J2EE1.4 SDK

com.sun.appserv.management.client
Class AppserverConnectionSource

java.lang.Object
  extended bycom.sun.appserv.management.client.AppserverConnectionSource
All Implemented Interfaces:
ConnectionSource, java.util.EventListener, NotificationListener

public final class AppserverConnectionSource
extends java.lang.Object
implements NotificationListener, ConnectionSource

Supports connectivity to Sun Appserver 8.1. This is the only official way to get a connection to the appserver.

If the server is running with TLS enabled, then you must use the constructor that includes TLSParams. Here is an example of how to connect using TLS:

final File trustStore	= new File( "~/.keystore" );
        final char[] trustStorePassword	= "changeme".toCharArray();	// or whatever it is
final HandshakeCompletedListener listener = new HandshakeCompletedListenerImpl();
final TrustStoreTrustManager trustMgr = new TrustStoreTrustManager( trustStore, trustStorePassword);
trustMgr.setPrompt( true );

final TLSParams	tlsParams = new TLSParams( new X509TrustManager[] { trustMgr }, listener );
final AppserverConnectionSource src	=
        new AppserverConnectionSource( AppserverConnectionSource.PROTOCOL_RMI,
                "localhost", 8686, "admin", "admin123",
                tlsParams,
                null );
final DomainRoot domainRoot	= src.getDomainRoot();
If security is not an issue, it is recommended to simply disable TLS on the server. However, you can also connect using TLS whereby the server certificate is blindly trusted:
final TLSParams	tlsParams = new TLSParams( TrustAnyTrustManager.getInstanceArray(), null );
final AppserverConnectionSource src	=
        new AppserverConnectionSource( AppserverConnectionSource.PROTOCOL_RMI,
                "localhost", 8686, "admin", "admin123",
                tlsParams,
                null );
final DomainRoot domainRoot	= src.getDomainRoot();

See Also:
TrustStoreTrustManager, TrustAnyTrustManager, HandshakeCompletedListenerImpl, TLSParams

Field Summary
static java.lang.String DEFAULT_PROTOCOL
          Default protocol to the Appserver eg PROTOCOL_RMI.
static java.lang.String HANDSHAKE_COMPLETED_LISTENER_KEY
          [used internally]
protected  javax.management.remote.JMXConnector mJMXConnector
           
static java.lang.String PROTOCOL_HTTP
          Internal unsupported protocol.
static java.lang.String PROTOCOL_RMI
          RMI protocol to the Appserver.
static java.lang.String TRUST_MANAGERS_KEY
          [used internally]
 
Constructor Summary
AppserverConnectionSource(java.lang.String host, int port, java.lang.String user, java.lang.String password, java.util.Map reserved)
          Create a new instance using the default protocol without TLS.
AppserverConnectionSource(java.lang.String protocol, java.lang.String host, int port, java.lang.String user, java.lang.String password, java.util.Map reserved)
          Create a new instance connecting to the specified host/port with the specified protocol without TLS.
AppserverConnectionSource(java.lang.String protocol, java.lang.String host, int port, java.lang.String user, java.lang.String password, TLSParams tlsParams, java.util.Map reserved)
          Create a new instance which will optionally TLS for security.
 
Method Summary
 DomainRoot getDomainRoot()
           
 MBeanServerConnection getExistingMBeanServerConnection()
           
 javax.management.remote.JMXConnector getJMXConnector(boolean forceNew)
          If the connection has already been created, return the existing JMXConnector unless 'forceNew' is true or the connection is currently null.
 MBeanServerConnection getMBeanServerConnection(boolean forceNew)
          Return a valid MBeanServerConnection, making a new connection if necessary, or returning an existing one if still valid.
 void handleNotification(Notification notifIn, java.lang.Object handback)
          Invoked when a JMX notification occurs.
static boolean isSupportedProtocol(java.lang.String protocol)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mJMXConnector

protected javax.management.remote.JMXConnector mJMXConnector

TRUST_MANAGERS_KEY

public static final java.lang.String TRUST_MANAGERS_KEY
[used internally]

See Also:
Constant Field Values

HANDSHAKE_COMPLETED_LISTENER_KEY

public static final java.lang.String HANDSHAKE_COMPLETED_LISTENER_KEY
[used internally]

See Also:
Constant Field Values

PROTOCOL_RMI

public static final java.lang.String PROTOCOL_RMI
RMI protocol to the Appserver. Do not use the literal value of this constant in your code; it is subject to change

