org.objectweb.jonas.management.monitoring
Class JMXProxy

java.lang.Object
  extended by org.objectweb.jonas.management.monitoring.JMXProxy
Direct Known Subclasses:
ClusterDaemonProxy, ServerProxy

public abstract class JMXProxy
extends java.lang.Object

Abstract class acting as a JMXConnector client It is implemented by ServerProxy or ClusterDaemonProxy

Author:
durieuxp, S. Ali Tokmen

Field Summary
protected  javax.management.MBeanServerConnection connection
          JMX connection
protected  javax.management.remote.JMXConnector connector
          JMX Connector
protected  java.util.Map env
          Environment used to get the connection
static int FAILED
          Server which can't be reached after a several number of retries
static int INITIAL
          This is the initial state
protected  JmxServiceImpl jmx
          Local JMX server.
protected static org.objectweb.util.monolog.api.Logger logger
          logger for traces.
protected  java.lang.String name
          Unique name of the remote object
protected  java.lang.String objectName
          The OBJECT_NAME of this Proxy MBean Must be initialized before checking connection.
static int RUNNING
          Server is RUNNING and its reacheable
protected  javax.management.ObjectName serverOn
          The server's ObjectName (this corresponds to the J2EEServer MBean registered in the represented server's MBean server)
static int STARTING
          Server is starting (temporary state)
protected  int state
          State of the remote object (as seen from the proxy)
static int STOPPED
          Server is stopped
static int STOPPING
          Server is stopping (temporary state)
static int UNKNOWN
          Server which started without the discovery and can't be reached after a several number of retries
static int UNREACHABLE
          This state is corresponding to the situation when the JMX connection is broken - maybe temporary.
 
Constructor Summary
JMXProxy(DomainMonitor dm, java.lang.String name, java.util.Collection urls)
          Constructor: saves information and connects if urls is not null or the proxy is created for the local server.
 
Method Summary
protected  boolean checkConnection()
          Check the established connection to the remote object, or try to establish a connection if the connection object is null.
 boolean connect(java.util.Collection urls)
          Try to connect this Proxy to its Server
 void disconnect()
          Disconnect the proxy if connected.
 java.lang.Object getAttribute(javax.management.ObjectName on, java.lang.String attribute)
          Get an MBean Attribute on the remote server
 javax.management.AttributeList getAttributes(javax.management.ObjectName on, java.lang.String[] attributes)
          Get a group of MBean Attributes on the remote server
 javax.management.MBeanServerConnection getConnection()
           
 java.lang.String getConnectionUrl()
           
 java.lang.String getDomain()
           
 java.lang.String getName()
           
 java.lang.String getObjectName()
          Return this MBean's name
 int getServerState()
          Return the int giving the server state
 java.lang.String getState()
          MBean method returning the state as a String Return the String form of the server state
 java.util.ArrayList getUrls()
           
 boolean isRegistered(javax.management.ObjectName on)
          Check if an ObjectName is registered on the remote server
 java.util.Set queryNames(javax.management.ObjectName on)
           
 void setObjectName(java.lang.String on)
          Set its OBJECT_NAME and register the MBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.objectweb.util.monolog.api.Logger logger
logger for traces.


name

protected java.lang.String name
Unique name of the remote object


objectName

protected java.lang.String objectName
The OBJECT_NAME of this Proxy MBean Must be initialized before checking connection.


connection

protected javax.management.MBeanServerConnection connection
JMX connection


connector

protected javax.management.remote.JMXConnector connector
JMX Connector


env

protected java.util.Map env
Environment used to get the connection


jmx

protected JmxServiceImpl jmx
Local JMX server.


serverOn

protected javax.management.ObjectName serverOn
The server's ObjectName (this corresponds to the J2EEServer MBean registered in the represented server's MBean server)


state

protected int state
State of the remote object (as seen from the proxy)


INITIAL

public static final int INITIAL
This is the initial state

See Also:
Constant Field Values

UNREACHABLE

public static final int UNREACHABLE
This state is corresponding to the situation when the JMX connection is broken - maybe temporary.

See Also:
Constant Field Values

RUNNING

public static final int RUNNING
Server is RUNNING and its reacheable

See Also:
Constant Field Values

STOPPED

public static final int STOPPED
Server is stopped

See Also:
Constant Field Values

FAILED

public static final int FAILED
Server which can't be reached after a several number of retries

See Also:
Constant Field Values

UNKNOWN

public static final int UNKNOWN
Server which started without the discovery and can't be reached after a several number of retries

See Also:
Constant Field Values

STARTING

public static final int STARTING
Server is starting (temporary state)

See Also:
Constant Field Values

STOPPING

public static final int STOPPING
Server is stopping (temporary state)

See Also:
Constant Field Values
Constructor Detail

JMXProxy

public JMXProxy(DomainMonitor dm,
                java.lang.String name,
                java.util.Collection urls)
Constructor: saves information and connects if urls is not null or the proxy is created for the local server.

Parameters:
dm - reference to the domain monitor
name - the proxy name
urls - the urls that can be used to establish connection
Method Detail

getServerState

public int getServerState()
Return the int giving the server state

Returns:
the state value as an int

getState

public java.lang.String getState()
MBean method returning the state as a String Return the String form of the server state

Returns:
the state value

disconnect

public void disconnect()
Disconnect the proxy if connected.


connect

public boolean connect(java.util.Collection urls)
Try to connect this Proxy to its Server

Parameters:
urls - the urls that can be used to establish connection
Returns:
True if connected

checkConnection

protected boolean checkConnection()
Check the established connection to the remote object, or try to establish a connection if the connection object is null.

Returns:
true if connection is ok.

getName

public java.lang.String getName()
Returns:
The name of the remote object

getObjectName

public java.lang.String getObjectName()
Return this MBean's name

Returns:
The name of the MBean (see OBJECT_NAME in the JSR77)

setObjectName

public void setObjectName(java.lang.String on)
Set its OBJECT_NAME and register the MBean

Parameters:
on - OBJECT_NAME

getConnection

public javax.management.MBeanServerConnection getConnection()
Returns:
the connection to the remote MBean server

isRegistered

public boolean isRegistered(javax.management.ObjectName on)
Check if an ObjectName is registered on the remote server

Parameters:
on - the ObjectName to be checked
Returns:
true if registered

getAttribute

public java.lang.Object getAttribute(javax.management.ObjectName on,
                                     java.lang.String attribute)
Get an MBean Attribute on the remote server

Parameters:
on - the MBean's ObjectName
attribute - the attribute name
Returns:
the attribute value

getAttributes

public javax.management.AttributeList getAttributes(javax.management.ObjectName on,
                                                    java.lang.String[] attributes)
Get a group of MBean Attributes on the remote server

Parameters:
on - the MBean's ObjectName
attributes - the attributes names
Returns:
a list of Attribute objects containing for each attribute its name and value

queryNames

public java.util.Set queryNames(javax.management.ObjectName on)
Parameters:
on - the MBean's ObjectName
Returns:
A set containing the ObjectNames for the MBeans selected.

getDomain

public java.lang.String getDomain()
Returns:
the current domain name

getConnectionUrl

public java.lang.String getConnectionUrl()
Returns:
the URL of the current connection

getUrls

public java.util.ArrayList getUrls()
Returns:
the list of urls that can be used for connection