org.objectweb.jonas.mejb
Class ManagementBean

java.lang.Object
  extended by org.objectweb.jonas.mejb.ManagementBean
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, javax.ejb.EnterpriseBean, javax.ejb.SessionBean, ManagementEndpoint

public class ManagementBean
extends java.lang.Object
implements javax.ejb.SessionBean, ManagementEndpoint

This is the Management EJB implementation for JOnAS. A MEJB instance is created and deployed at JOnAS start time. It is registered in the ejb/mgmt naming subcontext. The current implementation allows access to managed resources registered in the current (local) MBean server via the standard management methods defined in the javax.management.j2ee.Management interface. It also allows access to managed resources registered in remote MBean servers which belong to the current management domain, via management methods exposed as a WebService endpoint (defined in the ManagementEndpoint interface).

Author:
Adriana Danes, Vivek Lakshmanan, Matt Wringe
See Also:
Serialized Form

Constructor Summary
ManagementBean()
           
 
Method Summary
 void ejbActivate()
           
 void ejbCreate()
          ejbCreate method Get the MBeanServer reference to allow local access
 void ejbPassivate()
           
 void ejbRemove()
           
 java.lang.Object getAttribute(javax.management.ObjectName name, java.lang.String attribute)
           
 java.lang.Object getAttribute(java.lang.String domainServerName, javax.management.ObjectName name, java.lang.String attribute)
           
 java.lang.String[] getAttribute(java.lang.String domainServerName, java.lang.String objectName, java.lang.String attribute)
          Returns the attribute value for an mbean on a server in the domain.
 javax.management.AttributeList getAttributes(javax.management.ObjectName name, java.lang.String[] attributes)
           
 javax.management.AttributeList getAttributes(java.lang.String domainServerName, javax.management.ObjectName name, java.lang.String[] attributes)
           
 java.lang.String[] getAttributesList(java.lang.String domainServerName, java.lang.String objectName)
          Returns a list of attributes for a specified mbean on a server in the domain.
 java.lang.String getDefaultDomain()
          Returns the name of the current domain.
 java.lang.String getDescription(java.lang.String domainServerName, java.lang.String objectName)
          Returns the description for an mbean on a server in the domain.
 javax.management.j2ee.ListenerRegistration getListenerRegistry()
          Returns the ListenerRegistration implementation object which allows the client to register a event notification listener.
 java.lang.Integer getMBeanCount()
           
 java.lang.Integer getMBeanCount(java.lang.String domainServerName)
          Returns the number of mbeans for a server in the domain.
 javax.management.MBeanInfo getMBeanInfo(javax.management.ObjectName name)
           
 javax.management.MBeanInfo getMBeanInfo(java.lang.String domainServerName, javax.management.ObjectName name)
           
 java.lang.String[] getOperations(java.lang.String domainServerName, java.lang.String objectName)
          Returns the list of operations for an mbean on a server in the domain.
 java.lang.String[] getServers()
          Returns the names of the servers in the domain.
 java.lang.Object invoke(javax.management.ObjectName name, java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)
           
 java.lang.Object invoke(java.lang.String domainServerName, javax.management.ObjectName name, java.lang.String operationName, java.lang.Object[] params, java.lang.String[] signature)
           
 java.lang.String[] invoke(java.lang.String domainServerName, java.lang.String objectName, java.lang.String operationName, java.lang.String[] params)
          Invokes an mbean operation having String params on a server in the domain.
 boolean isRegistered(javax.management.ObjectName name)
           
 boolean isRegistered(java.lang.String domainServerName, javax.management.ObjectName name)
           
 boolean isRegistered(java.lang.String domainServerName, java.lang.String objectName)
          Returns True if the mbean is registered with the server in the domain, false otherwise.
 java.util.Set queryNames(javax.management.ObjectName name, javax.management.QueryExp query)
           
 java.util.Set queryNames(java.lang.String domainServerName, javax.management.ObjectName name, javax.management.QueryExp query)
           
 java.lang.String[] queryNames(java.lang.String domainServerName, java.lang.String objectName, java.lang.String query)
          Returns the search results for mbeans on a server in the domain.
 void setAttribute(javax.management.ObjectName name, javax.management.Attribute attribute)
           
 void setAttribute(java.lang.String domainServerName, javax.management.ObjectName name, javax.management.Attribute attribute)
           
 javax.management.AttributeList setAttributes(javax.management.ObjectName name, javax.management.AttributeList attributes)
           
 javax.management.AttributeList setAttributes(java.lang.String domainServerName, javax.management.ObjectName name, javax.management.AttributeList attributes)
           
 void setSessionContext(javax.ejb.SessionContext sessionContext)
          Sets the associated session context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagementBean

