Home » openjdk-7 » javax » management » [javadoc | source]
javax.management
public interface: MBeanServer [javadoc | source]

All Implemented Interfaces:
    MBeanServerConnection

All Known Implementing Classes:
    MBeanServerForwarder

This is the interface 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.

User code does not usually implement this interface. Instead, an object that implements this interface is obtained with one of the methods in the javax.management.MBeanServerFactory class.

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 a 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.

An object obtained from the createMBeanServer or newMBeanServer methods of the MBeanServerFactory class applies security checks to its methods, as follows.

First, if there is no security manager (System#getSecurityManager() is null), then an implementation of this interface is free not to make any checks.

Assuming that there is a security manager, or that the implementation chooses to make checks anyway, the checks are made as detailed below. In what follows, and unless otherwise specified, {@code className} is the string returned by MBeanInfo#getClassName() for the target MBean.

If a security check fails, the method throws SecurityException .

For methods that can throw InstanceNotFoundException , this exception is thrown for a non-existent MBean, regardless of permissions. This is because a non-existent MBean has no className.

Method from javax.management.MBeanServer Summary:
addNotificationListener,   addNotificationListener,   createMBean,   createMBean,   createMBean,   createMBean,   deserialize,   deserialize,   deserialize,   getAttribute,   getAttributes,   getClassLoader,   getClassLoaderFor,   getClassLoaderRepository,   getDefaultDomain,   getDomains,   getMBeanCount,   getMBeanInfo,   getObjectInstance,   instantiate,   instantiate,   instantiate,   instantiate,   invoke,   isInstanceOf,   isRegistered,   queryMBeans,   queryNames,   registerMBean,   removeNotificationListener,   removeNotificationListener,   removeNotificationListener,   removeNotificationListener,   setAttribute,   setAttributes,   unregisterMBean
Method from javax.management.MBeanServer Detail:
 public  void addNotificationListener(ObjectName name,
    NotificationListener listener,
    NotificationFilter filter,
    Object handback) throws InstanceNotFoundException
    {@inheritDoc} If the source of the notification is a reference to an MBean object, the MBean server will replace it by that MBean's ObjectName. Otherwise the source is unchanged.
 public  void addNotificationListener(ObjectName name,
    ObjectName listener,
    NotificationFilter filter,
    Object handback) throws InstanceNotFoundException
    {@inheritDoc}
 public ObjectInstance createMBean(String className,
    ObjectName name) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
    {@inheritDoc}

    If this method successfully creates an MBean, a notification is sent as described above.

 public ObjectInstance createMBean(String className,
    ObjectName name,
    ObjectName loaderName) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
    {@inheritDoc}

    If this method successfully creates an MBean, a notification is sent as described above.

 public ObjectInstance createMBean(String className,
    ObjectName name,
    Object[] params,
    String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException
    {@inheritDoc}

    If this method successfully creates an MBean, a notification is sent as described above.

 public ObjectInstance createMBean(String className,
    ObjectName name,
    ObjectName loaderName,
    Object[] params,
    String[] signature) throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, InstanceNotFoundException
    {@inheritDoc}

    If this method successfully creates an MBean, a notification is sent as described above.

 public ObjectInputStream deserialize(ObjectName name,
    byte[] data) throws InstanceNotFoundException, OperationsExceptionDeprecated! Use -   getClassLoaderFor  to
obtain the appropriate class loader for deserialization.

    De-serializes a byte array in the context of the class loader of an MBean.

 public ObjectInputStream deserialize(String className,
    byte[] data) throws OperationsException, ReflectionExceptionDeprecated! Use -  #getClassLoaderRepository  to obtain the
class loader repository and use it to deserialize.

    De-serializes a byte array in the context of a given MBean class loader. The class loader is found by loading the class className through the Class Loader Repository . The resultant class's class loader is the one to use.

 public ObjectInputStream deserialize(String className,
    ObjectName loaderName,
    byte[] data) throws InstanceNotFoundException, OperationsException, ReflectionExceptionDeprecated! Use -   getClassLoader  to obtain
the class loader for deserialization.

    De-serializes a byte array in the context of a given MBean class loader. The class loader is the one that loaded the class with name "className". The name of the class loader to be used for loading the specified class is specified. If null, the MBean Server's class loader will be used.

 public Object getAttribute(ObjectName name,
    String attribute) throws MBeanException, AttributeNotFoundException, InstanceNotFoundException, ReflectionException
 public AttributeList getAttributes(ObjectName name,
    String[] attributes) throws InstanceNotFoundException, ReflectionException
 public ClassLoader getClassLoader(ObjectName loaderName) throws InstanceNotFoundException
 public ClassLoader getClassLoaderFor(ObjectName mbeanName) throws InstanceNotFoundException
 public ClassLoaderRepository getClassLoaderRepository()

    Return the ClassLoaderRepository for this MBeanServer.

 public String getDefaultDomain()
 public String[] getDomains()
 public Integer getMBeanCount()
    Returns the number of MBeans registered in the MBean server.
 public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, IntrospectionException, ReflectionException
 public ObjectInstance getObjectInstance(ObjectName name) throws InstanceNotFoundException
 public Object instantiate(String className) throws ReflectionException, MBeanException
 public Object instantiate(String className,
    ObjectName loaderName) throws ReflectionException, MBeanException, InstanceNotFoundException

    Instantiates an object using the class Loader specified by its ObjectName. If the loader name is null, the ClassLoader that loaded the MBean Server will be used. The object's class should have a public constructor. This method returns a reference to the newly created object. The newly created object is not registered in the MBean server.

    This method is equivalent to instantiate(className, loaderName, (Object[]) null, (String[]) null) .

 public Object instantiate(String className,
    Object[] params,
    String[] signature) throws ReflectionException, MBeanException

    Instantiates an object using the list of all class loaders registered in the MBean server Class Loader Repository . The object's class should have a public constructor. The call returns a reference to the newly created object. The newly created object is not registered in the MBean server.

 public Object instantiate(String className,
    ObjectName loaderName,
    Object[] params,
    String[] signature) throws ReflectionException, MBeanException, InstanceNotFoundException

    Instantiates an object. The class loader to be used is identified by its object name. If the object name of the loader is null, the ClassLoader that loaded the MBean server will be used. The object's class should have a public constructor. The call returns a reference to the newly created object. The newly created object is not registered in the MBean server.

 public Object invoke(ObjectName name,
    String operationName,
    Object[] params,
    String[] signature) throws InstanceNotFoundException, MBeanException, ReflectionException
 public boolean isInstanceOf(ObjectName name,
    String className) throws InstanceNotFoundException
 public boolean isRegistered(ObjectName name)
 public Set<ObjectInstance> queryMBeans(ObjectName name,
    QueryExp query)
    {@inheritDoc}
 public Set<ObjectName> queryNames(ObjectName name,
    QueryExp query)
    {@inheritDoc}
 public ObjectInstance registerMBean(Object object,
    ObjectName name) throws InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException

    Registers a pre-existing object as an MBean with the MBean server. If the object name given is null, the MBean must provide its own name by implementing the MBeanRegistration interface and returning the name from the preRegister method.

    If this method successfully registers an MBean, a notification is sent as described above.

 public  void removeNotificationListener(ObjectName name,
    ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException
 public  void removeNotificationListener(ObjectName name,
    NotificationListener listener) throws InstanceNotFoundException, ListenerNotFoundException
 public  void removeNotificationListener(ObjectName name,
    ObjectName listener,
    NotificationFilter filter,
    Object handback) throws InstanceNotFoundException, ListenerNotFoundException
 public  void removeNotificationListener(ObjectName name,
    NotificationListener listener,
    NotificationFilter filter,
    Object handback) throws InstanceNotFoundException, ListenerNotFoundException
 public  void setAttribute(ObjectName name,
    Attribute attribute) throws InstanceNotFoundException, AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException
 public AttributeList setAttributes(ObjectName name,
    AttributeList attributes) throws InstanceNotFoundException, ReflectionException
 public  void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException
    {@inheritDoc}

    If this method successfully unregisters an MBean, a notification is sent as described above.