FileDocCategorySizeDatePackage
JMXAccessorEqualsCondition.javaAPI DocApache Tomcat 6.0.147368Fri Jul 20 04:20:36 BST 2007org.apache.catalina.ant.jmx

JMXAccessorEqualsCondition

public class JMXAccessorEqualsCondition extends org.apache.tools.ant.ProjectComponent implements org.apache.tools.ant.taskdefs.condition.Condition
Definition
<path id="catalina_ant">
<fileset dir="${catalina.home}/server/lib">
<include name="catalina-ant.jar"/>
<include name="catalina-ant-jmx.jar"/>
</fileset>
</path>

<typedef
name="jmxEquals"
classname="org.apache.catalina.ant.jmx.JMXAccessorEqualsCondition"
classpathref="catalina_ant"/>
usage: Wait for start backup node
<target name="wait">
<waitfor maxwait="${maxwait}" maxwaitunit="second" timeoutproperty="server.timeout" >
<and>
<socket server="${server.name}" port="${server.port}"/>
<http url="${url}"/>
<jmxEquals
host="localhost" port="9014" username="controlRole" password="tomcat"
name="Catalina:type=IDataSender,host=localhost,senderAddress=192.168.111.1,senderPort=9025"
attribute="connected" value="true"
/>
</and>
</waitfor>
<fail if="server.timeout" message="Server ${url} don't answer inside ${maxwait} sec" />
<echo message="Server ${url} alive" />
</target>

author
Peter Rossbach
version
$Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
since
5.5.10

Fields Summary
private String
url
private String
host
private String
port
private String
password
private String
username
private String
name
private String
attribute
private String
value
private String
ref
private static final String
info
Descriptive information describing this implementation.
Constructors Summary
Methods Summary
protected java.lang.StringaccessJMXValue()

return
The value

        try {
            Object result = getJMXConnection().getAttribute(
                    new ObjectName(name), attribute);
            if(result != null)
                return result.toString();
        } catch (Exception e) {
            // ignore access or connection open errors
        }
        return null;
    
public booleaneval()

        if (value == null) {
            throw new BuildException("value attribute is not set");
        }
        if ((name == null || attribute == null)) {
            throw new BuildException(
                    "Must specify a 'attribute', name for equals condition");
        }
        //FIXME check url or host/parameter
        String jmxValue = accessJMXValue();
        if(jmxValue != null)
            return jmxValue.equals(value);
        return false;
    
public java.lang.StringgetAttribute()

return
Returns the attribute.

        return attribute;
    
public java.lang.StringgetHost()

return
Returns the host.

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


                        
       

        return (info);

    
protected javax.management.MBeanServerConnectiongetJMXConnection()

        return JMXAccessorTask.accessJMXConnection(
                getProject(),
                getUrl(), getHost(),
                getPort(), getUsername(), getPassword(), ref);
    
public java.lang.StringgetName()

return
Returns the name.

        return name;
    
public java.lang.StringgetPassword()

return
Returns the password.

        return password;
    
public java.lang.StringgetPort()

return
Returns the port.

        return port;
    
public java.lang.StringgetRef()

return
Returns the ref.

        return ref;
    
public java.lang.StringgetUrl()

return
Returns the url.

        return url;
    
public java.lang.StringgetUsername()

return
Returns the username.

        return username;
    
public java.lang.StringgetValue()

return
Returns the value.

        return value;
    
public voidsetAttribute(java.lang.String attribute)

param
attribute The attribute to set.

        this.attribute = attribute;
    
public voidsetHost(java.lang.String host)

param
host The host to set.

        this.host = host;
    
public voidsetName(java.lang.String objectName)

param
objectName The name to set.

        this.name = objectName;
    
public voidsetPassword(java.lang.String password)

param
password The password to set.

        this.password = password;
    
public voidsetPort(java.lang.String port)

param
port The port to set.

        this.port = port;
    
public voidsetRef(java.lang.String refId)

param
refId The ref to set.

        this.ref = refId;
    
public voidsetUrl(java.lang.String url)

param
url The url to set.

        this.url = url;
    
public voidsetUsername(java.lang.String username)

param
username The username to set.

        this.username = username;
    
public voidsetValue(java.lang.String value)

        this.value = value;