|
Java EE 5 SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.appserv.management.client.AppserverConnectionSource
public final class AppserverConnectionSource
Supports connectivity to Sun Appserver 8.1 and later (not available prior to 8.1). This is the only official way to get a connection to the appserver.
Helper methods to simplify connecting are available in
Connect
.
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();
TrustStoreTrustManager
,
TrustAnyTrustManager
,
HandshakeCompletedListenerImpl
,
TLSParams
Field Summary | |
---|---|
static String |
DEFAULT_PROTOCOL
Default protocol to the Appserver eg PROTOCOL_RMI. |
static String |
DEFAULT_TRUST_STORE_NAME
Name of the default TrustStore file, located in the client's home directory. |
static String |
DEFAULT_TRUST_STORE_PASSWORD
The default pasword for DEFAULT_TRUST_STORE_NAME . |
static String |
HANDSHAKE_COMPLETED_LISTENER_KEY
[used internally] |
protected JMXConnector |
mJMXConnector
|
static String |
PROTOCOL_HTTP
Internal unsupported protocol. |
static String |
PROTOCOL_RMI
RMI protocol to the Appserver. |
static String |
TRUST_MANAGERS_KEY
[used internally] |
Constructor Summary | |
---|---|
AppserverConnectionSource(String host,
int port,
String user,
String userPassword,
Map<String,String> reserved)
Create a new instance using the default protocol without TLS. |
|
AppserverConnectionSource(String protocol,
String host,
int port,
String user,
String userPassword,
Map<String,String> reserved)
Create a new instance connecting to the specified host/port with the specified protocol without TLS. |
|
AppserverConnectionSource(String protocol,
String host,
int port,
String user,
String userPassword,
TLSParams tlsParams,
Map<String,String> reserved)
Create a new instance which will use TLS for security if specified. |
Method Summary | |
---|---|
DomainRoot |
getDomainRoot()
DomainRoot will be returned. |
MBeanServerConnection |
getExistingMBeanServerConnection()
|
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,
Object handback)
Used internally as callback for NotificationListener . |
static boolean |
isSupportedProtocol(String protocol)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected JMXConnector mJMXConnector
public static final String TRUST_MANAGERS_KEY
public static final String HANDSHAKE_COMPLETED_LISTENER_KEY
public static final String PROTOCOL_RMI
public static final String DEFAULT_PROTOCOL
public static final String PROTOCOL_HTTP
public static final String DEFAULT_TRUST_STORE_NAME
public static final String DEFAULT_TRUST_STORE_PASSWORD
DEFAULT_TRUST_STORE_NAME
.
Constructor Detail |
---|
public AppserverConnectionSource(String host, int port, String user, String userPassword, Map<String,String> reserved)
host
- hostname or IP addressport
- port to which to connectuser
- usernameuserPassword
- password for specified usernamereserved
- reserved for future usepublic AppserverConnectionSource(String protocol, String host, int port, String user, String userPassword, Map<String,String> reserved)
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.
protocol
- protocol to use eg PROTOCOL_RMIhost
- hostname or IP addressport
- port to which to connectuser
- usernameuserPassword
- password for specified usernamereserved
- reserved for future usepublic AppserverConnectionSource(String protocol, String host, int port, String user, String userPassword, TLSParams tlsParams, Map<String,String> reserved)
protocol
- protocol to use eg PROTOCOL_RMIhost
- hostname or IP addressport
- port to which to connectuser
- usernameuserPassword
- password for specified usernametlsParams
- (may be null if TLS is not desired)reserved
- reserved for future useTLSParams
Method Detail |
---|
public static boolean isSupportedProtocol(String protocol)
public void handleNotification(Notification notifIn, Object handback)
NotificationListener
.
DO NOT CALL THIS METHOD.
handleNotification
in interface NotificationListener
public JMXConnector getJMXConnector(boolean forceNew) throws IOException
getJMXConnector
in interface ConnectionSource
forceNew
- if a new connection should be created
IOException
public MBeanServerConnection getExistingMBeanServerConnection()
getExistingMBeanServerConnection
in interface ConnectionSource
public MBeanServerConnection getMBeanServerConnection(boolean forceNew) throws IOException
ConnectionSource
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.
getMBeanServerConnection
in interface ConnectionSource
forceNew
- creates a new connection instead of reusing an existing one
IOException
public DomainRoot getDomainRoot() throws IOException
DomainRoot
will be returned. Upon return, AMX is
ready for use. If the server has just been started, there
may be a slight delay until AMX is ready for use; this method
returns only once AMX is ready for use.
IOException
public String toString()
toString
in class Object
|
Java EE 5 SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2006 Sun Microsystems, Inc. All rights reserved.