Running the samples

The samples subdirectory contains samples that illustrate some of the functionality that is provided in this release.

JMX notification listener

The NotificationSample program obtains an RMI connection to the JMX MBeanServer, and listens for JMX notifications generated by the ServicesManager MBean, which are sent whenever a service MBean changes state, or an operation is performed on it. For example, if EAServer is shut down (or crashes), this generates events that are picked up by NotificationSample.

To run the NotificationSample program:

EAServer log monitor

The EASLogMonitorSample sample obtains an RMI connection to the JMX MBeanServer, and monitors the contents of the EAServer error log, checking for a string that, if seen, triggers a service restart, using the service interface exposed over JMX. To run the program:

Service builder

SimpleMBean extends com.sybase.management.jmx.services.ServiceSupport, a Sybase-provided abstract class, which you can use to build services. To use SimpleMBean, you must first register it with the JMX MBeanServer. You can either:

To implement the first approach:

  1. Create a JAR file called simple.jar that contains the Simple.class and SimpleMBean.class files, which are created when you compile the sources. Put simple.jar in the lib subdirectory.

  2. Create an XML file called test.xml, similar to the following:

    <?xml version="1.0" encoding="UTF-8"?>
    
    <mbeans>
    
      <mbean name="test:Name=Test"
        code="samples.Simple"
        archive="file:XXX-ROOT-XXX/lib/simple.jar">
      </mbean>
    
      <service name="Test"
        type="test"
        mbean="test:Name=Test"
        startmode="manual">
      </service>
    
    </mbeans>
    

    Replace XXX-ROOT-XXX with the location of the Systems Management installation.

  3. Edit the ROOT/agent.props file, and set the value of the products property to:

    com.sybase.management.jmx.boot.products=
    (name=EAS,url=file:XXX-ROOT-XXX/eas.xml),
    (name=NetSNMP,url=file:XXX-ROOT-XXX/netsnmp.xml),
    (name=Test,url=file:XXX-ROOT-XXX/test.xml)
    

    Replace XXX-ROOT-XXX with the location of the system management installation. The products property now refers to the test.xml file that you just created.

  4. Stop and restart the JMX MBeanServer.

The new Test service should be visible through the Systems Management Console, and you should be able to use the console to start and stop the service, and verify that its state changes appropriately.