Top Description Inners Fields Constructors Methods
com.sun.jmx.interceptor

public Class DefaultMBeanServerInterceptor

extends Object
implements MBeanServerInterceptor
Class Inheritance
All Implemented Interfaces
com.sun.jmx.interceptor.MBeanServerInterceptor, javax.management.MBeanServer, javax.management.MBeanServerConnection
Static Imports
com.sun.jmx.defaults.JmxProperties.MBEANSERVER_LOGGER

This is the default class for MBean manipulation on the agent side. It contains the methods necessary for the creation, registration, and deletion of MBeans as well as the access methods for registered MBeans. This is the core component of the JMX infrastructure.

Every MBean which is added to the MBean server becomes manageable: its attributes and operations become remotely accessible through the connectors/adaptors connected to that MBean server. A Java object cannot be registered in the MBean server unless it is a JMX compliant MBean.

When an MBean is registered or unregistered in the MBean server an MBeanServerNotification Notification is emitted. To register an object as listener to MBeanServerNotifications you should call the MBean server method addNotificationListener with ObjectName the ObjectName of the MBeanServerDelegate. This ObjectName is:
JMImplementation:type=MBeanServerDelegate.

Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static interface
DefaultMBeanServerInterceptor.ResourceContext

A RegistrationContext that makes it possible to perform additional post registration actions (or post unregistration actions) outside of the repository lock, once postRegister (or postDeregister) has been called.

Field Summary

Modifier and TypeField and Description
private final Set<ObjectName>
private final transient MBeanServerDelegate
delegate

The MBean server delegate object that is associated to the DefaultMBeanServerInterceptor

private final String
domain

The default domain of the object names

private final transient MBeanInstantiator
instantiator

The MBeanInstantiator object used by the DefaultMBeanServerInterceptor

private final transient WeakHashMap<DefaultMBeanServerInterceptor.ListenerWrapper, WeakReference<DefaultMBeanServerInterceptor.ListenerWrapper>>
listenerWrappers

Wrappers for client listeners.

private final transient Repository
repository

The Repository object used by the DefaultMBeanServerInterceptor

private transient MBeanServer
server

The MBean server object that is associated to the DefaultMBeanServerInterceptor

Constructor Summary

AccessConstructor and Description
public
DefaultMBeanServerInterceptor(MBeanServer
A pointer to the MBeanServer object that must be passed to the MBeans when invoking their javax.management.MBeanRegistration interface.
outer
,
MBeanServerDelegate
A pointer to the MBeanServerDelegate associated with the new MBeanServer. The new MBeanServer must register this MBean in its MBean repository.
delegate
,
MBeanInstantiator
The MBeanInstantiator that will be used to instantiate MBeans and take care of class loading issues.
instantiator
,
Repository
The repository to use for this MBeanServer.
repository
)

Creates a DefaultMBeanServerInterceptor with the specified repository instance.

Method Summary

Modifier and TypeMethod and Description
private void
addClassLoader(ClassLoader
The ClassLoader.
loader
,
final ObjectName
The ClassLoader MBean ObjectName.
logicalName
)

Registers a ClassLoader with the CLR.

public void
addNotificationListener(ObjectName
The name of the MBean on which the listener should be added.
name
,
NotificationListener
The listener object which will handle the notifications emitted by the registered MBean.
listener
,
NotificationFilter
The filter object. If filter is null, no filtering will be performed before handling notifications.
filter
,
Object
The context to be sent to the listener when a notification is emitted.
handback
)

Implements javax.management.MBeanServer.addNotificationListener.

Adds a listener to a registered MBean.

public void
addNotificationListener(ObjectName
The name of the MBean on which the listener should be added.
name
,
ObjectName
The object name of the listener which will handle the notifications emitted by the registered MBean.
listener
,
NotificationFilter
The filter object. If filter is null, no filtering will be performed before handling notifications.
filter
,
Object
The context to be sent to the listener when a notification is emitted.
handback
)

Implements javax.management.MBeanServer.addNotificationListener.

Adds a listener to a registered MBean.

private static void
checkMBeanPermission(DynamicMBean mbean, String member, ObjectName objectName, String actions)

private static void
checkMBeanPermission(String classname, String member, ObjectName objectName, String actions)

private static void
checkMBeanTrustPermission(final Class<?> theClass)

private DefaultMBeanServerInterceptor.ResourceContext

Returns:

a ResourceContext that takes in charge the addition or removal of the loader to or from the CLR.
createClassLoaderContext
(final ClassLoader
The ClassLoader MBean being registered or unregistered.
loader
,
final ObjectName
The name of the ClassLoader MBean.
logicalName
)

Creates a ResourceContext for a ClassLoader MBean.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
)

Implements javax.management.MBeanServer.createMBean.

Instantiates and registers an MBean in the MBean server.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
,
ObjectName
The object name of the class loader to be used.
loaderName
)

Implements javax.management.MBeanServer.createMBean.

Instantiates and registers an MBean in the MBean server.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Implements javax.management.MBeanServer.createMBean.

Instantiates and registers an MBean in the MBean server.

