FileDocCategorySizeDatePackage
JMXAccessorSetTask.javaAPI DocApache Tomcat 6.0.146593Fri Jul 20 04:20:34 BST 2007org.apache.catalina.ant.jmx

JMXAccessorSetTask

public class JMXAccessorSetTask 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: Set a Mbean Manager attribute maxActiveSessions. Set this attribute with fresh jmx connection without save reference

<jmx:set
host="127.0.0.1"
port="9014"
ref=""
name="Catalina:type=Manager,path="/ClusterTest",host=localhost"
attribute="maxActiveSessions"
value="100"
type="int"
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 String
value
private String
type
private boolean
convert
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);

    
protected java.lang.StringgetMBeanAttributeType(javax.management.MBeanServerConnection jmxServerConnection, java.lang.String name, java.lang.String attribute)
Get MBean Attriute from Mbean Server

param
jmxServerConnection
param
name
param
attribute
return
The type
throws
Exception

        ObjectName oname = new ObjectName(name);
        String mattrType = null;
        MBeanInfo minfo = jmxServerConnection.getMBeanInfo(oname);
        MBeanAttributeInfo attrs[] = minfo.getAttributes();
        if (attrs != null) {
            for (int i = 0; mattrType == null && i < attrs.length; i++) {
                if (attribute.equals(attrs[i].getName()))
                    mattrType = attrs[i].getType();
            }
        }
        return mattrType;
    
public java.lang.StringgetType()

return
Returns the type.

        return type;
    
public java.lang.StringgetValue()

return
Returns the value.

        return value;
    
public booleanisConvert()

return
Returns the convert.

        return convert;
    
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
Exception if an error occurs


        if (getName() == null) {
            throw new BuildException("Must specify a 'name'");
        }
        if ((attribute == null || value == null)) {
            throw new BuildException(
                    "Must specify a 'attribute' and 'value' for set");
        }
        return  jmxSet(jmxServerConnection, getName());
     
protected java.lang.StringjmxSet(javax.management.MBeanServerConnection jmxServerConnection, java.lang.String name)

param
jmxServerConnection
param
name
throws
Exception

        Object realValue;
        if (type != null) {
            realValue = convertStringToType(value, type);
        } else {
            if (isConvert()) {
                String mType = getMBeanAttributeType(jmxServerConnection, name,
                        attribute);
                realValue = convertStringToType(value, mType);
            } else
                realValue = value;
        }
        jmxServerConnection.setAttribute(new ObjectName(name), new Attribute(
                attribute, realValue));
        return null;
    
public voidsetAttribute(java.lang.String attribute)

param
attribute The attribute to set.

        this.attribute = attribute;
    
public voidsetConvert(boolean convert)

param
convert The convert to set.

        this.convert = convert;
    
public voidsetType(java.lang.String valueType)

param
valueType The type to set.

        this.type = valueType;
    
public voidsetValue(java.lang.String value)

param
value The value to set.

        this.value = value;