org.jboss.mx.server.registry
Class BasicMBeanRegistry

java.lang.Object
  extended byorg.jboss.mx.server.registry.BasicMBeanRegistry
All Implemented Interfaces:
MBeanRegistry (src) , ServerConstants (src)

public class BasicMBeanRegistry
extends java.lang.Object
implements MBeanRegistry (src)

The registry for object name - object reference mapping in the MBean server.

The implementation of this class affects the invocation speed directly, please check any changes for performance.

See Also:
MBeanRegistry (src)

Field Summary
protected  MBeanServerDelegate (src) delegate
          Direct reference to the mandatory MBean server delegate MBean.
protected  java.util.Vector fMbInfosToStore
           
protected static Logger (src) log
          The logger
protected  SynchronizedLong registrationNotificationSequence
          Sequence number for the MBean server registration notifications.
protected  SynchronizedLong unregistrationNotificationSequence
          Sequence number for the MBean server unregistration notifications.
 
Fields inherited from interface org.jboss.mx.server.ServerConstants (src)
CLASS_REMOVED, CLASSLOADER, CLASSLOADER_ADDED, CLASSLOADER_REMOVED, DEFAULT_DOMAIN, DEFAULT_LOADER_NAME, DEFAULT_LOADER_REPOSITORY_CLASS, DEFAULT_MBEAN_REGISTRY_CLASS, DEFAULT_MBEAN_SERVER_BUILDER_CLASS, DEFAULT_REQUIRED_MODELMBEAN_CLASS, DEFAULT_SCOPED_REPOSITORY_CLASS, DEFAULT_SCOPED_REPOSITORY_PARSER_CLASS, IMPLEMENTATION_NAME, IMPLEMENTATION_VENDOR, IMPLEMENTATION_VERSION, JMI_DOMAIN, LOADER_REPOSITORY_CLASS_PROPERTY, MBEAN_REGISTRY, MBEAN_REGISTRY_CLASS_PROPERTY, MBEAN_SERVER_BUILDER_CLASS_PROPERTY, MBEAN_SERVER_CONFIGURATION, MBEAN_SERVER_DELEGATE, OPTIMIZE_REFLECTED_DISPATCHER, REQUIRED_MODELMBEAN_CLASS_PROPERTY, SPECIFICATION_NAME, SPECIFICATION_VENDOR, SPECIFICATION_VERSION, UNIFIED_LOADER_REPOSITORY_CLASS
 
Constructor Summary
BasicMBeanRegistry(MBeanServer (src)  server, java.lang.String defaultDomain, ClassLoaderRepository (src)  clr)
          Constructs a new BasicMBeanRegistry.
 
Method Summary
protected  void add(MBeanEntry (src)  entry)
          Adds an MBean entry
 boolean contains(ObjectName (src)  name)
          Test whether an object name is registered.
 java.util.List findEntries(ObjectName (src)  pattern)
          Return a List of MBeanEntry objects with ObjectNames that match the specified pattern.
 MBeanEntry (src) get(ObjectName (src)  name)
          Retrieve the registration for an object name.
 java.lang.String getDefaultDomain()
          Retrieve the default domain for this registry.
 java.lang.String[] getDomains()
          Retrieve the domains for this registry.
 ObjectInstance (src) getObjectInstance(ObjectName (src)  name)
          Retrieve the object instance for an object name.
 int getSize()
          Retrieve the number of mbeans registered.
 java.lang.Object getValue(ObjectName (src)  name, java.lang.String key)
          Retrieve a value from the registration.
protected  void handlePreDeregister(MBeanRegistration (src)  registrationInterface)
          subclasses can override to provide any custom preDeregister logic and must call preDregister on the MBeanRegistration instance
protected  ObjectName (src) handlePreRegistration(MBeanRegistration (src)  registrationInterface, ObjectName (src)  regName)
          subclasses can override to provide their own pre-registration pre- and post- logic for preRegister and must call preRegister on the MBeanRegistration instance
protected  ObjectName (src) invokePreRegister(MBeanInvoker (src)  invoker, ObjectName (src)  regName, java.lang.String magicToken)
           
protected  java.util.Vector mbInfosToStore()
          ObjectName objects bound to MBean Info objects that are waiting to be stored in the persistence store.
protected  void persistIfRequired(MBeanInfo (src)  info, ObjectName (src)  name)
          Adds the given MBean Info object to the persistence queue if it explicity denotes (via metadata) that it should be stored.
protected  ObjectName (src) qualifyName(ObjectName (src)  name)
          Qualify an object name with the default domain
protected  void registerClassLoader(java.lang.ClassLoader cl)
          Subclasses can override if they wish to control the classloader registration to loader repository.
 ObjectInstance (src) registerMBean(java.lang.Object object, ObjectName (src)  name, java.util.Map valueMap)
          Register an mbean.
 void releaseRegistry()
          Cleans up the registry before the MBean server is released.
protected  void remove(ObjectName (src)  name)
          Removes an MBean entry WARNING: The object name should be fully qualified.
protected  void sendRegistrationNotification(ObjectName (src)  regName)
          send a MBeanServerNotification.REGISTRATION_NOTIFICATION notification to regName
