Hosted by:
SourceForge

JMX Control
JMX Control
Controlling the Java Service Wrapper using JMX

The Java Service Wrapper provides a pair of JMX MBean interfaces which make it possible to control the Wrapper using a JMX interface. This section will describe how to configure your JMX enabled application so that the MBeans provided with the Java Service Wrapper are available.

JBoss

Registering the Java Service Wrapper's MBean interfaces with JBoss is surprising simple. This assumes that you have already gotten JBoss integrated with the Java Service Wrapper. See the Integration section, in particular the example using JBoss. This explanation assumes that you have installed all of the Wrapper files in the locations described in the JBoss integration example. Particularly the wrapper.jar file is assumed to be located in the ${jboss.home}/lib directory.

JBoss allows you to register as an MBean, any Object which implements an interface whose name is the same as the class, appended by "MBean". The Wrapper provides two such classes in the org.tanukisoftware.wrapper.jmx package. WrapperManager and WrapperManagerTesting. The first provides several functions to restart and stop the JVM as well as providing other information about the Java Service Wrapper. The second class exposes a few methods which can be useful in the testing cycle. They are broken out in case you wish to not include them in a final product release. See the javadocs for more details.

To register both of the above MBeans, create an XML file named java-service-wrapper-service.xml in the ${jboss.home}/server/default/deploy directory. The file should contain the following:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE server>
<server>
    <classpath archives="wrapper.jar" codebase="../../lib"/>
    
    <mbean code="org.tanukisoftware.wrapper.jmx.WrapperManager"
           name="JavaServiceWrapper:service=WrapperManager"/>
    
    <mbean code="org.tanukisoftware.wrapper.jmx.WrapperManagerTesting"
           name="JavaServiceWrapper:service=WrapperManagerTesting"/>
</server>

Notice that the location of the wrapper.jar jar file is relative to the location of the XML file.

Upon saving the file, JBoss should detect it and register your new MBeans almost immediately. No need to restart JBoss. Pretty Cool.

Now, to actually use the new MBeans, simply point your browser to JBoss's JMX interface at: http://localhost:8080/jmx-console/ You should notice a JavaServiceWrapper Agent with two MBeans, WrapperManager and WrapperManagerTesting. Selecting either beans will present you with a set of attributes and actions provided by the MBean.

MX4J

To do. (This section is incomplete and just a jumble of my notes at this point. Feel free to send in any suggestions for this section)

MX4J

Sun JMX Reference Implementation

To do. (This section is incomplete and just a jumble of my notes at this point. Feel free to send in any suggestions for this section)

Sun's reference implementation is just that, a reference implementation. There are not a fixed set of steps that you can follow to register the the Wrapper's MBeans. Each application tends to have created their own custom way of registering such beans.

Although many applications have defined their own syntax, Sun has defined MLET tags, short for Management Applet, as a means for defining MBeans. Their syntax is described in the javadocs for the javax.management.loading.MLet class. The following MLET tags can be used to register the MBeans provided with the Wrapper. Notice that they are not really XML.

<MLET
    CODE = org.tanukisoftware.wrapper.jmx.WrapperManager
    ARCHIVE = "../lib/wrapper.jar"
    NAME = JavaServiceWrapper:service=WrapperManager>
<MLET
    CODE = org.tanukisoftware.wrapper.jmx.WrapperManagerTesting
    ARCHIVE = "../lib/wrapper.jar"
    NAME = JavaServiceWrapper:service=WrapperManagerTesting>

More information is available on Sun's Java Managagement Extensions (JMX) Home Page.

by Leif Mortenson

last modified: