cz.cuni.amis.pogamut.base.agent.jmx
Class AgentJMXComponents<T extends IAgent>

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.jmx.AgentJMXComponents<T>

public class AgentJMXComponents<T extends IAgent>
extends java.lang.Object

Wraps a few methods into one place so it won't plague the public method space of the agent. (Make things a bit clear...).

Contains list of IJMXEnabled components that should be enabled when the whole JMX feature of the agent is fired up.

Note that jmx domain is taken from the java property "pogamut.jmx.domain".


Field Summary
static java.lang.String JMX_SERVER_AGENT_NAME_DELIM
          Separates JMX server address and the agent's MBean object name in address exported to the outside.
static java.lang.String LOG_CATEGORY_NAME
           
 
Constructor Summary
AgentJMXComponents(T agent)
           
 
Method Summary
 void addComponent(IJMXEnabled component)
          Adding new IJMXEnabled component to the list - registering it so it will be notified when the enableJMX() is called.
protected  AgentMBeanAdapter createAgentMBean(javax.management.ObjectName objectName, javax.management.MBeanServer mbs)
          Factory method for creating agent MBean.
 java.lang.String enableJMX()
          This enables the JMX feature on the whole agent notifying all IJMXEnabled components to register itself to provided mBeanServer.
 javax.management.ObjectName getAgentJMXName()
          Returns ObjectName of the agent.
 java.lang.String getJMXDomain()
          JMX domain of the whole agent - used to construct ObjectName instances.
 javax.management.MBeanServer getMBeanServer()
          MBeanServer, if null the jmx is not enabled.
 boolean isJMXEnabled()
          Whether the JMX is enabled or not.
 void registerJMX()
          Re-register all agent's MBeans / Listener into the MBeanServer again.
 void unregisterJMX()
          Unregister all agent's MBeans / Listeners from MBeanServer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_CATEGORY_NAME

public static final java.lang.String LOG_CATEGORY_NAME
See Also:
Constant Field Values

JMX_SERVER_AGENT_NAME_DELIM

public static final java.lang.String JMX_SERVER_AGENT_NAME_DELIM
Separates JMX server address and the agent's MBean object name in address exported to the outside.

See Also:
Constant Field Values
Constructor Detail

AgentJMXComponents

@Inject
public AgentJMXComponents(T agent)
Method Detail

addComponent

public void addComponent(IJMXEnabled component)
Adding new IJMXEnabled component to the list - registering it so it will be notified when the enableJMX() is called.

Parameters:
component -

getMBeanServer

public javax.management.MBeanServer getMBeanServer()
MBeanServer, if null the jmx is not enabled.

Returns:

getJMXDomain

public java.lang.String getJMXDomain()
JMX domain of the whole agent - used to construct ObjectName instances. If null the jmx is not enabled.

Returns:

isJMXEnabled

public boolean isJMXEnabled()
Whether the JMX is enabled or not.

Returns:

getAgentJMXName

public javax.management.ObjectName getAgentJMXName()
Returns ObjectName of the agent.

Returns:

enableJMX

public java.lang.String enableJMX()
                           throws JMXAlreadyEnabledException,
                                  CantStartJMXException
This enables the JMX feature on the whole agent notifying all IJMXEnabled components to register itself to provided mBeanServer.

Note that jmxDomain must be well-formed in JMX Object Name sense.

Parameters:
mBeanServer -
jmxDomain -
Returns:
full jmx address of the agent
Throws:
JMXAlreadyEnabledException
CantStartJMXException

createAgentMBean

protected AgentMBeanAdapter createAgentMBean(javax.management.ObjectName objectName,
                                             javax.management.MBeanServer mbs)
                                      throws javax.management.MalformedObjectNameException,
                                             javax.management.InstanceAlreadyExistsException,
                                             javax.management.InstanceAlreadyExistsException,
                                             javax.management.MBeanRegistrationException,
                                             javax.management.NotCompliantMBeanException
Factory method for creating agent MBean.

Parameters:
objectName -
mbs -
Returns:
Throws:
javax.management.MalformedObjectNameException
javax.management.InstanceAlreadyExistsException
javax.management.MBeanRegistrationException
javax.management.NotCompliantMBeanException

unregisterJMX

public void unregisterJMX()
Unregister all agent's MBeans / Listeners from MBeanServer.


registerJMX

public void registerJMX()
Re-register all agent's MBeans / Listener into the MBeanServer again.