public ManagementBean()
Method Detail

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
ejbCreate method Get the MBeanServer reference to allow local access

Throws:
javax.ejb.CreateException

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext sessionContext)
Sets the associated session context.

Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
sessionContext - - A SessionContext interface for the instance.

getAttribute

public java.lang.Object getAttribute(javax.management.ObjectName name,
                                     java.lang.String attribute)
                              throws javax.management.MBeanException,
                                     javax.management.AttributeNotFoundException,
                                     javax.management.InstanceNotFoundException,
                                     javax.management.ReflectionException,
                                     java.rmi.RemoteException
Throws:
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

getAttributes

public javax.management.AttributeList getAttributes(javax.management.ObjectName name,
                                                    java.lang.String[] attributes)
                                             throws javax.management.InstanceNotFoundException,
                                                    javax.management.ReflectionException,
                                                    java.rmi.RemoteException
Throws:
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

getDefaultDomain

public java.lang.String getDefaultDomain()
                                  throws java.rmi.RemoteException
Description copied from interface: ManagementEndpoint
Returns the name of the current domain.

Specified by:
getDefaultDomain in interface ManagementEndpoint
Returns:
The name of the domain.
Throws:
java.rmi.RemoteException - If an error occurs communicating with the server.

getMBeanCount

public java.lang.Integer getMBeanCount()
                                throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo(javax.management.ObjectName name)
                                        throws javax.management.IntrospectionException,
                                               javax.management.InstanceNotFoundException,
                                               javax.management.ReflectionException,
                                               java.rmi.RemoteException
Throws:
javax.management.IntrospectionException
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

invoke

