public class JMXAccessorTask extends BaseRedirectorHelperTask
<jmxOpen host="127.0.0.1" port="9014" username="monitorRole" password="mysecret" ref="jmx.myserver" />All calls after opening with same refid reuse the connection.
First call to a remote MBeanserver save the JMXConnection a referenz jmx.server
All JMXAccessorXXXTask support the attribute if and unless. With if the task is only execute when property exist and with unless when property not exists.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
JMX_SERVICE_PREFIX |
static java.lang.String |
JMX_SERVICE_SUFFIX |
alwaysLog, failOnError, redirectErrStream, redirector, redirectorConfigured, redirectorElement, redirectOutput, redirectOutStream
Constructor and Description |
---|
JMXAccessorTask() |
Modifier and Type | Method and Description |
---|---|
static javax.management.MBeanServerConnection |
accessJMXConnection(org.apache.tools.ant.Project project,
java.lang.String url,
java.lang.String host,
java.lang.String port,
java.lang.String username,
java.lang.String password,
java.lang.String refId)
Get Current Connection from ref parameter or create a new one!
|
protected java.lang.Object |
convertStringToType(java.lang.String value,
java.lang.String valueType)
Convert string to datatype FIXME How we can transfer values from ant
project reference store (ref)?
|
static javax.management.MBeanServerConnection |
createJMXConnection(java.lang.String url,
java.lang.String host,
java.lang.String port,
java.lang.String username,
java.lang.String password)
create a new JMX Connection with auth when username and password is set.
|
protected void |
createProperty(java.lang.Object result)
create result as property with name from attribute resultproperty
|
protected void |
createProperty(java.lang.String propertyPrefix,
java.lang.Object result)
create result as property with name from property prefix When result is
an array and isSeparateArrayResults is true, resultproperty used as
prefix (
resultproperty.0-array.length and store the
result array length at resultproperty.length . |
protected void |
echoResult(java.lang.String name,
java.lang.Object result) |
void |
execute()
Execute the specified command.
|
java.lang.String |
getDelimiter() |
java.lang.String |
getHost()
The Host of the
JMX JSR 160 MBeanServer to be used. |
java.lang.String |
getIf() |
java.lang.String |
getInfo()
Return descriptive information about this implementation and the
corresponding version number, in the format
<description>/<version> . |
protected javax.management.MBeanServerConnection |
getJMXConnection()
get JMXConnection
|
java.lang.String |
getName()
The name used at remote MbeanServer
|
java.lang.String |
getPassword()
The login password for the
Manager application. |
java.lang.String |
getPort()
The Port of the
JMX JSR 160 MBeanServer to be used. |
java.lang.String |
getProperty(java.lang.String property)
Get Property
|
java.lang.String |
getRef() |
java.lang.String |
getResultproperty() |
java.lang.String |
getUnless() |
java.lang.String |
getUrl()
The URL of the
JMX JSR 160 MBeanServer to be used. |
java.lang.String |
getUsername()
The login username for the
JMX MBeanServer. |
boolean |
isEcho() |
boolean |
isSeparatearrayresults() |
boolean |
isUseRef() |
java.lang.String |
jmxExecute(javax.management.MBeanServerConnection jmxServerConnection)
Execute the specified command, based on the configured properties.
|
void |
setDelimiter(java.lang.String separator) |
void |
setEcho(boolean echo) |
void |
setHost(java.lang.String host) |
void |
setIf(java.lang.String c)
Only execute if a property of the given name exists in the current
project.
|
void |
setName(java.lang.String objectName) |
void |
setPassword(java.lang.String password) |
void |
setPort(java.lang.String port) |
boolean |
setProperty(java.lang.String property,
java.lang.Object value) |
void |
setRef(java.lang.String refId) |
void |
setResultproperty(java.lang.String propertyName) |
void |
setSeparatearrayresults(boolean separateArrayResults) |
void |
setUnless(java.lang.String c)
Only execute if a property of the given name does not exist in the
current project.
|
void |
setUrl(java.lang.String url) |
void |
setUsername(java.lang.String username) |
protected boolean |
testIfCondition()
test the if condition
|
protected boolean |
testUnlessCondition()
test the unless condition
|
addConfiguredRedirector, closeRedirector, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, handleOutput, isFailOnError, openRedirector, setAlwaysLog, setAppend, setCreateEmptyFiles, setError, setErrorProperty, setFailonerror, setLogError, setOutput, setOutputproperty
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleInput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
public static final java.lang.String JMX_SERVICE_PREFIX
public static final java.lang.String JMX_SERVICE_SUFFIX
public java.lang.String getInfo()
<description>/<version>
.public java.lang.String getName()
public void setName(java.lang.String objectName)
public java.lang.String getResultproperty()
public void setResultproperty(java.lang.String propertyName)
propertyName
- The resultproperty to set.public java.lang.String getDelimiter()
public void setDelimiter(java.lang.String separator)
separator
- The delimiter to set.public boolean isEcho()
public void setEcho(boolean echo)
echo
- The echo to set.public boolean isSeparatearrayresults()
public void setSeparatearrayresults(boolean separateArrayResults)
separateArrayResults
- The separatearrayresults to set.public java.lang.String getPassword()
Manager
application.public void setPassword(java.lang.String password)
public java.lang.String getUsername()
JMX
MBeanServer.public void setUsername(java.lang.String username)
public java.lang.String getUrl()
JMX JSR 160
MBeanServer to be used.public void setUrl(java.lang.String url)
public java.lang.String getHost()
JMX JSR 160
MBeanServer to be used.public void setHost(java.lang.String host)
public java.lang.String getPort()
JMX JSR 160
MBeanServer to be used.public void setPort(java.lang.String port)
public boolean isUseRef()
public java.lang.String getRef()
public void setRef(java.lang.String refId)
refId
- The ref to set.public java.lang.String getIf()
public void setIf(java.lang.String c)
c
- property namepublic java.lang.String getUnless()
public void setUnless(java.lang.String c)
c
- property namepublic void execute() throws org.apache.tools.ant.BuildException
execute
in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException
- if a validation error occurspublic static javax.management.MBeanServerConnection createJMXConnection(java.lang.String url, java.lang.String host, java.lang.String port, java.lang.String username, java.lang.String password) throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
protected boolean testIfCondition()
protected boolean testUnlessCondition()
public static javax.management.MBeanServerConnection accessJMXConnection(org.apache.tools.ant.Project project, java.lang.String url, java.lang.String host, java.lang.String port, java.lang.String username, java.lang.String password, java.lang.String refId) throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
protected javax.management.MBeanServerConnection getJMXConnection() throws java.net.MalformedURLException, java.io.IOException
java.net.MalformedURLException
java.io.IOException
public java.lang.String jmxExecute(javax.management.MBeanServerConnection jmxServerConnection) throws java.lang.Exception
java.lang.Exception
- if an error occursprotected java.lang.Object convertStringToType(java.lang.String value, java.lang.String valueType)
value
- The valuevalueType
- The typeprotected void echoResult(java.lang.String name, java.lang.Object result)
name
- context of resultresult
- protected void createProperty(java.lang.Object result)
result
- The resultcreateProperty(String, Object)
protected void createProperty(java.lang.String propertyPrefix, java.lang.Object result)
resultproperty.0-array.length
and store the
result array length at resultproperty.length
. Other
option is that you delimit your result with a delimiter
(java.util.StringTokenizer is used).propertyPrefix
- result
- public java.lang.String getProperty(java.lang.String property)
property
- namepublic boolean setProperty(java.lang.String property, java.lang.Object value)
property
- The propertyvalue
- The valueCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.