See Also:
Constant Field Values

DEFAULT_PROTOCOL

public static final java.lang.String DEFAULT_PROTOCOL
Default protocol to the Appserver eg PROTOCOL_RMI.

See Also:
Constant Field Values

PROTOCOL_HTTP

public static final java.lang.String PROTOCOL_HTTP
Internal unsupported protocol. Not supported for external use. Do not use the literal value of this constant in your code; it is subject to change

See Also:
Constant Field Values
Constructor Detail

AppserverConnectionSource

public AppserverConnectionSource(java.lang.String host,
                                 int port,
                                 java.lang.String user,
                                 java.lang.String password,
                                 java.util.Map reserved)
Create a new instance using the default protocol without TLS.

Parameters:
host - hostname or IP address
port - port to which to connect
user - admin user name
password - admin password for admin user
reserved - reserved for future use

AppserverConnectionSource

public AppserverConnectionSource(java.lang.String protocol,
                                 java.lang.String host,
                                 int port,
                                 java.lang.String user,
                                 java.lang.String password,
                                 java.util.Map reserved)
Create a new instance connecting to the specified host/port with the specified protocol without TLS.

Note:The only supported protocol is PROTOCOL_RMI. Use of any other protocol is not supported and these protocols are subject to change or removal at any time.

Parameters:
protocol - protocol to use eg PROTOCOL_RMI
host - hostname or IP address
port - port to which to connect
user - admin user name
password - admin password for admin user
reserved - reserved for future use

AppserverConnectionSource

public AppserverConnectionSource(java.lang.String protocol,
                                 java.lang.String host,
                                 int port,
                                 java.lang.String user,
                                 java.lang.String password,
                                 TLSParams tlsParams,
                                 java.util.Map reserved)
Create a new instance which will optionally TLS for security. The tlsParams must be non-null.

Parameters:
protocol - protocol to use eg PROTOCOL_RMI
host - hostname or IP address
port - port to which to connect
user - admin user name
password - admin password for admin user
tlsParams - (may be null if TLS is not desired)
reserved - reserved for future use
See Also:
TLSParams
Method Detail

isSupportedProtocol

public static boolean isSupportedProtocol(java.lang.String protocol)

handleNotification

public void handleNotification(Notification notifIn,
                               java.lang.Object handback)
Description copied from interface: NotificationListener
Invoked when a JMX notification occurs. The implementation of this method should return as soon as possible, to avoid blocking its notification broadcaster.

Specified by:
handleNotification in interface NotificationListener
Parameters:
notifIn - The notification.
handback - An opaque object which helps the listener to associate information regarding the MBean emitter. This object is passed to the MBean during the addListener call and resent, without modification, to the listener. The MBean object should not use or modify the object.

getJMXConnector

public javax.management.remote.JMXConnector getJMXConnector(boolean forceNew)
                                                     throws java.io.IOException
If the connection has already been created, return the existing JMXConnector unless 'forceNew' is true or the connection is currently null.

Specified by:
getJMXConnector in interface ConnectionSource
Parameters:
forceNew - if a new connection should be created
Returns:
JMXConnector
Throws:
java.io.IOException

getExistingMBeanServerConnection

public MBeanServerConnection getExistingMBeanServerConnection()
Specified by:
getExistingMBeanServerConnection in interface ConnectionSource
Returns:
existing connection, valid or not, may be null

getMBeanServerConnection

public MBeanServerConnection getMBeanServerConnection(boolean forceNew)
                                               throws java.io.IOException
Description copied from interface: ConnectionSource
Return a valid MBeanServerConnection, making a new connection if necessary, or returning an existing one if still valid. Some implementations may choose to not allow creation of a new connection (when 'forceNew' is specified).

Should not be called frequently, as the check for validity will make a remote call.

An implementation may choose to ignore the 'forceNew' parameter and always return the same connection.

Specified by:
getMBeanServerConnection in interface ConnectionSource
Parameters:
forceNew - creates a new connection instead of reusing an existing one
Returns:
getJMXConnector( forceNew ).getMBeanServerConnection()
Throws:
java.io.IOException

getDomainRoot

public DomainRoot getDomainRoot()
                         throws java.io.IOException
Returns:
a DomainRoot
Throws:
java.io.IOException

toString

public java.lang.String toString()

J2EE1.4 SDK

Submit a bug or feature

Copyright 2003 Sun Microsystems, Inc. All rights reserved.