public java.lang.Object invoke(javax.management.ObjectName name,
                               java.lang.String operationName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException,
                               javax.management.InstanceNotFoundException,
                               javax.management.ReflectionException,
                               java.rmi.RemoteException
Throws:
javax.management.MBeanException
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

isRegistered

public boolean isRegistered(javax.management.ObjectName name)
                     throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

queryNames

public java.util.Set queryNames(javax.management.ObjectName name,
                                javax.management.QueryExp query)
                         throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

setAttribute

public void setAttribute(javax.management.ObjectName name,
                         javax.management.Attribute attribute)
                  throws javax.management.MBeanException,
                         javax.management.AttributeNotFoundException,
                         javax.management.InstanceNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.ReflectionException,
                         java.rmi.RemoteException
Throws:
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.InvalidAttributeValueException
javax.management.ReflectionException
java.rmi.RemoteException

setAttributes

public javax.management.AttributeList setAttributes(javax.management.ObjectName name,
                                                    javax.management.AttributeList attributes)
                                             throws javax.management.InstanceNotFoundException,
                                                    javax.management.ReflectionException,
                                                    java.rmi.RemoteException
Throws:
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

getListenerRegistry

public javax.management.j2ee.ListenerRegistration getListenerRegistry()
                                                               throws java.rmi.RemoteException
Returns the ListenerRegistration implementation object which allows the client to register a event notification listener. This method also creates a MBean

Returns:
An instance of the class implementing the ListenerRegistration interface. null is returned if
Throws:
java.rmi.RemoteException

getAttribute

public java.lang.Object getAttribute(java.lang.String domainServerName,
                                     javax.management.ObjectName name,
                                     java.lang.String attribute)
                              throws javax.management.AttributeNotFoundException,
                                     javax.management.InstanceNotFoundException,
                                     javax.management.MBeanException,
                                     javax.management.ReflectionException,
                                     java.rmi.RemoteException
Throws:
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.MBeanException
javax.management.ReflectionException
java.rmi.RemoteException

getAttributes

public javax.management.AttributeList getAttributes(java.lang.String domainServerName,
                                                    javax.management.ObjectName name,
                                                    java.lang.String[] attributes)
                                             throws javax.management.InstanceNotFoundException,
                                                    javax.management.ReflectionException,
                                                    java.rmi.RemoteException
Throws:
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

getMBeanCount

public java.lang.Integer getMBeanCount(java.lang.String domainServerName)
                                throws java.rmi.RemoteException
Description copied from interface: ManagementEndpoint
Returns the number of mbeans for a server in the domain.

Specified by:
getMBeanCount in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
Returns:
The number of mbeans for the specified server.
Throws:
java.rmi.RemoteException - If an error occurs communicating with the server.

getMBeanInfo

public javax.management.MBeanInfo getMBeanInfo(java.lang.String domainServerName,
                                               javax.management.ObjectName name)
                                        throws javax.management.IntrospectionException,
                                               javax.management.InstanceNotFoundException,
                                               javax.management.ReflectionException,
                                               java.rmi.RemoteException
Throws:
javax.management.IntrospectionException
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

invoke

public java.lang.Object invoke(java.lang.String domainServerName,
                               javax.management.ObjectName name,
                               java.lang.String operationName,
                               java.lang.Object[] params,
                               java.lang.String[] signature)
                        throws javax.management.MBeanException,
                               javax.management.InstanceNotFoundException,
                               javax.management.ReflectionException,
                               java.rmi.RemoteException
Throws:
javax.management.MBeanException
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

isRegistered

public boolean isRegistered(java.lang.String domainServerName,
                            javax.management.ObjectName name)
                     throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

queryNames

public java.util.Set queryNames(java.lang.String domainServerName,
                                javax.management.ObjectName name,
                                javax.management.QueryExp query)
                         throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

setAttribute

public void setAttribute(java.lang.String domainServerName,
                         javax.management.ObjectName name,
                         javax.management.Attribute attribute)
                  throws javax.management.MBeanException,
                         javax.management.AttributeNotFoundException,
                         javax.management.InstanceNotFoundException,
                         javax.management.InvalidAttributeValueException,
                         javax.management.ReflectionException,
                         java.rmi.RemoteException
Throws:
javax.management.MBeanException
javax.management.AttributeNotFoundException
javax.management.InstanceNotFoundException
javax.management.InvalidAttributeValueException
javax.management.ReflectionException
java.rmi.RemoteException

setAttributes

public javax.management.AttributeList setAttributes(java.lang.String domainServerName,
                                                    javax.management.ObjectName name,
                                                    javax.management.AttributeList attributes)
                                             throws javax.management.InstanceNotFoundException,
                                                    javax.management.ReflectionException,
                                                    java.rmi.RemoteException
Throws:
javax.management.InstanceNotFoundException
javax.management.ReflectionException
java.rmi.RemoteException

getServers

public java.lang.String[] getServers()
                              throws ManagementEndpointException,
                                     java.rmi.RemoteException
Returns the names of the servers in the domain.

Specified by:
getServers in interface ManagementEndpoint
Returns:
The names of the servers in the domain.
Throws:
ManagementEndpointException - If any errors occur.
java.rmi.RemoteException - If a connection error occurs.

getAttribute

public java.lang.String[] getAttribute(java.lang.String domainServerName,
                                       java.lang.String objectName,
                                       java.lang.String attribute)
                                throws ManagementEndpointException
Description copied from interface: ManagementEndpoint
Returns the attribute value for an mbean on a server in the domain.

Specified by:
getAttribute in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
objectName - The objectname of the mbean.
attribute - The attribute to be returned.
Returns:
The value of the attribute.
Throws:
ManagementEndpointException - If any error occurs with getAttribute.
See Also:
ManagementEndpoint.getAttribute(String, String, String)

isRegistered

public boolean isRegistered(java.lang.String domainServerName,
                            java.lang.String objectName)
                     throws ManagementEndpointException
Description copied from interface: ManagementEndpoint
Returns True if the mbean is registered with the server in the domain, false otherwise.

Specified by:
isRegistered in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
objectName - The objectname of the mbean.
Returns:
True if the mbean is registered, false if not.
Throws:
ManagementEndpointException - If any error occurs with isRegistered.
See Also:
ManagementEndpoint.isRegistered(String, String)

queryNames

public java.lang.String[] queryNames(java.lang.String domainServerName,
                                     java.lang.String objectName,
                                     java.lang.String query)
                              throws ManagementEndpointException
Description copied from interface: ManagementEndpoint
Returns the search results for mbeans on a server in the domain. The query parameter currently does nothing.

Specified by:
queryNames in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
objectName - The objectname of the mbean.
query - Currently does nothing.
Returns:
The ObjectNames for the queried mbeans.
Throws:
ManagementEndpointException - If any error occurs with queryNames.
See Also:
ManagementEndpoint.queryNames(String, String, String)

getAttributesList

public java.lang.String[] getAttributesList(java.lang.String domainServerName,
                                            java.lang.String objectName)
                                     throws ManagementEndpointException
Description copied from interface: ManagementEndpoint
Returns a list of attributes for a specified mbean on a server in the domain.

Specified by:
getAttributesList in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
objectName - The objectname of the mbean.
Returns:
The list of attributes for the mbean.
Throws:
ManagementEndpointException - If any error occurs with getAttributesList.
See Also:
ManagementEndpoint.getAttributesList(String, String)

getDescription

public java.lang.String getDescription(java.lang.String domainServerName,
                                       java.lang.String objectName)
                                throws ManagementEndpointException
Description copied from interface: ManagementEndpoint
Returns the description for an mbean on a server in the domain.

Specified by:
getDescription in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
objectName - The objectname of the mbean.
Returns:
The description for the mbean.
Throws:
ManagementEndpointException - If any error occurs with getDescription.
See Also:
ManagementEndpoint.getDescription(String, String)

getOperations

public java.lang.String[] getOperations(java.lang.String domainServerName,
                                        java.lang.String objectName)
                                 throws ManagementEndpointException
Description copied from interface: ManagementEndpoint
Returns the list of operations for an mbean on a server in the domain.

Specified by:
getOperations in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
objectName - The objectname of the mbean.
Returns:
The operations for the mbean.
Throws:
ManagementEndpointException - If any error occurs with getOperations.
See Also:
ManagementEndpoint.getOperations(String, String)

invoke

public java.lang.String[] invoke(java.lang.String domainServerName,
                                 java.lang.String objectName,
                                 java.lang.String operationName,
                                 java.lang.String[] params)
                          throws ManagementEndpointException,
                                 java.rmi.RemoteException
Description copied from interface: ManagementEndpoint
Invokes an mbean operation having String params on a server in the domain.

Specified by:
invoke in interface ManagementEndpoint
Parameters:
domainServerName - The name of the server in the domain.
objectName - The objectname of the mbean.
operationName - operation name
params - String parameters
Returns:
The operation result
Throws:
ManagementEndpointException - If any error occurs with getOperations.
java.rmi.RemoteException - If an error occurs with the web service.
See Also:
ManagementEndpoint#invoke(String, String, String[])