org.apache.felix.mosgi.jmx.agent.mx4j.server
Class MX4JMBeanServer

java.lang.Object
  extended by org.apache.felix.mosgi.jmx.agent.mx4j.server.MX4JMBeanServer
All Implemented Interfaces:
Serializable, MBeanServer, MBeanServerConnection

public class MX4JMBeanServer
extends Object
implements MBeanServer, Serializable

The MX4J MBeanServer implementation.
The MBeanServer accomplishes these roles:


The repository function is delegated to instances of MBeanRepository classes. This class acts as a factory for MBeanRepository instances, that can be controlled via the system property mx4j.MX4JSystemKeys#MX4J_MBEANSERVER_REPOSITORY to the qualified name of the implementation class.
This class also acts as an invoker on MBeans. The architecture is interceptor-based, that is whenever you call from a client an MBeanServer method that will end up to call the MBean instance, the call is dispatched to the interceptor chain and eventually to the MBean.
The interceptors are configurable via the MBean MBeanServerInterceptorConfigurator. When the call is about to arrive to the MBean instance, the last interceptor dispatches the call depending on the MBean type: if the MBean is a dynamic MBean, the call is dispatched directly; if the MBean is a standard MBean an MBeanInvoker is delegated to invoke on the MBean instance.

Version:
$Revision: 1.3 $
Author:
Simone Bordet
See Also:
Serialized Form

Constructor Summary
MX4JMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate)
          Create a new MBeanServer implementation with the specified default domain.
 
Method Summary
 void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback)
           
 void addNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback)
           
 ObjectInstance createMBean(String className, ObjectName objectName)
           
 ObjectInstance createMBean(String className, ObjectName objectName, Object[] args, String[] parameters)
           
 ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName)
           
 ObjectInstance createMBean(String className, ObjectName objectName, ObjectName loaderName, Object[] args, String[] parameters)
           
 ObjectInputStream deserialize(ObjectName objectName, byte[] bytes)
           
 ObjectInputStream deserialize(String className, byte[] bytes)
           
 ObjectInputStream deserialize(String className, ObjectName loaderName, byte[] bytes)
           
 Object getAttribute(ObjectName objectName, String attribute)
           
 AttributeList getAttributes(ObjectName objectName, String[] attributes)
           
 ClassLoader getClassLoader(ObjectName name)
           
 ClassLoader getClassLoaderFor(ObjectName name)
           
 ClassLoaderRepository getClassLoaderRepository()
          Returns the ClassLoaderRepository for this MBeanServer.
 String getDefaultDomain()
           
 String[] getDomains()
           
 Integer getMBeanCount()
           
 MBeanInfo getMBeanInfo(ObjectName objectName)
           
 ObjectInstance getObjectInstance(ObjectName objectName)
           
 Object instantiate(String className)
           
 Object instantiate(String className, Object[] args, String[] parameters)
           
 Object instantiate(String className, ObjectName loaderName)
           
 Object instantiate(String className, ObjectName loaderName, Object[] args, String[] parameters)
           
 Object invoke(ObjectName objectName, String methodName, Object[] args, String[] parameters)
           
 boolean isInstanceOf(ObjectName objectName, String className)
           
 boolean isRegistered(ObjectName objectName)
           
 Set queryMBeans(ObjectName patternName, QueryExp filter)
           
 Set queryNames(ObjectName patternName, QueryExp filter)
           
 ObjectInstance registerMBean(Object mbean, ObjectName objectName)
           
 void removeNotificationListener(ObjectName observed, NotificationListener listener)
           
 void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, Object handback)
           
 void removeNotificationListener(ObjectName observed, ObjectName listener)
           
 void removeNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, Object handback)
           
 void setAttribute(ObjectName objectName, Attribute attribute)
           
 AttributeList setAttributes(ObjectName objectName, AttributeList attributes)
           
 void unregisterMBean(ObjectName objectName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MX4JMBeanServer

public MX4JMBeanServer(String defaultDomain,
                       MBeanServer outer,
                       MBeanServerDelegate delegate)
Create a new MBeanServer implementation with the specified default domain. If the default domain is null, then the empty string is assumed.

Parameters:
defaultDomain - The default domain to be used
Throws:
SecurityException - if access is not granted to create an MBeanServer instance
Method Detail

getClassLoaderRepository

public ClassLoaderRepository getClassLoaderRepository()
Returns the ClassLoaderRepository for this MBeanServer. When first the ClassLoaderRepository is created in the constructor, the system property mx4j.MX4JSystemKeys#MX4J_MBEANSERVER_CLASSLOADER_REPOSITORY is tested; if it is non-null and defines a subclass of ModifiableClassLoaderRepository, then that class is used instead of the default one.

Specified by:
getClassLoaderRepository in interface MBeanServer

getClassLoader

public ClassLoader getClassLoader(ObjectName name)
                           throws InstanceNotFoundException
Specified by:
getClassLoader in interface MBeanServer
Throws:
InstanceNotFoundException

getClassLoaderFor

public ClassLoader getClassLoaderFor(ObjectName name)
                              throws InstanceNotFoundException
Specified by:
getClassLoaderFor in interface MBeanServer
Throws:
InstanceNotFoundException

deserialize

public ObjectInputStream deserialize(String className,
                                     ObjectName loaderName,
                                     byte[] bytes)
                              throws InstanceNotFoundException,
                                     OperationsException,
                                     ReflectionException
Specified by:
deserialize in interface MBeanServer
Throws:
InstanceNotFoundException
OperationsException
ReflectionException

deserialize

public ObjectInputStream deserialize(String className,
                                     byte[] bytes)
                              throws OperationsException,
                                     ReflectionException
Specified by:
deserialize in interface MBeanServer
Throws:
OperationsException
ReflectionException

deserialize

public ObjectInputStream deserialize(ObjectName objectName,
                                     byte[] bytes)
                              throws InstanceNotFoundException,
                                     OperationsException
Specified by:
deserialize in interface MBeanServer
Throws:
InstanceNotFoundException
OperationsException

addNotificationListener

public void addNotificationListener(ObjectName observed,
                                    ObjectName listener,
                                    NotificationFilter filter,
                                    Object handback)
                             throws InstanceNotFoundException
Specified by:
addNotificationListener in interface MBeanServer
Specified by:
addNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException

addNotificationListener

public void addNotificationListener(ObjectName observed,
                                    NotificationListener listener,
                                    NotificationFilter filter,
                                    Object handback)
                             throws InstanceNotFoundException
Specified by:
addNotificationListener in interface MBeanServer
Specified by:
addNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName observed,
                                       ObjectName listener)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName observed,
                                       NotificationListener listener)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName observed,
                                       ObjectName listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

