org.apache.catalina.ant.jmx

Class JMXAccessorCondition

public class JMXAccessorCondition extends ProjectComponent implements Condition

Definition:
 
   <path id="catalina_ant">
       <fileset dir="${catalina.home}/server/lib">
           <include name="catalina-ant.jar"/>
       </fileset>
   </path>

   <typedef
       name="jmxCondition"
       classname="org.apache.catalina.ant.jmx.JMXAccessorCondition"
       classpathref="catalina_ant"/>
   <taskdef
       name="jmxOpen"
       classname="org.apache.catalina.ant.jmx.JMXAccessorTask"
       classpathref="catalina_ant"/>
 
Usage: Wait for start backup node
     <target name="wait">
       <jmxOpen
               host="${jmx.host}" port="${jmx.port}" username="${jmx.username}" password="${jmx.password}" />
        <waitfor maxwait="${maxwait}" maxwaitunit="second" timeoutproperty="server.timeout" >
           <and>
               <socket server="${server.name}" port="${server.port}"/>
               <http url="${url}"/>
               <jmxCondition
                   name="Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025"
                   operation="==" 
                   attribute="connected" value="true"
               />
               <jmxCondition
                   operation="&lt;"
                   name="Catalina:j2eeType=WebModule,name=//${tomcat.application.host}${tomcat.application.path},J2EEApplication=none,J2EEServer=none"
                   attribute="startupTime" value="250"
               />
           </and>
       </waitfor>
       <fail if="server.timeout" message="Server ${url} don't answer inside ${maxwait} sec" />
       <echo message="Server ${url} alive" />
   </target>

 
Allowed operation between jmx attribute and reference value: NOTE: For numeric expressions the type must be set and use xml entities as operations.
As type we currently support long and double.

Since: 5.5.10

Version: $Revision: 612599 $ $Date: 2008-01-16 23:37:36 +0100 (Wed, 16 Jan 2008) $

Author: Peter Rossbach

Method Summary
protected StringaccessJMXValue()
Get value from MBeans attribute
booleaneval()
This method evaluates the condition It support for operation ">,>=,<,<=" the types long and double.
StringgetAttribute()
StringgetHost()
StringgetIf()
StringgetInfo()
Return descriptive information about this implementation and the corresponding version number, in the format <description>/<version>.
protected MBeanServerConnectiongetJMXConnection()
Get JMXConnection (default look at jmx.server project reference from jmxOpen Task)
StringgetName()
StringgetOperation()
StringgetPassword()
StringgetPort()
StringgetRef()
StringgetType()
StringgetUnless()
StringgetUrl()
StringgetUsername()
StringgetValue()
voidsetAttribute(String attribute)
voidsetHost(String host)
voidsetIf(String c)
Only execute if a property of the given name exists in the current project.
voidsetName(String objectName)
voidsetOperation(String operation)
voidsetPassword(String password)
voidsetPort(String port)
voidsetRef(String refId)
voidsetType(String type)
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)
voidsetValue(String value)
protected booleantestIfCondition()
test the if condition
protected booleantestUnlessCondition()
test the unless condition

Method Detail

accessJMXValue

protected String accessJMXValue()
Get value from MBeans attribute

Returns: The value

eval

public boolean eval()
This method evaluates the condition It support for operation ">,>=,<,<=" the types long and double.

Returns: expression jmxValue operation value

getAttribute

public String getAttribute()

Returns: Returns the attribute.

getHost

public String getHost()

Returns: Returns the host.

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 (default look at jmx.server project reference from jmxOpen Task)

Returns: active JMXConnection

Throws: MalformedURLException IOException

getName

public String getName()

Returns: Returns the name.

getOperation

public String getOperation()

Returns: Returns the operation.

getPassword

public String getPassword()

Returns: Returns the password.

getPort

public String getPort()

Returns: Returns the port.

getRef

public String getRef()

Returns: Returns the ref.

getType

public String getType()

Returns: Returns the type.

getUnless

public String getUnless()

Returns: Returns the unlessCondition.

getUrl

public String getUrl()

Returns: Returns the url.

getUsername

public String getUsername()

Returns: Returns the username.

getValue

public String getValue()

Returns: Returns the value.

setAttribute

public void setAttribute(String attribute)

Parameters: attribute The attribute to set.

setHost

public void setHost(String host)

Parameters: host The host to set.

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)

Parameters: objectName The name to set.

setOperation

public void setOperation(String operation)

Parameters: operation The operation to set.

setPassword

public void setPassword(String password)

Parameters: password The password to set.

setPort

public void setPort(String port)

Parameters: port The port to set.

setRef

public void setRef(String refId)

Parameters: refId The ref to set.

setType

public void setType(String type)

Parameters: type The type 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)

Parameters: url The url to set.

setUsername

public void setUsername(String username)

Parameters: username The username to set.

setValue

public void setValue(String value)

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.