JSR 160 MBeans Server.
Examples:
Set a Mbean Manager attribute maxActiveSessions.
Set this attribute with fresh jmx connection without save reference
These tasks require Ant 1.6 or later interface.
| Method from org.apache.catalina.ant.jmx.JMXAccessorSetTask Detail: |
public String getAttribute() {
return attribute;
}
|
public String getInfo() {
return (info);
}
Return descriptive information about this implementation and the
corresponding version number, in the format
<description>/<version>. |
protected String getMBeanAttributeType(MBeanServerConnection jmxServerConnection,
String name,
String attribute) 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;
}
Get MBean Attriute from Mbean Server |
public String getType() {
return type;
}
|
public String getValue() {
return value;
}
|
public boolean isConvert() {
return convert;
}
|
public String jmxExecute(MBeanServerConnection jmxServerConnection) throws Exception {
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());
}
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. |
protected String jmxSet(MBeanServerConnection jmxServerConnection,
String 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 void setAttribute(String attribute) {
this.attribute = attribute;
}
|
public void setConvert(boolean convert) {
this.convert = convert;
}
|
public void setType(String valueType) {
this.type = valueType;
}
|
public void setValue(String value) {
this.value = value;
}
|