The following task includes everything a you need to create an application using the Java CAPS APIs. If you are connecting using the Sun Java System Application Server (SJSAS) that you installed during the Java CAPS Installation you do not need any additional JAR files in your working directory. However, if you are connecting remotely, you need the following JAR files in your working directory:
When connecting through just the RMI protocol using the JSR-160 MX URL you need these JAR files:
%CAPS_MANAGEMENT_HOME%\api\caps.management.client.jar; %SJSAS_HOME%\jbi\lib\jbi-admin-common.jar; %SJSAS_HOME%\lib\javaee.jar; |
When connecting through the HTTP/HTTPS protocols, you need these JAR files:
%CAPS_MANAGEMENT_HOME%\api\caps.management.client.jar; %SJSAS_HOME%\jbi\lib\jbi-admin-common.jar; %SJSAS_HOME%\lib\javaee.jar; %SJSAS_HOME%\lib\appserv-deployment-client.jar; %SJSAS_HOME%\lib\appserv-ext.jar; %SJSAS_HOME%\lib\appserv-rt.jar; %SJSAS_HOME%\lib\jmxremote_optional.jar |
Use this example to connect to the JMX URL
String hostName = "localhost"; int jrmpPortNumber = 8686; String userName = "admin", password = "adminadmin"; boolean isRemoteConnection = true; String jrmpURLString = "service:jmx:rmi:///jndi/rmi://" + hostName + ":" + jrmpPortNumber + "/jmxrmi"; CAPSManagementClient managementClient = CAPSManagementClientFactory.getInstance(jrmpURLString, userName, password, isRemoteConnection); |
Get the service you need to write your application, for example the AdministrationService.
// get services CAPSAdministrationService administrationService = managementClient.getService(CAPSAdministrationService.class); |
After creating the application, for example JBIRuntime, invoke the application.
// use the service, System.out.println("The JBI Runtime is "+(administrationService.isJBIRuntimeEnabled()? "Enabled." : "NOT Enabled.")); |