FileDocCategorySizeDatePackage
JMXAccessorGetTask.javaAPI DocApache Tomcat 6.0.144630Fri Jul 20 04:20:36 BST 2007org.apache.catalina.ant.jmx

JMXAccessorGetTask

public class JMXAccessorGetTask extends JMXAccessorTask
Access JMX JSR 160 MBeans Server.
  • Get Mbeans attributes
  • Show Get result as Ant console log
  • Bind Get result as Ant properties

Examples:
Get a Mbean IDataSender attribute nrOfRequests and create a new ant property IDataSender.9025.nrOfRequests

<jmx:get
ref="jmx.server"
name="Catalina:type=IDataSender,host=localhost,senderAddress=192.168.1.2,senderPort=9025"
attribute="nrOfRequests"
resultproperty="IDataSender.9025.nrOfRequests"
echo="false">
/>

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

These tasks require Ant 1.6 or later interface.
author
Peter Rossbach
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
since
5.5.10

Fields Summary
private String
attribute
private static final String
info
Descriptive information describing this implementation.
Constructors Summary
Methods Summary
public java.lang.StringgetAttribute()

return
Returns the attribute.

        return attribute;
    
public java.lang.StringgetInfo()
Return descriptive information about this implementation and the corresponding version number, in the format <description>/<version>.


                        
       

        return (info);

    
public java.lang.StringjmxExecute(javax.management.MBeanServerConnection jmxServerConnection)
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.

exception
BuildException if an error occurs


        if (getName() == null) {
            throw new BuildException("Must specify a 'name'");
        }
        if ((attribute == null)) {
            throw new BuildException(
                    "Must specify a 'attribute' for get");
        }
        return  jmxGet(jmxServerConnection, getName());
     
protected java.lang.StringjmxGet(javax.management.MBeanServerConnection jmxServerConnection, java.lang.String name)

param
jmxServerConnection
param
name
return
The value of the given named attribute
throws
Exception

        String error = null;
        if(isEcho()) {
            handleOutput("MBean " + name + " get attribute " + attribute );
        }
        Object result = jmxServerConnection.getAttribute(
                new ObjectName(name), attribute);
        if (result != null) {
            echoResult(attribute,result);
            createProperty(result);
        } else
            error = "Attribute " + attribute + " is empty";
        return error;
    
public voidsetAttribute(java.lang.String attribute)

param
attribute The attribute to set.

        this.attribute = attribute;