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

- Previous: Connecting to the Domain Administration Server
- Next: Starting an Application Server

## Connecting to the DAS

The connection to the DAS is shown in the following code.

##### Example 16–1 Connecting to the DAS

    [...]
    public static AppserverConnectionSource
        connect(
            final String host,
            final int port,
            final String user,
            final String password,
            final TLSParams tlsParams )
            throws IOException
            {
                final String info = "host=" + host + ", port=" + port +
                    ", user=" + user + ", password=" + password +
                    ", tls=" + (tlsParams != null);

                SampleUtil.println( "Connecting...:" + info );

                final AppserverConnectionSource conn    =
                    new AppserverConnectionSource(
                        AppserverConnectionSource.PROTOCOL_RMI,
                        host, port, user, password, tlsParams, null);

                conn.getJMXConnector( false );

                SampleUtil.println( "Connected: " + info );

                return( conn );
            }
    [...]

A connection to the DAS is obtained via an instance of the `com.sun.appserv.management.client.AppserverConnectionSource` class. For the connection to be established, you must know the name of the host and port number on which the DAS is running, and have the correct user name, password and TLS parameters.

Once the connection to the DAS is established, `DomainRoot` is obtained as follows:

    DomainRoot domainRoot = appserverConnectionSource.getDomainRoot();

This `DomainRoot` instance is a client-side dynamic proxy to the MBean `amx:j2eeType=X-DomainRoot,name=amx`.

See the API documentation for `com.sun.appserv.management.client.AppserverConnectionSource` for further details about connecting to the DAS using the `AppserverConnectionSource` class`.`

However, if you prefer to work with standard JMX, instead of getting `DomainRoot`, you can get the `MBeanServerConnection` or `JMXConnector`, as shown:

    MBeanServerConnection conn =
    appserverConnectionSource.getMBeanServerConnection( false );
    JMXConnector jmxConn =
    appserverConnectionSource.getJMXConnector( false );

- Previous: Connecting to the Domain Administration Server
- Next: Starting an Application Server

- © 2010, Oracle Corporation and/or its affiliates