Test Installation Service In Java
package org.glassfish.extended.management.sample.impl.installation;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.glassfish.openesb.extended.management.api.administration.ExtendedAdministrationService;
import org.glassfish.openesb.extended.management.api.installation.ExtendedInstallationService;
import org.glassfish.openesb.extended.management.api.runtime.ExtendedRuntimeManagementService;
import org.glassfish.openesb.extended.management.client.ExtendedManagementClient;
import org.glassfish.openesb.extended.management.client.ExtendedManagementClientFactory;
import org.glassfish.openesb.extended.management.common.ExtendedManagementRemoteException;
import org.glassfish.openesb.extended.management.common.jbi.ManagementRemoteExceptionProcessor;
import com.sun.esb.management.common.ManagementRemoteException;
import org.glassfish.openesb.management.ServerConnectionFactory;
/**
* @author gopalan
*/
public class TestExtendedInstallationServiceImpl {
/**
*
*/
public TestExtendedInstallationServiceImpl() {
}
/**
* @param args
*/
public static void main(String[] args) {
String hostName = ServerConnectionFactory.LOCALHOST,
userName = ServerConnectionFactory.ADMIN_USERNAME,
password = ServerConnectionFactory.ADMINADMIN_PASSWORD;
int portNumber = ServerConnectionFactory.RMI_ADMIN_PORT;
String targetName = ServerConnectionFactory.SERVER_TARGET;
ExtendedManagementClient client = null;
ExtendedAdministrationService administrationService = null;
ExtendedRuntimeManagementService runtimeManagementService = null;
ExtendedInstallationService installationService = null;
boolean isJBIRuntimeEnabled = false;
String result = null;
boolean isTargetUp = false;
boolean componentInstalled = false;
String engine = "";
String library = "";
String dataPath = "";
String componentZipFilePath = "";
String libraryZipFilePath = "";
engine = "sun-bpel-engine";
library = "sun-saxon-library";
dataPath = ".";
componentZipFilePath = dataPath + "/data/sun-bpel-engine-1.0-M8.jar";
libraryZipFilePath = dataPath + "/data/sun-saxon-library-1.0-M8.jar";
try {
client = ExtendedManagementClientFactory.getInstance(hostName, portNumber, userName, password);
} catch (ExtendedManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
administrationService = client.getService(ExtendedAdministrationService.class);
if (administrationService != null) {
try {
isJBIRuntimeEnabled = administrationService.isJBIRuntimeEnabled();
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
if (true == isJBIRuntimeEnabled) {
System.out.println("The JBI Framework is Enabled");
runtimeManagementService = client.getService(ExtendedRuntimeManagementService.class);
if (runtimeManagementService != null) {
try {
isTargetUp = runtimeManagementService.isTargetUp(targetName);
} catch (ExtendedManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("The target is " + targetName + (isTargetUp ? " Up." : " Down."));
try {
componentInstalled = administrationService.isJBIComponentInstalled(engine, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
if (componentInstalled) {
try {
result = runtimeManagementService.stopComponent(engine, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
result = ManagementRemoteExceptionProcessor.processTaskResult(result);
System.out.println("Stop " + engine + ". Result: " + result);
try {
result = runtimeManagementService.shutdownComponent(engine, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
result = ManagementRemoteExceptionProcessor.processTaskResult(result);
System.out.println("Shutdown " + engine + ". Result: " + result);
}
installationService = client.getService(ExtendedInstallationService.class);
if (installationService != null) {
try {
result = installationService.uninstallSharedLibrary(library, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
try {
result = installationService.installSharedLibrary(libraryZipFilePath, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
if (componentInstalled) {
try {
result = installationService.uninstallComponent(engine, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
result = ManagementRemoteExceptionProcessor.processTaskResult(result);
System.out.println("Uninstall " + engine + ". Result: " + result);
}
try {
result = installationService.installComponent(componentZipFilePath, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
result = ManagementRemoteExceptionProcessor.processTaskResult(result);
System.out.println("Install " + engine + ". Result: " + result);
} else {
System.out.println("Could not obtain the Installation Service.");
}
try {
result = runtimeManagementService.startComponent(engine, targetName);
} catch (ManagementRemoteException ex) {
Logger.getLogger(TestExtendedInstallationServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
}
result = ManagementRemoteExceptionProcessor.processTaskResult(result);
System.out.println("Start " + engine + ". Result: " + result);
} else {
System.out.println("Could not obtain the Runtime Service.");
}
} else {
System.out.println("JBI Runtime is NOT Enabled.");
}
} else {
System.out.println("Could not obtain the Administration Service.");
}
}
}
Quick Navigation Links
Number of visits: 1
This page (revision-2) was last changed on
09-Oct-09 04:48 AM, -0700
by Gopalan Suresh Raj.
This page was created on
09-Oct-09 04:48 AM, -0700 by Gopalan Suresh Raj.
More info...
| Version |
Date |
Author |
Size |
Changes ... |
|
4
|
09-Oct-09 06:26 AM, -0700
|
Gopalan Suresh Raj |
9926 |
to previous
|
|
3
|
09-Oct-09 06:25 AM, -0700
|
Gopalan Suresh Raj |
9928 |
to previous
|
to last
|
|
2
|
09-Oct-09 04:48 AM, -0700
|
Gopalan Suresh Raj |
9541 |
to previous
|
to last
|
|
1
|
09-Oct-09 04:48 AM, -0700
|
Gopalan Suresh Raj |
9559 |
to last
|