protected  void sendUnRegistrationNotification(ObjectName (src)  name)
          send MBeanServerNotification.UNREGISTRATION_NOTIFICATION notification to name
 void unregisterMBean(ObjectName (src)  name)
          Unregister an mbean.
protected  ObjectName (src) validateAndQualifyName(ObjectName (src)  name, java.lang.String magicToken)
          Validates and qualifies an MBean
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registrationNotificationSequence

protected final SynchronizedLong registrationNotificationSequence
Sequence number for the MBean server registration notifications.


unregistrationNotificationSequence

protected final SynchronizedLong unregistrationNotificationSequence
Sequence number for the MBean server unregistration notifications.


delegate

protected MBeanServerDelegate (src)  delegate
Direct reference to the mandatory MBean server delegate MBean.


fMbInfosToStore

protected java.util.Vector fMbInfosToStore

log

protected static Logger (src)  log
The logger

Constructor Detail

BasicMBeanRegistry

public BasicMBeanRegistry(MBeanServer (src)  server,
                          java.lang.String defaultDomain,
                          ClassLoaderRepository (src)  clr)
Constructs a new BasicMBeanRegistry.

Method Detail

registerMBean

public ObjectInstance (src)  registerMBean(java.lang.Object object,
                                    ObjectName (src)  name,
                                    java.util.Map valueMap)
                             throws InstanceAlreadyExistsException (src) ,
                                    MBeanRegistrationException (src) ,
                                    NotCompliantMBeanException (src) 
Description copied from interface: MBeanRegistry (src)
Register an mbean.

This method is invoked by the MBeanServer for createMBean() and registerMBean().

The object name passed maybe unqualified.

The map is a user definable string to value object map for holding information against a registered object. This map may contain metadata related to the registration, such as registration date/time, classloader references, etc.

Pass JMI_DOMAIN in both the key and values of the values map to get access to the reserved domain. It is removed from the map during registration to save memory.

Pass CLASSLOADER in the values map to set the context classloader

Other values are user definable and can be retrieved using the getValue(ObjectName,String) method.

Specified by:
registerMBean in interface MBeanRegistry (src)
Parameters:
object - the mbean to register.
name - the object name to assign to the mbean.
valueMap - a map of other information to include in the registry
Returns:
an object instance for the registered mbean
Throws:
InstanceAlreadyExistsException (src) - when the object name is already registered.
NotCompliantMBeanException (src) - when the passed object is a valid mbean.
MBeanRegistrationException (src) - when an exception is raised during preRegister for the mbean.

sendRegistrationNotification

protected void sendRegistrationNotification(ObjectName (src)  regName)
send a MBeanServerNotification.REGISTRATION_NOTIFICATION notification to regName

Parameters:
regName -

handlePreRegistration

protected ObjectName (src)  handlePreRegistration(MBeanRegistration (src)  registrationInterface,
                                           ObjectName (src)  regName)
                                    throws java.lang.Exception
subclasses can override to provide their own pre-registration pre- and post- logic for preRegister and must call preRegister on the MBeanRegistration instance

Parameters:
registrationInterface -
regName -
Returns:
object name
Throws:
java.lang.Exception

handlePreDeregister

protected void handlePreDeregister(MBeanRegistration (src)  registrationInterface)
                            throws java.lang.Exception
subclasses can override to provide any custom preDeregister logic and must call preDregister on the MBeanRegistration instance

Parameters:
registrationInterface -
Throws:
java.lang.Exception

registerClassLoader

protected void registerClassLoader(java.lang.ClassLoader cl)
Subclasses can override if they wish to control the classloader registration to loader repository.

Parameters:
cl - classloader

unregisterMBean

public void unregisterMBean(ObjectName (src)  name)
                     throws InstanceNotFoundException (src) ,
                            MBeanRegistrationException (src) 
Description copied from interface: MBeanRegistry (src)
Unregister an mbean.

This method is invoked by the MBeanServer for unregisterMBean().

The object name passed maybe unqualified.

MBeans in JMImplementation cannot be unregistered

Specified by:
unregisterMBean in interface MBeanRegistry (src)
Parameters:
name - the mbean to unregister.
Throws:
InstanceNotFoundException (src) - when the object name is not registered.
MBeanRegistrationException (src) - when an exception is raised during preDeregister for the mbean.

sendUnRegistrationNotification

protected void sendUnRegistrationNotification(ObjectName (src)  name)
send MBeanServerNotification.UNREGISTRATION_NOTIFICATION notification to name

Parameters:
name -

get

public MBeanEntry (src)  get(ObjectName (src)  name)
               throws InstanceNotFoundException (src) 
Description copied from interface: MBeanRegistry (src)
Retrieve the registration for an object name.

This method is invoked by the MBeanServer for methods passing an ObjectName that are not covered in other methods.

The object name passed maybe unqualified.

Specified by:
get in interface MBeanRegistry (src)
Parameters:
name - the object name to retrieve
Returns:
the mbean's registration
Throws:
InstanceNotFoundException (src) - when the object name is not registered.

getDefaultDomain

