org.apache.catalina.ant.jmx
Class JMXAccessorCondition

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.catalina.ant.jmx.JMXAccessorCondition
All Implemented Interfaces:
java.lang.Cloneable, org.apache.tools.ant.taskdefs.condition.Condition

public class JMXAccessorCondition
extends org.apache.tools.ant.ProjectComponent
implements org.apache.tools.ant.taskdefs.condition.Condition

Definition:

 
   <path id="catalina_ant">
       <fileset dir="${catalina.home}/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: 515 $ $Date: 2008-03-17 22:02:23 +0100 (Mon, 17 Mar 2008) $
Author:
Peter Rossbach

Field Summary
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
JMXAccessorCondition()
           
 
Method Summary
protected  java.lang.String accessJMXValue()
          Get value from MBeans attribute
 boolean eval()
          This method evaluates the condition It support for operation ">,>=,<,<=" the types long and double.
 java.lang.String getAttribute()
           
 java.lang.String getHost()
           
 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 (default look at jmx.server project reference from jmxOpen Task)
 java.lang.String getName()
           
 java.lang.String getOperation()
           
 java.lang.String getPassword()
           
 java.lang.String getPort()
           
 java.lang.String getRef()
           
 java.lang.String getType()
           
 java.lang.String getUnless()
           
 java.lang.String getUrl()
           
 java.lang.String getUsername()
           
 java.lang.String getValue()
           
 void setAttribute(java.lang.String attribute)
           
 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 setOperation(java.lang.String operation)
           
 void setPassword(java.lang.String password)
           
 void setPort(java.lang.String port)
           
 void setRef(java.lang.String refId)
           
 void setType(java.lang.String type)
           
 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)
           
 void setValue(java.lang.String value)
           
protected  boolean testIfCondition()
          test the if condition
protected  boolean testUnlessCondition()
          test the unless condition
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, log, log, setDescription, setLocation, setProject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMXAccessorCondition

public JMXAccessorCondition()
Method Detail

getInfo

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


getOperation

public java.lang.String getOperation()
Returns:
Returns the operation.

setOperation

public void setOperation(java.lang.String operation)
Parameters:
operation - The operation to set.

getType

public java.lang.String getType()
Returns:
Returns the type.

setType

public void setType(java.lang.String type)
Parameters:
type - The type to set.

getAttribute

public java.lang.String getAttribute()
Returns:
Returns the attribute.

setAttribute

public void setAttribute(java.lang.String attribute)
Parameters:
attribute - The attribute to set.

getHost

public java.lang.String getHost()
Returns:
Returns the host.

setHost

public void setHost(java.lang.String host)
Parameters:
host - The host to set.

getName

public java.lang.String getName()
Returns:
Returns the name.

setName

public void setName(java.lang.String objectName)
Parameters:
objectName - The name to set.

getPassword

public java.lang.String getPassword()
Returns:
Returns the password.

setPassword

public void setPassword(java.lang.String password)
Parameters:
password - The password to set.

getPort

public java.lang.String getPort()
Returns:
Returns the port.

setPort

public void setPort(java.lang.String port)
Parameters:
port - The port to set.

getUrl

public java.lang.String getUrl()
Returns:
Returns the url.

setUrl

public void setUrl(java.lang.String url)
Parameters:
url - The url to set.

getUsername

public java.lang.String getUsername()
Returns:
Returns the username.

setUsername

public void setUsername(java.lang.String username)
Parameters:
username - The username to set.

getValue

public java.lang.String getValue()
Returns:
Returns the value.

setValue

public void setValue(java.lang.String value)

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

getJMXConnection

protected javax.management.MBeanServerConnection getJMXConnection()
                                                           throws java.net.MalformedURLException,
                                                                  java.io.IOException
Get JMXConnection (default look at jmx.server project reference from jmxOpen Task)

Returns:
active JMXConnection
Throws:
java.net.MalformedURLException
java.io.IOException

accessJMXValue

protected java.lang.String accessJMXValue()
Get value from MBeans attribute

Returns:
The 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

eval

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

Specified by:
eval in interface org.apache.tools.ant.taskdefs.condition.Condition
Returns:
expression jmxValue operation value


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