Sun Java System Application Server Platform Edition 8.1 2005Q2 Update 2 Developer's Guide

- Previous: Displaying the AMX MBean Hierarchy
- Next: Accessing AMX MBeans

## Setting Monitoring States

The `setMonitoring()` method demonstrates how to set monitoring states.

##### Example 16–7 Setting Monitoring States

    [...]
    private static final Set LEGAL_MON =
        Collections.unmodifiableSet( SampleUtil.newSet( new String[]
    {
        ModuleMonitoringLevelValues.HIGH,
        ModuleMonitoringLevelValues.LOW,
        ModuleMonitoringLevelValues.OFF,
    } ));
    public void setMonitoring(
        final String configName,
        final String state )
    {
        if ( ! LEGAL_MON.contains( state ) )
        {
            throw new IllegalArgumentException( state );
        }
        final ConfigConfig config =
            (ConfigConfig)getDomainConfig().
            getConfigConfigMap().get( configName );
        final ModuleMonitoringLevelsConfig mon =
            config.getMonitoringServiceConfig().
            getModuleMonitoringLevelsConfig();
        mon.setConnectorConnectionPool( state );
        mon.setThreadPool( state );
        mon.setHTTPService( state );
        mon.setJDBCConnectionPool( state );
        mon.setORB( state );
        mon.setTransactionService( state );
        mon.setWebContainer( state );
        mon.setEJBContainer( state );
    }
    [...]

The AMX API defines three levels of monitoring in `com.sun.appserv.management.config.ModuleMonitoringLevelValues`, namely, `HIGH`, `LOW`, and `OFF`.

In this example, the configuration element being monitored is named `configName`. The `com.sun.appserv.management.config.ConfigConfig` interface is used to configure the `config` element for `configName` in the `domain.xml` file.

An instance of `com.sun.appserv.management.config.ModuleMonitoringLevelsConfig` is created to configure the `module-monitoring-levels` element for `configName` in the `domain.xml` file.

The `ModuleMonitoringLevelsConfig` instance created then calls each of its set methods to change their states to `state`.

The above is performed by running the `set-monitoring` command when you run `SimpleMain`, stating the name of the configuration element to be monitored and the monitoring `state` to one of `HIGH`, `LOW` or `OFF`.

- Previous: Displaying the AMX MBean Hierarchy
- Next: Accessing AMX MBeans

- © 2010, Oracle Corporation and/or its affiliates