JMXAccessorTask (Tomcat API Documentation)
Keywords: org.apache.catalina.ant.jmx.JMXAccessorTask class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.catalina.ant.jmx
Class JMXAccessorTask

    java.lang.Object
      org.apache.tools.ant.ProjectComponent
          org.apache.tools.ant.Task
              org.apache.catalina.ant.BaseRedirectorHelperTask
                  org.apache.catalina.ant.jmx.JMXAccessorTask

All Implemented Interfaces:
  java.lang.Cloneable

Direct Known Subclasses:
  JMXAccessorCreateTask, JMXAccessorGetTask, JMXAccessorInvokeTask, JMXAccessorQueryTask, JMXAccessorSetTask, JMXAccessorUnregisterTask

    public class JMXAccessorTask

extends BaseRedirectorHelperTask

Access JMX JSR 160 MBeans Server.

- open more then one JSR 160 rmi connection
- Get/Set Mbeans attributes
- Call Mbean Operation with arguments
- Argument values can be converted from string to int,long,float,double,boolean,ObjectName or InetAddress
- Query Mbeans
- Show Get, Call, Query result at Ant console log
- Bind Get, Call, Query result at Ant properties

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 java.lang.String` | `JMX_SERVICE_PREFIX`
`static java.lang.String` | `JMX_SERVICE_SUFFIX`

Fields inherited from class org.apache.catalina.ant.BaseRedirectorHelperTask
`alwaysLog, failOnError, redirectErrStream, redirector, redirectorConfigured, redirectorElement, redirectOutput, redirectOutStream`

Fields inherited from class org.apache.tools.ant.Task
`target, taskName, taskType, wrapper`

Fields inherited from class org.apache.tools.ant.ProjectComponent
`description, location, project`

Constructor Summary
`JMXAccessorTask()`

Method Summary
`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.util.Map` | `getProperties()` get all properties, when project is there got all project Properties
`java.lang.String` | `getProperty(java.lang.String property)` get all Properties
`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

Methods inherited from class org.apache.catalina.ant.BaseRedirectorHelperTask
`addConfiguredRedirector, closeRedirector, handleErrorFlush, handleErrorOutput, handleFlush, handleFlush, handleOutput, handleOutput, isFailOnError, openRedirector, setAlwaysLog, setAppend, setCreateEmptyFiles, setError, setErrorProperty, setFailonerror, setLogError, setOutput, setOutputproperty`

Methods inherited from class org.apache.tools.ant.Task
`bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleInput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType`

