Class JMXAccessorCondition

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

public class JMXAccessorCondition extends JMXAccessorConditionBase
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:
  • == equals
  • != not equals
  • > greater than (&gt;)
  • >= greater than or equals (&gt;=)
  • < lesser than (&lt;)
  • <= lesser than or equals (&lt;=)
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
  • Constructor Details

    • JMXAccessorCondition

      public JMXAccessorCondition()
  • Method Details

    • getOperation

      public String getOperation()
      Returns:
      Returns the operation.
    • setOperation

      public void setOperation(String operation)
      Parameters:
      operation - The operation to set.
    • getType

      public String getType()
      Returns:
      Returns the type.
    • setType

      public void setType(String type)
      Parameters:
      type - The type to set.
    • getIf

      public String getIf()
      Returns:
      Returns the ifCondition.
    • setIf

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

      public String getUnless()
      Returns:
      Returns the unlessCondition.
    • 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
    • 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.
      Returns:
      expression jmxValue operation value