public ObjectInstance
createMBean(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the MBean. May be null.
name
,
ObjectName
The object name of the class loader to be used.
loaderName
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Implements javax.management.MBeanServer.createMBean.

Instantiates and registers an MBean in the MBean server.

private ObjectInstance
createMBean(String className, ObjectName name, ObjectName loaderName, boolean withDefaultLoaderRepository, Object[] params, String[] signature)

private void
private Set<ObjectInstance>
filterListOfObjectInstances(Set<ObjectInstance> list, QueryExp query)

Applies the specified queries to the set of ObjectInstances.

public Object
getAttribute(ObjectName
The object name of the MBean from which the attribute is to be retrieved.
name
,
String
A String specifying the name of the attribute to be retrieved.
attribute
)

Implements javax.management.MBeanServer.getAttribute.

Gets the value of a specific attribute of a named MBean.

public AttributeList
getAttributes(ObjectName
The object name of the MBean from which the attributes are retrieved.
name
,
String[]
A list of the attributes to be retrieved.
attributes
)

Implements javax.management.MBeanServer.getAttributes.

Retrieves the values of several attributes of a named MBean.

public ClassLoader

Returns:

The named ClassLoader.
getClassLoader
(ObjectName
The ObjectName of the ClassLoader.
loaderName
)

Implements javax.management.MBeanServer.getClassLoader.

Return the named java.lang.ClassLoader.

public ClassLoader

Returns:

The ClassLoader used for that MBean.
getClassLoaderFor
(ObjectName
The ObjectName of the MBean.
mbeanName
)

Implements javax.management.MBeanServer.getClassLoaderFor.

Return the java.lang.ClassLoader that was used for loading the class of the named MBean.

public ClassLoaderRepository
private static String
public String
getDefaultDomain()

Implements javax.management.MBeanServer.getDefaultDomain.

Returns the default domain used for naming the MBean.

public String[]
getDomains()

Implements javax.management.MBeanServer.getDomains.

Returns the list of domains in which any MBean is currently registered.

private ModifiableClassLoaderRepository
private NotificationListener
private NotificationListener
private DynamicMBean
getMBean(ObjectName name)

Gets a specific MBean controlled by the DefaultMBeanServerInterceptor.

public Integer
getMBeanCount()

Implements javax.management.MBeanServer.getMBeanCount.

Returns the number of MBeans registered in the MBean server.

public MBeanInfo
getMBeanInfo(ObjectName
The name of the MBean to analyze
name
)

Implements javax.management.MBeanServer.getMBeanInfo.

This method discovers the attributes and operations that an MBean exposes for management.

private static String
getNewMBeanClassName(Object mbeanToRegister)

private static <T extends NotificationBroadcaster> T
getNotificationBroadcaster(ObjectName name, Object instance, Class<T> reqClass)

public ObjectInstance
getObjectInstance(ObjectName
The object name of the MBean.
name
)

Implements javax.management.MBeanServer.getObjectInstance.

Gets the ObjectInstance for a given MBean registered with the MBean server.

private static Object
public Object
instantiate(String
The class name of the object to be instantiated.
className
)

Implements com.sun.jmx.interceptor.MBeanServerInterceptor.instantiate.

This method should never be called.

public Object
instantiate(String
The class name of the MBean to be instantiated.
className
,
ObjectName
The object name of the class loader to be used.
loaderName
)

Implements com.sun.jmx.interceptor.MBeanServerInterceptor.instantiate.

This method should never be called.

public Object
instantiate(String
The class name of the object to be instantiated.
className
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Implements com.sun.jmx.interceptor.MBeanServerInterceptor.instantiate.

This method should never be called.

public Object
instantiate(String
The class name of the object to be instantiated.
className
,
ObjectName
The object name of the class loader to be used.
loaderName
,
Object[]
An array containing the parameters of the constructor to be invoked.
params
,
String[]
An array containing the signature of the constructor to be invoked.
signature
)

Implements com.sun.jmx.interceptor.MBeanServerInterceptor.instantiate.

This method should never be called.

public Object
invoke(ObjectName
The object name of the MBean on which the method is to be invoked.
name
,
String
The name of the operation to be invoked.
operationName
,
Object[]
An array containing the parameters to be set when the operation is invoked
params
,
String[]
An array containing the signature of the operation, an array of class names in the format returned by Class#getName(). The class objects will be loaded using the same class loader as the one used for loading the MBean on which the operation was invoked.
signature
)

Implements javax.management.MBeanServer.invoke.

Invokes an operation on an MBean.

public boolean
isInstanceOf(ObjectName
The ObjectName of the MBean.
name
,
String
The name of the class.
className
)

Implements javax.management.MBeanServer.isInstanceOf.

Returns true if the MBean specified is an instance of the specified class, false otherwise.

public boolean
isRegistered(ObjectName
The object name of the MBean to be checked.
name
)

Implements javax.management.MBeanServer.isRegistered.

Checks whether an MBean, identified by its object name, is already registered with the MBean server.

private DefaultMBeanServerInterceptor.ResourceContext
makeResourceContextFor(Object
The resource being registered or unregistered.
resource
,
ObjectName
The name of the associated MBean.
logicalName
)

Creates a ResourceContext for the given resource.

private ObjectName
private Set<ObjectInstance>
objectInstancesFromFilteredNamedObjects(Set<NamedObject> list, QueryExp query)

Applies the specified queries to the set of NamedObjects.

private Set<ObjectName>
objectNamesFromFilteredNamedObjects(Set<NamedObject> list, QueryExp query)

Applies the specified queries to the set of NamedObjects.

private static void
private static void
postRegister(ObjectName logicalName, DynamicMBean mbean, boolean registrationDone, boolean registerFailed)

private static void
private static ObjectName
public Set<ObjectInstance>
queryMBeans(ObjectName
The object name pattern identifying the MBeans to be retrieved. If null or no domain and key properties are specified, all the MBeans registered will be retrieved.
name
,
QueryExp
The query expression to be applied for selecting MBeans. If null no query expression will be applied for selecting MBeans.
query
)

Implements javax.management.MBeanServer.queryMBeans.

Gets MBeans controlled by the MBean server.

private Set<ObjectInstance>
public Set<ObjectName>
queryNames(ObjectName
The object name pattern identifying the MBean names to be retrieved. If null or no domain and key properties are specified, the name of all registered MBeans will be retrieved.
name
,
QueryExp
The query expression to be applied for selecting MBeans. If null no query expression will be applied for selecting MBeans.
query
)

Implements javax.management.MBeanServer.queryNames.

Gets the names of MBeans controlled by the MBean server.

private Set<ObjectName>
private ObjectInstance
public ObjectInstance
registerMBean(Object
The MBean to be registered as an MBean.
object
,
ObjectName
The object name of the MBean. May be null.
name
)

Implements javax.management.MBeanServer.registerMBean.

Registers a pre-existing object as an MBean with the MBean server.

private ObjectInstance

Returns:

the actual ObjectName with which the object was registered.
registerObject
(String classname, Object
A reference to a MBean compliant object.
object
,
ObjectName
The ObjectName of the object MBean.
name
)

Register object in the repository, with the given name.

private DefaultMBeanServerInterceptor.ResourceContext

Returns:

a ResourceContext for special resources such as ClassLoaders or JMXNamespaces.
registerWithRepository
(final Object resource, final DynamicMBean object, final ObjectName logicalName)

Adds a MBean in the repository, sends MBeanServerNotification.REGISTRATION_NOTIFICATION, returns ResourceContext for special resources such as ClassLoaders or JMXNamespaces.

private void
removeClassLoader(ClassLoader
The ClassLoader.
loader
,
final ObjectName
The ClassLoader MBean ObjectName.
logicalName
)

Unregisters a ClassLoader from the CLR.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
NotificationListener
The listener to be removed.
listener
)

Implements javax.management.MBeanServer.removeNotificationListener.

Removes a listener from a registered MBean.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
NotificationListener
The listener to be removed.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
handback
)

