Class JMXAccessorCreateTask

java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
All Implemented Interfaces:
Cloneable

public class JMXAccessorCreateTask extends JMXAccessorTask
Create new MBean at JMX JSR 160 MBeans Server.
  • Create Mbeans
  • Create Mbeans with parameter
  • Create remote Mbeans with different classloader

Examples:
create a new Mbean at jmx.server connection

  <jmx:create
          ref="jmx.server"
          name="Catalina:type=MBeanFactory"
          className="org.apache.catalina.mbeans.MBeanFactory"
          classLoader="Catalina:type=ServerClassLoader,name=server">
           <Arg value="org.apache.catalina.mbeans.MBeanFactory" />
  </jmxCreate/>

WARNINGNot all Tomcat MBeans can create remotely and auto register by its parents! Please, use the MBeanFactory operation to generate valves and realms.

First call to a remote MBean server save the JMXConnection a reference jmx.server

These tasks require Ant 1.6 or later interface.
Since:
5.5.12
  • Constructor Details

    • JMXAccessorCreateTask

      public JMXAccessorCreateTask()
      Constructs a new JMXAccessorCreateTask.
  • Method Details

    • getClassLoader

      public String getClassLoader()
      Get the class loader for MBean creation.
      Returns:
      the class loader
    • setClassLoader

      public void setClassLoader(String classLoaderName)
      Set the class loader for MBean creation.
      Parameters:
      classLoaderName - the class loader to set
    • getClassName

      public String getClassName()
      Get the MBean class name.
      Returns:
      the class name
    • setClassName

      public void setClassName(String className)
      Set the MBean class name.
      Parameters:
      className - the class name to set
    • addArg

      public void addArg(Arg arg)
      Add an argument for MBean creation.
      Parameters:
      arg - the argument to add
    • getArgs

      public List<Arg> getArgs()
      Get the arguments for MBean creation.
      Returns:
      the arguments
    • setArgs

      public void setArgs(List<Arg> args)
      Set the arguments for MBean creation.
      Parameters:
      args - the arguments to set
    • jmxExecute

      public String jmxExecute(MBeanServerConnection jmxServerConnection) throws Exception
      Description copied from class: JMXAccessorTask
      Execute the specified command, based on the configured properties. The input stream will be closed upon completion of this task, whether it was executed successfully or not.
      Overrides:
      jmxExecute in class JMXAccessorTask
      Parameters:
      jmxServerConnection - The JMX connection that should be used
      Returns:
      An error message string in some situations
      Throws:
      Exception - if an error occurs
    • jmxCreate

      protected void jmxCreate(MBeanServerConnection jmxServerConnection, String name) throws Exception
      Create new MBean from ClassLoader identified by an ObjectName.
      Parameters:
      jmxServerConnection - Connection to the JMX server
      name - MBean name
      Throws:
      Exception - Error creating MBean