Java CAPS currently provides seven options for you to connect to the Sun Java System Application Server using APIs.
CAPSManagementClientFactory Client Usage
Option 1: host, port, userName, password
/** Only relevant piece of code is shown */ ManagementClient client = CAPSManagementClientFactory.getInstance("127.0.0.1", 4848, "admin", "adminadmin"); // ... Invoke operations on the returned CAPSManagementClient object ... |
Option 2: host, port, userName, password, connectionType
/** Only relevant piece of code is shown */ ManagementClient client = CAPSManagementClientFactory.getInstance("127.0.0.1", 4848, "admin", "adminadmin", ConnectionType.HTTP); // ... Invoke operations on the returned CAPSManagementClient object ... |
Option 3: url, userName, password, isRemoteConnection
/** Only relevant piece of code is shown */ ManagementClient client = CAPSManagementClientFactory.getInstance( "service:jmx:rmi:///jndi/rmi://localhost:22287/management/rmi-jmx- connector", "admin", "adminadmin", false); // ... Invoke operations on the returned CAPSManagementClient object ... |
Option 4: MBeanServerConnection
/** Only relevant piece of code is shown */ MBeanServerConnection connection = ... // Get the MBeanServerConnection ManagementClient client = CAPSManagementClientFactory.getInstance(connection); // ... Invoke operations on the returned CAPSManagementClient object ... |
Option 5: MBeanServerConnection, isRemoteConnection (true/false)
/** Only relevant piece of code is shown */ MBeanServerConnection connection = ... // Get the MBeanServerConnection ManagementClient client = CAPSManagementClientFactory.getInstance(connection, true); // ... Invoke operations on the returned CAPSManagementClient object ... |
Option 6: host, port, userName, password, connectionType, promtUserForMasterPassword(true/false)
/** Only relevant piece of code is shown */ ManagementClient client = CAPSManagementClientFactory.getInstance("127.0.0.1", 8686, "admin", "adminadmin", ConnectionType.JRMP, false); // ... Invoke operations on the returned CAPSManagementClient object ... |
Option 7: hostName, portNumber, userName, password, connectionType, keyStoreFileLocation, masterPassword, promptForMasterPassword (true/false)
/** Only relevant piece of code is shown */ ManagementClient client = CAPSManagementClientFactory.getInstance ("127.0.0.1", 8686, "admin", "adminadmin", ConnectionType.JRMP, "C:/CAPS6/Glassfish/ domains/domain1/ config/keystore.jks", "changeit", true); // ... Invoke operations on the returned CAPSManagementClient object ... |
public enum ConnectionType { HTTP("s1ashttp"), HTTPS("s1ashttps"), JRMP("jmxrmi"), IIOP("iiop"); // ... Implementation ... /** @return the protocol */ public String getProtocol(); /** @return the protocol description */ public String getDescription(); } |
/** Only relevant piece of code is shown */ public class CAPSManagementClientFactory { // Option 1 - host, port, userName, password public static CAPSManagementClient getInstance(String hostName, int portNumber, String userName, String password) throws ManagementRemoteException { // ... Implementation ... } // Option 2 - host, port, userName, password, connectionType public static CAPSManagementClient getInstance(String hostName, int portNumber, String userName, String password, ConnectionType connectionType) throws ManagementRemoteException { // ... Implementation ... } // Option 3 - url, userName, password, isRemoteConnection public static CAPSManagementClient getInstance(String url, String userName, String password, boolean isRemoteConnection) throws ManagementRemoteException { // ... Implementation ... } // Option 4 - MBeanServerConnection public static CAPSManagementClient getInstance(MBeanServerConnection connection) throws ManagementRemoteException { // ... Implementation ... } // Option 5 - MBeanServerConnection, isRemoteConnection public static CAPSManagementClient getInstance(MBeanServerConnection connection, boolean isRemoteConnection) throws ManagementRemoteException { // ... Implementation ... } // Option 6 - host, port, userName, password, connectionType, promtUserForMasterPassword(true/false) public static CAPSManagementClient getInstance(String hostName, int portNumber, String userName, String password, ConnectionType connectionType, boolean promptForPasswordFlag) throws ManagementRemoteException { // ... Implementation ... } // Option 7 - hostName, portNumber, userName, password, connectionType, keyStoreFileLocation, // masterPassword, promptForMasterPassword (true/false) public static CAPSManagementClient getInstance(String hostName, int portNumber, String userName, String password, ConnectionType connectionType, String trustStoreFilePath, String trustStorePassword, boolean promptForPasswordFlag) throws ManagementRemoteException { // ... Implementation ... } } |
The Java CAPS Management API samples that are pertinent to this topic, such as AdministrationServiceSample.groovy, are included with the delivery as zipped files.