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

- Previous: Setting Monitoring States
- Next: Accessing and Displaying the Attributes of an AMX MBean

## Accessing AMX MBeans

The `handleList()` method demonstrates how to access many (but not all) configuration elements.

##### Example 16–8 Accessing AMX MBeans

    [...]
    handleList()
    {
        final DomainConfig dcp = getDomainConfig();
        println( "\n--- Top-level --- \n" );
        displayMap( "ConfigConfig", dcp.getConfigConfigMap() );
        displayMap( "ServerConfig", dcp.getServerConfigMap() );
        displayMap( "StandaloneServerConfig",
            dcp.getStandaloneServerConfigMap() );
        displayMap( "ClusteredServerConfig",
            dcp.getClusteredServerConfigMap() );
        displayMap( "ClusterConfig", dcp.getClusterConfigMap() );
        println( "\n--- DeployedItems --- \n" );
        displayMap( "J2EEApplicationConfig",
            dcp.getJ2EEApplicationConfigMap() );
        displayMap( "EJBModuleConfig",
            dcp.getEJBModuleConfigMap() );
        displayMap( "WebModuleConfig",
            dcp.getWebModuleConfigMap() );
        displayMap( "RARModuleConfig",
            dcp.getRARModuleConfigMap() );
        displayMap( "AppClientModuleConfig",
            dcp.getAppClientModuleConfigMap() );
        displayMap( "LifecycleModuleConfig",
            dcp.getLifecycleModuleConfigMap() );
        println( "\n--- Resources --- \n" );
        displayMap( "CustomResourceConfig",
            dcp.getCustomResourceConfigMap() );
        displayMap( "PersistenceManagerFactoryResourceConfig",
            dcp.getPersistenceManagerFactoryResourceConfigMap() );
        displayMap( "JNDIResourceConfig",
            dcp.getJNDIResourceConfigMap() );
        displayMap( "JMSResourceConfig",
            dcp.getJMSResourceConfigMap() );
        displayMap( "JDBCResourceConfig",
            dcp.getJDBCResourceConfigMap() );
        displayMap( "ConnectorResourceConfig",
            dcp.getConnectorResourceConfigMap() );
        displayMap( "JDBCConnectionPoolConfig",
            dcp.getJDBCConnectionPoolConfigMap() );
        displayMap( "PersistenceManagerFactoryResourceConfig",
            dcp.getPersistenceManagerFactoryResourceConfigMap() );
        displayMap( "ConnectorConnectionPoolConfig",
            dcp.getConnectorConnectionPoolConfigMap() );
        displayMap( "AdminObjectResourceConfig",
            dcp.getAdminObjectResourceConfigMap() );
        displayMap( "ResourceAdapterConfig",
            dcp.getResourceAdapterConfigMap() );
        displayMap( "MailResourceConfig",
            dcp.getMailResourceConfigMap() );
        final ConfigConfig config =
            (ConfigConfig)dcp.getConfigConfigMap().get( "server-config" );
        println( "\n--- HTTPService --- \n" );
        final HTTPServiceConfig httpService = config.getHTTPServiceConfig();
        displayMap( "HTTPListeners",
            httpService.getHTTPListenerConfigMap() );
        displayMap( "VirtualServers",
            httpService.getVirtualServerConfigMap() );
    }
    [...]

The `handleList()` method makes use of the `displayMap()` method, which simply prints out the key value pairs.

The `handleList()` method identifies the configuration for a domain by calling the `DomainRoot.getDomainConfig()` method. This `DomainConfig` instance then calls each of its `getXXXMap()` methods in turn, to obtain a `Map` for each type of AMX MBean. The `Map` returned by each getter is displayed by `displayMap()`.

Similarly, the AMX MBeans representing the `http-service` element are displayed as `Maps` by calling the `getXXXMap()` methods of the `com.sun.appserv.management.config.HTTPServiceConfig` interface, and passing them to `displayMap()`.

- Previous: Setting Monitoring States
- Next: Accessing and Displaying the Attributes of an AMX MBean

- © 2010, Oracle Corporation and/or its affiliates