Class JMXAccessorInvokeTask

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class JMXAccessorInvokeTask
    extends JMXAccessorTask
    Access JMX JSR 160 MBeans Server.
    • open more then one JSR 160 rmi connection
    • Get/Set Mbeans attributes
    • Call Mbean Operation with arguments
    • Argument values can be converted from string to int,long,float,double,boolean,ObjectName or InetAddress
    • Query Mbeans
    • Show Get, Call, Query result at Ant console log
    • Bind Get, Call, Query result at Ant properties
    Examples:
    • Get a session attribute hello from session with ref ${sessionid.0} form app Catalina:type=Manager,context=/ClusterTest,host=localhost
         <jmx:invoke
                 name="Catalina:type=Manager,context=/ClusterTest,host=localhost"
                 operation="getSessionAttribute"
                 resultproperty="hello">
               <arg value="${sessionid.0}"/>
               <arg value="Hello"/>
         </jmx:invoke>
       
    • Create new AccessLogger at localhost <jmx:invoke name="Catalina:type=MBeanFactory" operation="createAccessLoggerValve" resultproperty="accessLoggerObjectName" > <arg value="Catalina:type=Host,host=localhost"/> </jmx:invoke>
    • Remove existing AccessLogger at localhost <jmx:invoke name="Catalina:type=MBeanFactory" operation="removeValve" > <arg value="Catalina:type=Valve,name=AccessLogValve,host=localhost"/> </jmx:invoke>

    First call to a remote MBeanserver save the JMXConnection a referenz jmx.server

    These tasks require Ant 1.6 or later interface.
    Since:
    5.5.10
    Author:
    Peter Rossbach
    • Constructor Detail

      • JMXAccessorInvokeTask

        public JMXAccessorInvokeTask()
    • Method Detail

      • getOperation

        public java.lang.String getOperation()
        Returns:
        Returns the operation.
      • setOperation

        public void setOperation​(java.lang.String operation)
        Parameters:
        operation - The operation to set.
      • addArg

        public void addArg​(Arg arg)
      • getArgs

        public java.util.List<Arg> getArgs()
        Returns:
        Returns the args.
      • setArgs

        public void setArgs​(java.util.List<Arg> args)
        Parameters:
        args - The args to set.
      • jmxExecute

        public java.lang.String jmxExecute​(javax.management.MBeanServerConnection jmxServerConnection)
                                    throws java.lang.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:
        java.lang.Exception - if an error occurs
      • jmxInvoke

        protected java.lang.String jmxInvoke​(javax.management.MBeanServerConnection jmxServerConnection,
                                             java.lang.String name)
                                      throws java.lang.Exception
        Invoke specified operation.
        Parameters:
        jmxServerConnection - Connection to the JMX server
        name - The MBean name
        Returns:
        null (no error message to report other than exception)
        Throws:
        java.lang.Exception - An error occurred