public java.lang.String getDefaultDomain()
Description copied from interface: MBeanRegistry (src)
Retrieve the default domain for this registry.

Specified by:
getDefaultDomain in interface MBeanRegistry (src)
Returns:
the default domain

getDomains

public java.lang.String[] getDomains()
Description copied from interface: MBeanRegistry (src)
Retrieve the domains for this registry.

Specified by:
getDomains in interface MBeanRegistry (src)
Returns:
the domains

getObjectInstance

public ObjectInstance (src)  getObjectInstance(ObjectName (src)  name)
                                 throws InstanceNotFoundException (src) 
Description copied from interface: MBeanRegistry (src)
Retrieve the object instance for an object name.

Specified by:
getObjectInstance in interface MBeanRegistry (src)
Parameters:
name - the object name of the mbean
Returns:
the object instance
Throws:
InstanceNotFoundException (src) - when the object name is not registered

getValue

public java.lang.Object getValue(ObjectName (src)  name,
                                 java.lang.String key)
                          throws InstanceNotFoundException (src) 
Description copied from interface: MBeanRegistry (src)
Retrieve a value from the registration.

Specified by:
getValue in interface MBeanRegistry (src)
Parameters:
name - the object name of the mbean
key - the key to the value
Returns:
the value or null if there is no such value
Throws:
InstanceNotFoundException (src) - when the object name is not registered

contains

public boolean contains(ObjectName (src)  name)
Description copied from interface: MBeanRegistry (src)
Test whether an object name is registered.

This method is invoked by the MBeanServer for isRegistered().

The object name passed maybe unqualified.

Specified by:
contains in interface MBeanRegistry (src)
Parameters:
name - the object name
Returns:
true when the object name is registered, false otherwise

getSize

public int getSize()
Description copied from interface: MBeanRegistry (src)
Retrieve the number of mbeans registered.

This method is invoked by the MBeanServer for getMBeanCount().

Specified by:
getSize in interface MBeanRegistry (src)
Returns:
the number of mbeans registered.

findEntries

public java.util.List findEntries(ObjectName (src)  pattern)
Description copied from interface: MBeanRegistry (src)
Return a List of MBeanEntry objects with ObjectNames that match the specified pattern.

This method is invoked by the MBeanServer for queryMBeans() and queryNames().

Specified by:
findEntries in interface MBeanRegistry (src)
Parameters:
pattern - the pattern to match
Returns:
a List of entries matching the pattern

releaseRegistry

public void releaseRegistry()
Cleans up the registry before the MBean server is released.

Specified by:
releaseRegistry in interface MBeanRegistry (src)

invokePreRegister

protected ObjectName (src)  invokePreRegister(MBeanInvoker (src)  invoker,
                                       ObjectName (src)  regName,
                                       java.lang.String magicToken)
                                throws MBeanRegistrationException (src) ,
                                       NotCompliantMBeanException (src) 
Throws:
MBeanRegistrationException (src)
NotCompliantMBeanException (src)

add

protected void add(MBeanEntry (src)  entry)
            throws InstanceAlreadyExistsException (src) 
Adds an MBean entry

WARNING: The object name should be fully qualified.

Parameters:
entry - the MBean entry to add
Throws:
InstanceAlreadyExistsException (src) - when the MBean's object name is already registered

remove

protected void remove(ObjectName (src)  name)
               throws InstanceNotFoundException (src) 
Removes an MBean entry WARNING: The object name should be fully qualified.

Parameters:
name - the object name of the entry to remove
Throws:
InstanceNotFoundException (src) - when the object name is not registered

validateAndQualifyName

protected ObjectName (src)  validateAndQualifyName(ObjectName (src)  name,
                                            java.lang.String magicToken)
Validates and qualifies an MBean

Validates the name is not a pattern.

Adds the default domain if no domain is specified.

Checks the name is not in the reserved domain JMImplementation when the magicToken is not JMI_DOMAIN

Parameters:
name - the name to validate
magicToken - used to get access to the reserved domain
Returns:
the original name or the name prepended with the default domain if no domain is specified.
Throws:
RuntimeOperationsException (src) - containing an IllegalArgumentException for a problem with the name

qualifyName

protected ObjectName (src)  qualifyName(ObjectName (src)  name)
Qualify an object name with the default domain

Adds the default domain if no domain is specified.

Parameters:
name - the name to qualify
Returns:
the original name or the name prepended with the default domain if no domain is specified.
Throws:
RuntimeOperationsException (src) - containing an IllegalArgumentException when there is a problem

persistIfRequired

protected void persistIfRequired(MBeanInfo (src)  info,
                                 ObjectName (src)  name)
                          throws MalformedObjectNameException (src) ,
                                 InstanceNotFoundException (src) ,
                                 MBeanException (src) ,
                                 ReflectionException (src) 
Adds the given MBean Info object to the persistence queue if it explicity denotes (via metadata) that it should be stored.

Throws:
MalformedObjectNameException (src)
InstanceNotFoundException (src)
MBeanException (src)
ReflectionException (src)

mbInfosToStore

protected java.util.Vector mbInfosToStore()
ObjectName objects bound to MBean Info objects that are waiting to be stored in the persistence store.