Methods Summary |
---|
protected java.lang.String | accessJMXValue()Get value from MBeans attribute
try {
Object result = getJMXConnection().getAttribute(
new ObjectName(name), attribute);
if(result != null)
return result.toString();
} catch (Exception e) {
// ignore access or connection open errors
}
return null;
|
public boolean | eval()This method evaluates the condition
It support for operation ">,>=,<,<=" the types long and double .
if (operation == null) {
throw new BuildException("operation attribute is not set");
}
if (value == null) {
throw new BuildException("value attribute is not set");
}
if ((name == null || attribute == null)) {
throw new BuildException(
"Must specify a 'attribute', name for equals condition");
}
if (testIfCondition() && testUnlessCondition()) {
String jmxValue = accessJMXValue();
if (jmxValue != null) {
String op = getOperation();
if ("==".equals(op)) {
return jmxValue.equals(value);
} else if ("!=".equals(op)) {
return !jmxValue.equals(value);
} else {
if ("long".equals(type)) {
long jvalue = Long.parseLong(jmxValue);
long lvalue = Long.parseLong(value);
if (">".equals(op)) {
return jvalue > lvalue;
} else if (">=".equals(op)) {
return jvalue >= lvalue;
} else if ("<".equals(op)) {
return jvalue < lvalue;
} else if ("<=".equals(op)) {
return jvalue <= lvalue;
}
} else if ("double".equals(type)) {
double jvalue = Double.parseDouble(jmxValue);
double dvalue = Double.parseDouble(value);
if (">".equals(op)) {
return jvalue > dvalue;
} else if (">=".equals(op)) {
return jvalue >= dvalue;
} else if ("<".equals(op)) {
return jvalue < dvalue;
} else if ("<=".equals(op)) {
return jvalue <= dvalue;
}
}
}
}
return false;
}
return true;
|
public java.lang.String | getAttribute()
return attribute;
|
public java.lang.String | getHost()
return host;
|
public java.lang.String | getIf()
return ifCondition;
|
public java.lang.String | getInfo()Return descriptive information about this implementation and the
corresponding version number, in the format
<description>/<version> .
return (info);
|
protected javax.management.MBeanServerConnection | getJMXConnection()Get JMXConnection (default look at jmx.server project reference from jmxOpen Task)
return JMXAccessorTask.accessJMXConnection(
getProject(),
getUrl(), getHost(),
getPort(), getUsername(), getPassword(), ref);
|
public java.lang.String | getName()
return name;
|
public java.lang.String | getOperation()
return operation;
|
public java.lang.String | getPassword()
return password;
|
public java.lang.String | getPort()
return port;
|
public java.lang.String | getRef()
return ref;
|
public java.lang.String | getType()
return type;
|
public java.lang.String | getUnless()
return unlessCondition;
|
public java.lang.String | getUrl()
return url;
|
public java.lang.String | getUsername()
return username;
|
public java.lang.String | getValue()
return value;
|
public void | setAttribute(java.lang.String attribute)
this.attribute = attribute;
|
public void | setHost(java.lang.String host)
this.host = host;
|
public void | setIf(java.lang.String c)Only execute if a property of the given name exists in the current project.
ifCondition = c;
|
public void | setName(java.lang.String objectName)
this.name = objectName;
|
public void | setOperation(java.lang.String operation)
this.operation = operation;
|
public void | setPassword(java.lang.String password)
this.password = password;
|
public void | setPort(java.lang.String port)
this.port = port;
|
public void | setRef(java.lang.String refId)
this.ref = refId;
|
public void | setType(java.lang.String type)
this.type = type;
|
public void | setUnless(java.lang.String c)Only execute if a property of the given name does not
exist in the current project.
unlessCondition = c;
|
public void | setUrl(java.lang.String url)
this.url = url;
|
public void | setUsername(java.lang.String username)
this.username = username;
|
public void | setValue(java.lang.String value)
this.value = value;
|
protected boolean | testIfCondition()test the if condition
if (ifCondition == null || "".equals(ifCondition)) {
return true;
}
return getProject().getProperty(ifCondition) != null;
|
protected boolean | testUnlessCondition()test the unless condition
if (unlessCondition == null || "".equals(unlessCondition)) {
return true;
}
return getProject().getProperty(unlessCondition) == null;
|