Implements javax.management.MBeanServer.removeNotificationListener.

Removes a listener from a registered MBean.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
ObjectName
The object name of the listener to be removed.
listener
)

Implements javax.management.MBeanServer.removeNotificationListener.

Removes a listener from a registered MBean.

public void
removeNotificationListener(ObjectName
The name of the MBean on which the listener should be removed.
name
,
ObjectName
The object name of the listener to be removed.
listener
,
NotificationFilter
The filter that was specified when the listener was added.
filter
,
Object
The handback that was specified when the listener was added.
handback
)

Implements javax.management.MBeanServer.removeNotificationListener.

Removes a listener from a registered MBean.

private void
removeNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback, boolean removeAll)

private static void
private static void
private static String
private void
sendNotification(String NotifType, ObjectName name)

Sends an MBeanServerNotifications with the specified type for the MBean with the specified ObjectName

public void
setAttribute(ObjectName
The name of the MBean within which the attribute is to be set.
name
,
Attribute
The identification of the attribute to be set and the value it is to be set to.
attribute
)

Implements javax.management.MBeanServer.setAttribute.

Sets the value of a specific attribute of a named MBean.

public AttributeList
setAttributes(ObjectName
The object name of the MBean within which the attributes are to be set.
name
,
AttributeList
A list of attributes: The identification of the attributes to be set and the values they are to be set to.
attributes
)

Implements javax.management.MBeanServer.setAttributes.

Sets the values of several attributes of a named MBean.

private static void
private DefaultMBeanServerInterceptor.ResourceContext

Returns:

a ResourceContext for special resources such as ClassLoaders or JMXNamespaces.
unregisterFromRepository
(final Object resource, final DynamicMBean object, final ObjectName logicalName)

Removes a MBean in the repository, sends MBeanServerNotification.UNREGISTRATION_NOTIFICATION, returns ResourceContext for special resources such as ClassLoaders or JMXNamespaces, or null.

public void
unregisterMBean(ObjectName
The object name of the MBean to be unregistered.
name
)

Implements javax.management.MBeanServer.unregisterMBean.

Unregisters an MBean from the MBean server.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait