Entering content frame

Background documentation Writing MBeans Locate the document in its SAP Library structure

...

Standard MBean

The easiest way to instrument a resource is to provide standard MBeans. All attributes and operations that you want to be manageable using the MBeanServer have to be put together in the MBean interface:

Example

// the MBean interface

interface MyResourceMBean {

  public String anOperation(String);

}

// the managed object

class MyResource implements MyResourceMBean {

  // visible for management clients

  public String anOperation(String);

  // not visible for management clients

  public String anotherOperation(String);

}

 

The standard MBean management interface is discovered according to an inheritance pattern upon registration. For more information, see the JMX™ 1.2 Specification on http://java.sun.com.

Wrapper Class

Set the wrapper class StandardMBean. There are some limitations in the naming of the MBean interface, which sometimes make it impossible to write a standard MBean. For that reason the JMX™ 1.2 Specification introduces a wrapper class StandardMBean, which itself is a dynamic MBean that takes the managed object and the MBean interface as parameters. By using the StandardMBean no restrictions on class/interface names exist any more.

Example

// the MBean interface

interface Foo {

  public String anOperation(String);

}

// the managed object

class MyResource implements Foo {

  // visible for management clients

  public String anOperation(String);

  // not visible for management clients

  public String anotherOperation(String);

}

import javax.management.StandardMBean;

...

// instantiate the MBean

StandardMBean mBean = new StandardMBean(new MyResource, Foo.class);

 

Sometimes, it is necessary to subclass the managed object from StandardMBean instead of passing it as a parameter to the constructor. This is the case if the managed object wants to implement the NotificationBroadcaster or MBeanRegistration interfaces, or must be instantiated by a remote MBeanServer.

For details see the API documentation of javax.management.StandardMBean and com.sap.pj.jmx.mbeaninfo.StandardMBeanWrapper. The latter allows for provision of additional meta data attached to the MBeanInfo.

Leaving content frame