Methods inherited from class org.apache.tools.ant.ProjectComponent
`clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### JMX_SERVICE_PREFIX

    public static java.lang.String JMX_SERVICE_PREFIX

### JMX_SERVICE_SUFFIX

    public static java.lang.String JMX_SERVICE_SUFFIX

Constructor Detail

### JMXAccessorTask

    public JMXAccessorTask()

Method Detail

### getInfo

    public java.lang.String getInfo()

  Return descriptive information about this implementation and the corresponding version number, in the format `<description>/<version>`.

### getName

    public java.lang.String getName()

  The name used at remote MbeanServer

### setName

    public void setName(java.lang.String objectName)

### getResultproperty

    public java.lang.String getResultproperty()

  Returns:
    Returns the resultproperty.

### setResultproperty

    public void setResultproperty(java.lang.String propertyName)

  Parameters:
    `propertyName` - The resultproperty to set.

### getDelimiter

    public java.lang.String getDelimiter()

  Returns:
    Returns the delimiter.

### setDelimiter

    public void setDelimiter(java.lang.String separator)

  Parameters:
    `separator` - The delimiter to set.

### isEcho

    public boolean isEcho()

  Returns:
    Returns the echo.

### setEcho

    public void setEcho(boolean echo)

  Parameters:
    `echo` - The echo to set.

### isSeparatearrayresults

    public boolean isSeparatearrayresults()

  Returns:
    Returns the separatearrayresults.

### setSeparatearrayresults

    public void setSeparatearrayresults(boolean separateArrayResults)

  Parameters:
    `separateArrayResults` - The separatearrayresults to set.

### getPassword

    public java.lang.String getPassword()

  The login password for the `Manager` application.

### setPassword

    public void setPassword(java.lang.String password)

### getUsername

    public java.lang.String getUsername()

  The login username for the `JMX` MBeanServer.

### setUsername

    public void setUsername(java.lang.String username)

### getUrl

    public java.lang.String getUrl()

  The URL of the `JMX JSR 160` MBeanServer to be used.

### setUrl

    public void setUrl(java.lang.String url)

### getHost

    public java.lang.String getHost()

  The Host of the `JMX JSR 160` MBeanServer to be used.

### setHost

    public void setHost(java.lang.String host)

### getPort

    public java.lang.String getPort()

  The Port of the `JMX JSR 160` MBeanServer to be used.

### setPort

    public void setPort(java.lang.String port)

### isUseRef

    public boolean isUseRef()

  Returns:
    Returns the useRef.

### getRef

    public java.lang.String getRef()

  Returns:
    Returns the ref.

### setRef

    public void setRef(java.lang.String refId)

  Parameters:
    `refId` - The ref to set.

### getIf

    public java.lang.String getIf()

  Returns:
    Returns the ifCondition.

### setIf

    public void setIf(java.lang.String c)

  Only execute if a property of the given name exists in the current project.

  Parameters:
    `c` - property name

### getUnless

    public java.lang.String getUnless()

  Returns:
    Returns the unlessCondition.

### setUnless

    public void setUnless(java.lang.String c)

  Only execute if a property of the given name does not exist in the current project.

  Parameters:
    `c` - property name

### execute

    public void execute()
                 throws org.apache.tools.ant.BuildException

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

  Overrides:
    `execute` in class `org.apache.tools.ant.Task`
  Throws:
    `org.apache.tools.ant.BuildException` - if a validation error occurs

### createJMXConnection

    public 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

  create a new JMX Connection with auth when username and password is set.

  Throws:
    `java.net.MalformedURLException`
    `java.io.IOException`

### 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

### accessJMXConnection

    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

  Get Current Connection from ref parameter or create a new one!

  Returns:
    The server connection
  Throws:
    `java.net.MalformedURLException`
    `java.io.IOException`

### getJMXConnection

    protected javax.management.MBeanServerConnection getJMXConnection()
                                                               throws java.net.MalformedURLException,
                                                                      java.io.IOException

  get JMXConnection

  Returns:
    The connection
  Throws:
    `java.net.MalformedURLException`
    `java.io.IOException`

### jmxExecute

    public java.lang.String jmxExecute(javax.management.MBeanServerConnection jmxServerConnection)
                                throws java.lang.Exception

  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:
    `java.lang.Exception` - if an error occurs

### convertStringToType

    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)?

  Parameters:
    `value` - The value
    `valueType` - The type
  Returns:
    The converted object

### echoResult

    protected void echoResult(java.lang.String name,
                              java.lang.Object result)

  Parameters:
    `name` - context of result
    `result` -

### createProperty

    protected void createProperty(java.lang.Object result)

  create result as property with name from attribute resultproperty

  Parameters:
    `result` - The result
  See Also:
    `createProperty(String, Object)`

### createProperty

    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`. Other option is that you delemit your result with a delimiter (java.util.StringTokenizer is used).

  Parameters:
    `propertyPrefix` -
    `result` -

### getProperties

    public java.util.Map getProperties()

  get all properties, when project is there got all project Properties

  Returns:
    properties

### getProperty

    public java.lang.String getProperty(java.lang.String property)

  get all Properties

  Parameters:
    `property` -
  Returns:
    The property

### setProperty

    public boolean setProperty(java.lang.String property,
                               java.lang.Object value)

  Parameters:
    `property` - The property
    `value` - The value
  Returns:
    True if successful

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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