Running the JMX agent  Running the samples

Chapter 13: Using Systems Management

Creating services

A service is an object that can run either within or outside of the JMX agent’s VM. Systems Management Console users and clients to the JMX agent can control service objects. A service is implemented using a service MBean that is registered with the ServicesManager MBean—see “Service MBeans”. To create a service:

  1. Create a service MBean, which interacts with external services.

  2. Create and register a service to represent the MBean.

Creating service MBeans

Service MBeans must expose a well-defined lifecycle API that provides the ability to start, stop, and check the status of managed services. To create a service MBean:

  1. In the Systems Management Console, highlight MBeans, right-click, and select Add MBean.

  2. Follow the instructions in the Add MBean wizard.

    The wizard registers the MBean on the server, and configures the MBean to load on start-up.

Because MBeans are invoked via the JMX MBeanServer APIs, service MBeans are not required to implement a particular interface or extend a particular class to ensure life-cycle compliancy. However, they are required to implement the methods described in Table 13-5.

Table 13-5: MBean required methods



void start()

Starts the MBean.

void stop()

Stops the MBean.

int getState()

Returns the state of the MBean. The return values, as defined in JSR 77, can be:

  • 0 – STARTING

  • 1 – RUNNING

  • 2 – STOPPING

  • 4 – FAILED

The class is available to extend, if required. This class provides all the API methods described in Table 13-5 and Table 13-6. If you extend this class, you can override the methods defined in Table 13-6, and let the ServiceSupport class handle state management for you. See “Service builder” for an example of how to do this. The ServiceSupport class provides default implementations for all the methods listed in Table 13-6, so you can implement only the ones you need. The ServiceSupport class is in ROOT/lib/sybasejmx.jar.

Table 13-6: MBean optional methods



void getLogfile()

Gets the service’s log file

void initService()

Initializes the resources

void refreshService()

Refreshes the MBean without restarting

void restartService()

Stops, then restarts the MBean

void startRecursiveService()

Starts dependent MBeans

void startService()

Starts the service

void stopService()

Stops the service

void terminateService()

Cleans up the resources

Creating services

To create and register a service that represents a service MBean:

  1. In the Systems Management Console, highlight the Services node in the tree view. Right-click, and select Add Service.

  2. Follow the instructions in the Add Service wizard.

    The wizard creates the host configuration, connects to the host if set to auto-connect, and writes the configuration to the Systems Management Console’s database (if the user is not anonymous).

Copyright © 2005. Sybase Inc. All rights reserved. Running the samples