|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--mx4j.server.MBeanServerImpl
MBeanServer implementation.
The MBeanServer accomplishes these roles:
MBeanRepository
classes.
This class acts as a factory for MBeanRepository instances, that can be controlled via the system property
mx4j.mbeanserver.repository set 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.
Constructor Summary | |
---|---|
MBeanServerImpl(java.lang.String defaultDomain)
Create a new MBeanServerImpl with the specified default domain. |
Method Summary | |
---|---|
void |
addNotificationListener(ObjectName observed,
NotificationListener listener,
NotificationFilter filter,
java.lang.Object handback)
Add a NotificationListener to a registered MBean Register an MBean listener to allow broadcast of management events(notifications). |
void |
addNotificationListener(ObjectName observed,
ObjectName listener,
NotificationFilter filter,
java.lang.Object handback)
Add a NotificationListener to a registered MBean Register an MBean listener to allow broadcast of management events(notifications). |
ObjectInstance |
createMBean(java.lang.String className,
ObjectName objectName)
Registers an MBean and returns an ObjectInstance. |
ObjectInstance |
createMBean(java.lang.String className,
ObjectName objectName,
java.lang.Object[] args,
java.lang.String[] parameters)
Registers an MBean and returns an ObjectInstance |
ObjectInstance |
createMBean(java.lang.String className,
ObjectName objectName,
ObjectName loaderName)
Registers an MBean and returns an ObjectInstance, and use the specified loaderName. |
ObjectInstance |
createMBean(java.lang.String className,
ObjectName objectName,
ObjectName loaderName,
java.lang.Object[] args,
java.lang.String[] parameters)
Registers an MBean and returns an ObjectInstance using the specified loaderName for the ClassLoader |
java.io.ObjectInputStream |
deserialize(ObjectName objectName,
byte[] bytes)
Deserialize the specified bytes using the classloader of the MBean registered with the given ObjectName |
java.io.ObjectInputStream |
deserialize(java.lang.String className,
byte[] bytes)
Deserialize the specified bytes using the classloader that is able to load the specified class. |
java.io.ObjectInputStream |
deserialize(java.lang.String className,
ObjectName loaderName,
byte[] bytes)
Deserialize the given bytes using the classloader that can actually load className using the classloader MBean with the specified ObjectName as initiating classloader. |
java.lang.Object |
getAttribute(ObjectName objectName,
java.lang.String attribute)
Retrieve an attribute using the given objectName |
AttributeList |
getAttributes(ObjectName objectName,
java.lang.String[] attributes)
|
java.lang.ClassLoader |
getClassLoader(ObjectName name)
Returns a ClassLoader using the ObjectName. |
java.lang.ClassLoader |
getClassLoaderFor(ObjectName name)
Returns the ClassLoader used by the MBean for the given ObjectName |
ClassLoaderRepository |
getClassLoaderRepository()
Returns the ClassLoaderRepository for this MBeanServer. |
java.lang.String |
getDefaultDomain()
Retrieve the default domain of this MBean Server |
java.lang.Integer |
getMBeanCount()
Returns the number of MBeans |
MBeanInfo |
getMBeanInfo(ObjectName objectName)
Returns an MBeanInfo using the specified objectName |
ObjectInstance |
getObjectInstance(ObjectName objectName)
Returns an ObjectInstance using the specified objectName |
static ClassLoaderRepository |
getStaticClassLoaderRepository()
Returns the ClassLoaderRepository that maps ClassLoaderRepositories of all MBeanServer in a JVM. |
java.lang.Object |
instantiate(java.lang.String className)
Instantiate the given className using the default ClassLoaderRepository . |
java.lang.Object |
instantiate(java.lang.String className,
java.lang.Object[] args,
java.lang.String[] parameters)
Instantiate the given className using the given args and parameters using the ClassLoaderRepository
|
java.lang.Object |
instantiate(java.lang.String className,
ObjectName loaderName)
Instantiate the given className using the loaderName as the ClassLoader |
java.lang.Object |
instantiate(java.lang.String className,
ObjectName loaderName,
java.lang.Object[] args,
java.lang.String[] parameters)
Instantiate the given className using the ClassLoader (loaderName), args and parameters |
java.lang.Object |
invoke(ObjectName objectName,
java.lang.String methodName,
java.lang.Object[] args,
java.lang.String[] parameters)
Invokes/Execute an operation on an MBean |
boolean |
isInstanceOf(ObjectName objectName,
java.lang.String className)
Checks if the MBean denoted by objectName is of type className |
boolean |
isRegistered(ObjectName objectName)
Checks if the specified ObjectName is registered
with this MBean Server |
java.util.Set |
queryMBeans(ObjectName patternName,
QueryExp filter)
Returns the names of all MBeans controlled by the MBean Server using the given patternName and filter. |
java.util.Set |
queryNames(ObjectName patternName,
QueryExp filter)
Returns the names of all MBeans controlled by the MBean Server using the given patternName and filter. |
ObjectInstance |
registerMBean(java.lang.Object mbean,
ObjectName objectName)
Register an already created MBean using the specified ObjectName |
void |
removeNotificationListener(ObjectName observed,
NotificationListener listener)
Removed a notificationListener. |
void |
removeNotificationListener(ObjectName observed,
NotificationListener listener,
NotificationFilter filter,
java.lang.Object handback)
Not present in the specification but needed |
void |
removeNotificationListener(ObjectName observed,
ObjectName listener)
Remove a notificationListener. |
void |
removeNotificationListener(ObjectName observed,
ObjectName listener,
NotificationFilter filter,
java.lang.Object handback)
Not present in the specification but needed |
void |
setAttribute(ObjectName objectName,
Attribute attribute)
Sets the vallue of the Attribute of the given MBean |
AttributeList |
setAttributes(ObjectName objectName,
AttributeList attributes)
Sets the attribute of an MBean |
void |
unregisterMBean(ObjectName objectName)
Unregister a registered MBean |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public MBeanServerImpl(java.lang.String defaultDomain)
defaultDomain
- The default domain to be usedjava.lang.SecurityException
- If access is not granted to
create an MBeanServer instanceMethod Detail |
public static ClassLoaderRepository getStaticClassLoaderRepository()
ClassLoaderRepository
public ClassLoaderRepository getClassLoaderRepository()
BaseClassLoaderRepository
, then that class is used instead of the default one.public java.lang.ClassLoader getClassLoader(ObjectName name) throws InstanceNotFoundException
name
- The ObjectName to be usedInstanceNotFoundException
- If no instance was found from the
MBeanRepositoryjava.lang.SecurityException
- If the ObjectName doesn't have
permission to getClassLoaderpublic java.lang.ClassLoader getClassLoaderFor(ObjectName name) throws InstanceNotFoundException
name
- The ObjectName for the MBeanInstanceNotFoundException
- If no instance was found from the
MBeanRepositoryjava.lang.SecurityException
- If the ObjectName doesn't have
permission to getClassLoaderForpublic java.io.ObjectInputStream deserialize(java.lang.String className, ObjectName loaderName, byte[] bytes) throws InstanceNotFoundException, OperationsException, ReflectionException
deserialize
in interface MBeanServer
className
- The className to loadloaderName
- The ObjectName of the classloader MBean that initiates the loading of classNamebytes
- The data to de-serializeInstanceNotFoundException
- If the specified ObjectName does not represent a registered MBeanOperationsException
- I/O Related ErrorReflectionException
- If className can't be loadedpublic java.io.ObjectInputStream deserialize(java.lang.String className, byte[] bytes) throws OperationsException, ReflectionException
deserialize
in interface MBeanServer
className
- The className used to find a suitable classloaderbytes
- The data to de-serializeOperationsException
- I/O Related ErrorReflectionException
- If the className cannot be loaded using this MBeanServer's ClassLoaderRepositorypublic java.io.ObjectInputStream deserialize(ObjectName objectName, byte[] bytes) throws InstanceNotFoundException, OperationsException
deserialize
in interface MBeanServer
objectName
- The ObjectName of the MBean whose classloader is used to deserializebytes
- The data to de-serializeOperationsException
- I/O Related ErrorInstanceNotFoundException
- If the specified ObjectName does not represent a registered MBeanpublic void addNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, java.lang.Object handback) throws InstanceNotFoundException
NotificationListener
.
See Page 47 (JMX Notification Model) of the JMX1.1 Agent Specification
for details.addNotificationListener
in interface MBeanServer
observed
- The observed MBean where the listener is addedlistener
- Handles notification sent by the observed MBeanfilter
- Implementation which provides filter to be applied on
notificationshandback
- Object sent when to the listenerInstanceNotFoundException
- If the MBean pointed by "listener"
is not an instance of NotificationListenerNotificationListenerMBeanServerInterceptor
public void addNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, java.lang.Object handback) throws InstanceNotFoundException
NotificationListener
.
See Page 47 (JMX Notification Model) of the JMX1.1 Agent Specification
for details.addNotificationListener
in interface MBeanServer
observed
- The observed MBean where the listener is addedlistener
- Handles notification sent by the observed MBeanfilter
- Implementation which provides filter to be applied on
notificationshandback
- Object sent when to the listenerInstanceNotFoundException
- If the MBean pointed by "listener"
is not an instance of NotificationBroadCasterNotificationListenerMBeanServerInterceptor
public void removeNotificationListener(ObjectName observed, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener
in interface MBeanServer
observed
- The observed MBean where the listener is removedlistener
- The listener to removedInstanceNotFoundException
- If the MBean pointed by "listener"
is not an instance of NotificationListenerListnerNotFoundException
- If no specified listener was foundpublic void removeNotificationListener(ObjectName observed, NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException
removeNotificationListener
in interface MBeanServer
observed
- The observed MBean where the listener is removedlistener
- The listener to removedInstanceNotFoundException
- If the MBean pointed by "listener"
is not an instance of NotificationListenerListnerNotFoundException
- If no specified listener was foundpublic void removeNotificationListener(ObjectName observed, ObjectName listener, NotificationFilter filter, java.lang.Object handback) throws InstanceNotFoundException, ListenerNotFoundException
public void removeNotificationListener(ObjectName observed, NotificationListener listener, NotificationFilter filter, java.lang.Object handback) throws InstanceNotFoundException, ListenerNotFoundException
public java.lang.Object instantiate(java.lang.String className) throws ReflectionException, MBeanException
ClassLoaderRepository
.
The class should have a public constructor. Note that the instance created isn't registered with the MBeanServer
instantiate
in interface MBeanServer
className
- The className to instantiateReflectionException
- MBeanException
- java.lang.IllegalArgumentException
- If the className is null or 0 lengthpublic java.lang.Object instantiate(java.lang.String className, java.lang.Object[] args, java.lang.String[] parameters) throws ReflectionException, MBeanException
ClassLoaderRepository
The class should have a public constructor. Note that the instance created isn't registered with the MBeanServer
instantiate
in interface MBeanServer
className
- The className to instantiateargs
- The argument as an arrayparameters
- The parameters as an arrayReflectionException
- MBeanException
- java.lang.IllegalArgumentException
- If the className is null or 0 lengthpublic java.lang.Object instantiate(java.lang.String className, ObjectName loaderName) throws ReflectionException, MBeanException, InstanceNotFoundException
The class should have a public constructor. Note that the instance created isn't registered with the MBeanServer
instantiate
in interface MBeanServer
className
- The className to instantiateloaderName
- The MBean loaderName to useReflectionException
- MBeanException
- InstanceNotFoundException
- If the className is null or 0 lengthpublic java.lang.Object instantiate(java.lang.String className, ObjectName loaderName, java.lang.Object[] args, java.lang.String[] parameters) throws ReflectionException, MBeanException, InstanceNotFoundException
instantiate
in interface MBeanServer
className
- The className to instantiateloaderName
- The MBean loaderName to useargs
- The argument as an arrayparameters
- The parameters as an arrayReflectionException
- MBeanException
- InstanceNotFoundException
- If the className is null or 0 lengthpublic ObjectInstance createMBean(java.lang.String className, ObjectName objectName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
The MBeanServer will use the default ClassLoaderRepository
createMBean
in interface MBeanServer
className
- The classname of the MBeanobjectName
- The given objectNameReflectionException
- InstanceAlreadyExistsException
- If an instance already exists
in the MBeanServerMBeanRegistrationException
- MBeanException
- NotCompliantMBeanException
- If not an MBeanpublic ObjectInstance createMBean(java.lang.String className, ObjectName objectName, java.lang.Object[] args, java.lang.String[] parameters) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
The MBeanServer will use the default ClassLoaderRepository
createMBean
in interface MBeanServer
className
- The classname of the MBeanobjectName
- The given objectNameargs
- The arguments as arrayparameters
- The parameters as arrayReflectionException
- InstanceAlreadyExistsException
- MBeanRegistrationException
- MBeanException
- NotCompliantMBeanException
- public ObjectInstance createMBean(java.lang.String className, ObjectName objectName, ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
createMBean
in interface MBeanServer
className
- The classname of the MBeanobjectName
- The objectnameloaderName
- The ObjectName of the loaderReflectionException
- InstanceAlreadyExistsException
- MBeanRegistrationException
- NotCompliantMBeanException
- InstanceNotFoundException
- public ObjectInstance createMBean(java.lang.String className, ObjectName objectName, ObjectName loaderName, java.lang.Object[] args, java.lang.String[] parameters) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
The MBeanServer will use the default ClassLoaderRepository
createMBean
in interface MBeanServer
className
- The classname of the MBeanobjectName
- The given objectNameargs
- The arguments as arrayparameters
- The parameters as arrayReflectionException
- InstanceAlreadyExistsException
- MBeanRegistrationException
- MBeanException
- If error on instantiating the MBeanInstanceNotFoundException
- If the loaderName wasn't foundNotCompliantMBeanException
- public ObjectInstance registerMBean(java.lang.Object mbean, ObjectName objectName) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException
ObjectName
registerMBean
in interface MBeanServer
mbean
- The instance of the MBean to registerobjectName
- The ObjectName
to useInstanceAlreadyExistsException
- If the MBean already existsMBeanRegistrationException
- Error in registering the MBeanNotCompliantMBeanException
- If not a compliant MBeanjava.lang.IllegalArgumentException
- if the MBean object is nullpublic void unregisterMBean(ObjectName objectName) throws InstanceNotFoundException, MBeanRegistrationException
unregisterMBean
in interface MBeanServer
objectName
- The objectName where the MBean to unregister is boundInstanceNotFoundException
- If no instance was foundMBeanRegistrationException
- public java.lang.Object getAttribute(ObjectName objectName, java.lang.String attribute) throws InstanceNotFoundException, MBeanException, AttributeNotFoundException, ReflectionException
getAttribute
in interface MBeanServer
objectName
- The objectName of the registered MBeanattribute
- The name of the attribute to retrieveInstanceNotFoundException
- If no instance was foundMBeanException
- AttributeNotFoundException
- If the attribute wasn't foundReflectionException
- public void setAttribute(ObjectName objectName, Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
setAttribute
in interface MBeanServer
objectName
- the objectName to useattribute
- the attribute to setInstanceNotFoundException
- No instance was foundInvalidAttributeValueException
- If the attribute was invalidMBeanException
- The exception thrownReflectionException
- public AttributeList getAttributes(ObjectName objectName, java.lang.String[] attributes) throws InstanceNotFoundException, ReflectionException
getAttributes
in interface MBeanServer
public AttributeList setAttributes(ObjectName objectName, AttributeList attributes) throws InstanceNotFoundException, ReflectionException
setAttributes
in interface MBeanServer
objectName
- the objectNameattributes
- The attributes to setInstanceNotFoundException
- If the MBean wasn't foundReflectionException
- public java.lang.Object invoke(ObjectName objectName, java.lang.String methodName, java.lang.Object[] args, java.lang.String[] parameters) throws InstanceNotFoundException, MBeanException, ReflectionException
invoke
in interface MBeanServer
objectName
- The objectName to usemethodName
- the name of the method to invokeargs
- the argumentsparameters
- the parametersInstanceNotFoundException
- If the MBean wasn't foundMBeanException
- ReflectionException
- public java.lang.String getDefaultDomain()
getDefaultDomain
in interface MBeanServer
public java.lang.Integer getMBeanCount()
getMBeanCount
in interface MBeanServer
public boolean isRegistered(ObjectName objectName)
ObjectName
is registered
with this MBean ServerisRegistered
in interface MBeanServer
objectName
- The objectName to checkpublic MBeanInfo getMBeanInfo(ObjectName objectName) throws InstanceNotFoundException, IntrospectionException, ReflectionException
getMBeanInfo
in interface MBeanServer
objectName
- The objectName to use for the MBeanInfoInstanceNotFoundException
- If no instance was foundIntrospectionException
- ReflectionException
- public ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException
getObjectInstance
in interface MBeanServer
objectName
- The object where the ObjectInstance is registered.InstanceNotFoundException
- If no MBean is registered with the
given objectNamepublic boolean isInstanceOf(ObjectName objectName, java.lang.String className) throws InstanceNotFoundException
isInstanceOf
in interface MBeanServer
objectName
- The objectName to checkclassName
- the className as StringInstanceNotFoundException
- If no MBean was found using ObjectName
public java.util.Set queryMBeans(ObjectName patternName, QueryExp filter)
queryMBeans
in interface MBeanServer
patternName
- The pattern to usefilter
- The filter to useObjectInstance
. Empty if
no ObjectInstance was foundpublic java.util.Set queryNames(ObjectName patternName, QueryExp filter)
queryNames
in interface MBeanServer
patternName
- The pattern to usefilter
- the filter to useObjectNames
. Empty if no
ObjectNames
was found
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |