Version 4

    The Standard MBean Helper (ServiceMBeanSupport)

     

    The
    org.jboss.system.ServiceMBean
    management interface

     

    This interface exposes the lifecycle methods, and a couple of other informational

    attributes for state and name. It also holds some constants for the possible state values

    and notifications emitted. You just need to extend this with your management interface.

     

    The
    org.jboss.system.ServiceMBeanSupport
    abstract class

     

    Fortunately JBoss does a lot of work to implement the

    ServiceMBean

    interface. By extending the

    ServiceMBeanSupport

    abstract class, you only need to implement the following lifecycle methods. JBoss handles the state machine to make sure they are invoked in the correct order handling the state attribute and notifications.

    protected void createService() throws Exception;
    protected void startService() throws Exception;
    protected void stopService() throws Exception;
    protected void destroyService() throws Exception;
    

     

    Additionally, you get the following helpers:

    protected org.jboss.logging.Logger log; // A logger 
    protected javax.management.MBeanServer server; // The MBeanServer
    protected javax.management.ObjectName serviceName; // The service's ObjectName
    

     

    Notes

     

    It is not intended that you override other methods with the exception of the following:

    public String getName(); // A text string describing the service
    

     

    See BindMBeanToJNDI for a simple subclass of

    ServiceMBeanSupport

    .