removeNotificationListener

public void removeNotificationListener(ObjectName observed,
                                       NotificationListener listener,
                                       NotificationFilter filter,
                                       Object handback)
                                throws InstanceNotFoundException,
                                       ListenerNotFoundException
Specified by:
removeNotificationListener in interface MBeanServer
Specified by:
removeNotificationListener in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ListenerNotFoundException

instantiate

public Object instantiate(String className)
                   throws ReflectionException,
                          MBeanException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException

instantiate

public Object instantiate(String className,
                          Object[] args,
                          String[] parameters)
                   throws ReflectionException,
                          MBeanException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException

instantiate

public Object instantiate(String className,
                          ObjectName loaderName)
                   throws ReflectionException,
                          MBeanException,
                          InstanceNotFoundException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException
InstanceNotFoundException

instantiate

public Object instantiate(String className,
                          ObjectName loaderName,
                          Object[] args,
                          String[] parameters)
                   throws ReflectionException,
                          MBeanException,
                          InstanceNotFoundException
Specified by:
instantiate in interface MBeanServer
Throws:
ReflectionException
MBeanException
InstanceNotFoundException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName objectName)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException
Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName objectName,
                                  Object[] args,
                                  String[] parameters)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException
Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName objectName,
                                  ObjectName loaderName)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException,
                                  InstanceNotFoundException
Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException

createMBean

public ObjectInstance createMBean(String className,
                                  ObjectName objectName,
                                  ObjectName loaderName,
                                  Object[] args,
                                  String[] parameters)
                           throws ReflectionException,
                                  InstanceAlreadyExistsException,
                                  MBeanRegistrationException,
                                  MBeanException,
                                  NotCompliantMBeanException,
                                  InstanceNotFoundException
Specified by:
createMBean in interface MBeanServer
Specified by:
createMBean in interface MBeanServerConnection
Throws:
ReflectionException
InstanceAlreadyExistsException
MBeanRegistrationException
MBeanException
NotCompliantMBeanException
InstanceNotFoundException

registerMBean

public ObjectInstance registerMBean(Object mbean,
                                    ObjectName objectName)
                             throws InstanceAlreadyExistsException,
                                    MBeanRegistrationException,
                                    NotCompliantMBeanException
