org.apache.catalina.ant.jmx

Class JMXAccessorTask

public class JMXAccessorTask extends BaseRedirectorHelperTask

Access JMX JSR 160 MBeans Server. Examples: open server with reference and autorisation
 
    <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.
NOTE : These tasks require Ant 1.6 or later interface.

Since: 5.5.10

Version: $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (Tue, 24 Oct 2006) $

Author: Peter Rossbach

Field Summary
static StringJMX_SERVICE_PREFIX
static StringJMX_SERVICE_SUFFIX
Method Summary
static MBeanServerConnectionaccessJMXConnection(Project project, String url, String host, String port, String username, String password, String refId)
Get Current Connection from ref parameter or create a new one!
protected ObjectconvertStringToType(String value, String valueType)
Convert string to datatype FIXME How we can transfer values from ant project reference store (ref)?
static MBeanServerConnectioncreateJMXConnection(String url, String host, String port, String username, String password)
create a new JMX Connection with auth when username and password is set.
protected voidcreateProperty(Object result)
create result as property with name from attribute resultproperty
protected voidcreateProperty(String propertyPrefix, 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 voidechoResult(String name, Object result)
voidexecute()
Execute the specified command.
StringgetDelimiter()
StringgetHost()
The Host of the JMX JSR 160 MBeanServer to be used.
StringgetIf()
StringgetInfo()
Return descriptive information about this implementation and the corresponding version number, in the format <description>/<version>.
protected MBeanServerConnectiongetJMXConnection()
get JMXConnection
StringgetName()
The name used at remote MbeanServer
StringgetPassword()
The login password for the Manager application.
StringgetPort()
The Port of the JMX JSR 160 MBeanServer to be used.
MapgetProperties()
get all properties, when project is there got all project Properties
StringgetProperty(String property)
get all Properties
StringgetRef()
StringgetResultproperty()
StringgetUnless()
StringgetUrl()
The URL of the JMX JSR 160 MBeanServer to be used.
StringgetUsername()
The login username for the JMX MBeanServer.
booleanisEcho()
booleanisSeparatearrayresults()
booleanisUseRef()
StringjmxExecute(MBeanServerConnection jmxServerConnection)
Execute the specified command, based on the configured properties.
voidsetDelimiter(String separator)
voidsetEcho(boolean echo)
voidsetHost(String host)
voidsetIf(String c)
Only execute if a property of the given name exists in the current project.
voidsetName(String objectName)
voidsetPassword(String password)
voidsetPort(String port)
booleansetProperty(String property, Object value)
voidsetRef(String refId)
voidsetResultproperty(String propertyName)
voidsetSeparatearrayresults(boolean separateArrayResults)
voidsetUnless(String c)
Only execute if a property of the given name does not exist in the current project.
voidsetUrl(String url)
voidsetUsername(String username)
protected booleantestIfCondition()
test the if condition
protected booleantestUnlessCondition()
test the unless condition

Field Detail

JMX_SERVICE_PREFIX

public static String JMX_SERVICE_PREFIX

JMX_SERVICE_SUFFIX

public static String JMX_SERVICE_SUFFIX

Method Detail

accessJMXConnection

public static MBeanServerConnection accessJMXConnection(Project project, String url, String host, String port, String username, String password, String refId)
Get Current Connection from ref parameter or create a new one!

Returns: The server connection

Throws: MalformedURLException IOException

convertStringToType

protected Object convertStringToType(String value, String valueType)
Convert string to datatype FIXME How we can transfer values from ant project reference store (ref)?

Parameters: value The value valueType The type

Returns: The converted object

createJMXConnection

public static MBeanServerConnection createJMXConnection(String url, String host, String port, String username, String password)
create a new JMX Connection with auth when username and password is set.

createProperty

protected void createProperty(Object result)
create result as property with name from attribute resultproperty

Parameters: result The result

See Also: JMXAccessorTask

createProperty

protected void createProperty(String propertyPrefix, 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. Other option is that you delemit your result with a delimiter (java.util.StringTokenizer is used).

Parameters: propertyPrefix result

echoResult

protected void echoResult(String name, Object result)

Parameters: name context of result result

execute

public void execute()
Execute the specified command. This logic only performs the common attribute validation required by all subclasses; it does not perform any functional logic directly.

Throws: BuildException if a validation error occurs

getDelimiter

public String getDelimiter()

Returns: Returns the delimiter.

getHost

public String getHost()
The Host of the JMX JSR 160 MBeanServer to be used.

getIf

public String getIf()

Returns: Returns the ifCondition.

getInfo

public String getInfo()
Return descriptive information about this implementation and the corresponding version number, in the format <description>/<version>.

getJMXConnection

protected MBeanServerConnection getJMXConnection()
get JMXConnection

Returns: The connection

Throws: MalformedURLException IOException

getName

public String getName()
The name used at remote MbeanServer

getPassword

public String getPassword()
The login password for the Manager application.

getPort

public String getPort()
The Port of the JMX JSR 160 MBeanServer to be used.

getProperties

public Map getProperties()
get all properties, when project is there got all project Properties

Returns: properties

getProperty

public String getProperty(String property)
get all Properties

Parameters: property

Returns: The property

getRef

public String getRef()

Returns: Returns the ref.

getResultproperty

public String getResultproperty()

Returns: Returns the resultproperty.

getUnless

public String getUnless()

Returns: Returns the unlessCondition.

getUrl

public String getUrl()
The URL of the JMX JSR 160 MBeanServer to be used.

getUsername

public String getUsername()
The login username for the JMX MBeanServer.

isEcho

public boolean isEcho()

Returns: Returns the echo.

isSeparatearrayresults

public boolean isSeparatearrayresults()

Returns: Returns the separatearrayresults.

isUseRef

public boolean isUseRef()

Returns: Returns the useRef.

jmxExecute

public String jmxExecute(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.

Throws: Exception if an error occurs

setDelimiter

public void setDelimiter(String separator)

Parameters: separator The delimiter to set.

setEcho

public void setEcho(boolean echo)

Parameters: echo The echo to set.

setHost

public void setHost(String host)

setIf

public void setIf(String c)
Only execute if a property of the given name exists in the current project.

Parameters: c property name

setName

public void setName(String objectName)

setPassword

public void setPassword(String password)

setPort

public void setPort(String port)

setProperty

public boolean setProperty(String property, Object value)

Parameters: property The property value The value

Returns: True if successful

setRef

public void setRef(String refId)

Parameters: refId The ref to set.

setResultproperty

public void setResultproperty(String propertyName)

Parameters: propertyName The resultproperty to set.

setSeparatearrayresults

public void setSeparatearrayresults(boolean separateArrayResults)

Parameters: separateArrayResults The separatearrayresults to set.

setUnless

public void setUnless(String c)
Only execute if a property of the given name does not exist in the current project.

Parameters: c property name

setUrl

public void setUrl(String url)

setUsername

public void setUsername(String username)

testIfCondition

protected boolean testIfCondition()
test the if condition

Returns: true if there is no if condition, or the named property exists

testUnlessCondition

protected boolean testUnlessCondition()
test the unless condition

Returns: true if there is no unless condition, or there is a named property but it doesn't exist

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.