Specified by:
registerMBean in interface MBeanServer
Throws:
InstanceAlreadyExistsException
MBeanRegistrationException
NotCompliantMBeanException

unregisterMBean

public void unregisterMBean(ObjectName objectName)
                     throws InstanceNotFoundException,
                            MBeanRegistrationException
Specified by:
unregisterMBean in interface MBeanServer
Specified by:
unregisterMBean in interface MBeanServerConnection
Throws:
InstanceNotFoundException
MBeanRegistrationException

getAttribute

public Object getAttribute(ObjectName objectName,
                           String attribute)
                    throws InstanceNotFoundException,
                           MBeanException,
                           AttributeNotFoundException,
                           ReflectionException
Specified by:
getAttribute in interface MBeanServer
Specified by:
getAttribute in interface MBeanServerConnection
Throws:
InstanceNotFoundException
MBeanException
AttributeNotFoundException
ReflectionException

setAttribute

public void setAttribute(ObjectName objectName,
                         Attribute attribute)
                  throws InstanceNotFoundException,
                         AttributeNotFoundException,
                         InvalidAttributeValueException,
                         MBeanException,
                         ReflectionException
Specified by:
setAttribute in interface MBeanServer
Specified by:
setAttribute in interface MBeanServerConnection
Throws:
InstanceNotFoundException
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException

getAttributes

public AttributeList getAttributes(ObjectName objectName,
                                   String[] attributes)
                            throws InstanceNotFoundException,
                                   ReflectionException
Specified by:
getAttributes in interface MBeanServer
Specified by:
getAttributes in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ReflectionException

setAttributes

public AttributeList setAttributes(ObjectName objectName,
                                   AttributeList attributes)
                            throws InstanceNotFoundException,
                                   ReflectionException
Specified by:
setAttributes in interface MBeanServer
Specified by:
setAttributes in interface MBeanServerConnection
Throws:
InstanceNotFoundException
ReflectionException

invoke

public Object invoke(ObjectName objectName,
                     String methodName,
                     Object[] args,
                     String[] parameters)
              throws InstanceNotFoundException,
                     MBeanException,
                     ReflectionException
Specified by:
invoke in interface MBeanServer
Specified by:
invoke in interface MBeanServerConnection
Throws:
InstanceNotFoundException
MBeanException
ReflectionException

getDefaultDomain

public String getDefaultDomain()
Specified by:
getDefaultDomain in interface MBeanServer
Specified by:
getDefaultDomain in interface MBeanServerConnection

getDomains

public String[] getDomains()
Specified by:
getDomains in interface MBeanServer
Specified by:
getDomains in interface MBeanServerConnection

getMBeanCount

public Integer getMBeanCount()
Specified by:
getMBeanCount in interface MBeanServer
Specified by:
getMBeanCount in interface MBeanServerConnection

isRegistered

public boolean isRegistered(ObjectName objectName)
Specified by:
isRegistered in interface MBeanServer
Specified by:
isRegistered in interface MBeanServerConnection

getMBeanInfo

public MBeanInfo getMBeanInfo(ObjectName objectName)
                       throws InstanceNotFoundException,
                              IntrospectionException,
                              ReflectionException
Specified by:
getMBeanInfo in interface MBeanServer
Specified by:
getMBeanInfo in interface MBeanServerConnection
Throws:
InstanceNotFoundException
IntrospectionException
ReflectionException

getObjectInstance

public ObjectInstance getObjectInstance(ObjectName objectName)
                                 throws InstanceNotFoundException
Specified by:
getObjectInstance in interface MBeanServer
Specified by:
getObjectInstance in interface MBeanServerConnection
Throws:
InstanceNotFoundException

isInstanceOf

public boolean isInstanceOf(ObjectName objectName,
                            String className)
                     throws InstanceNotFoundException
Specified by:
isInstanceOf in interface MBeanServer
Specified by:
isInstanceOf in interface MBeanServerConnection
Throws:
InstanceNotFoundException

queryMBeans

public Set queryMBeans(ObjectName patternName,
                       QueryExp filter)
Specified by:
queryMBeans in interface MBeanServer
Specified by:
queryMBeans in interface MBeanServerConnection

queryNames

public Set queryNames(ObjectName patternName,
                      QueryExp filter)
Specified by:
queryNames in interface MBeanServer
Specified by:
queryNames in interface MBeanServerConnection


Copyright © 2011 Apache Software Foundation. All Rights Reserved.