InstallerImplpublic class InstallerImpl extends Object implements InstallerInstalls Java EE Service Engine on a CAS installation. In openESB world, an
instance could either be a CAS or a non CAS ESB member. Java EE Servijece Engine
is installed on a instance only if the instance is CAS. All components
installed on CAS are installed on a non CAS ESB member by the CAS. |
Fields Summary |
---|
private static final String | ADD_COMPONENT_OPERATIONaddComponent operation of ESB installation MBean adds the component
to ESB's registry and repository. By adding a component, component becomes
installable. | private static final String | INSTALL_COMPONENT_OPERATIONInstall a already added component in ESB environment | private static final String | REMOVE_COMPONENT_OPERATIONremoveComponent operation of ESB installation MBean removes the component
from ESB's registry and repository. | private static final String | UNINSTALL_COMPONENT_OPERATIONUnInstalls already added component in ESB environment. By uninstalling a component,
component becomes removable from the registry and repository of CAS. | private static final String | START_COMPONENT_OPERATIONStarts the component | private static final String | STOP_COMPONENT_OPERATIONStops the component | private static final String | IS_ENGINE_OPERATIONChecks if an engine with provided name exists in openESB .
This operation is used to find out if Service Engine is installed or not | private static final String | IS_CAS_OPERATIONDetermines whether the jbi instance is CAS instance | private String | componentName | private String | SE_BUNDLE | private String | JBI_INSTANCE_NAME | private String | JBI_FOLDER | private String | JBI_ENV_PROPERTIES | private MBeanHelper | mbeanHelper | private String | jbiInstanceName | private boolean | casInstallation | private boolean | jbiInstalled | private static Logger | loggerInternal handle to the logger instance |
Constructors Summary |
---|
public InstallerImpl(MBeanHelper mbeanHelper)Creates a new instance of CASInstallerImpl
this.mbeanHelper = mbeanHelper;
String installationRoot =
ApplicationServer.getServerContext().getInstallRoot();
String jbiInstallationDir = installationRoot + File.separator + JBI_FOLDER;
jbiInstalled = (new File(jbiInstallationDir).exists() &&
(getJBIInstanceName() != null));
if(jbiInstalled)
casInstallation = isCASInstallation();
|
Methods Summary |
---|
private java.lang.String | getJBIInstanceName()
if(jbiInstanceName == null) {
try{
String installRoot = ApplicationServer.getServerContext().getInstallRoot();
String jbiEnvProperties = installRoot + JBI_ENV_PROPERTIES;
Properties jbiEnv = new Properties();
logger.fine("JBI Env properties :" + jbiEnvProperties);
jbiEnv.load(new FileInputStream(jbiEnvProperties));
jbiInstanceName = jbiEnv.getProperty(JBI_INSTANCE_NAME);
logger.fine("JBI Instance name " + jbiInstanceName);
} catch (IOException ioe) {
logger.log(Level.SEVERE, "IOException during reading of jbi env properties " + ioe.getMessage());
}
}
return jbiInstanceName;
| private java.lang.String | getServiceEngineBundle()
String seBundle = System.getProperty("com.sun.aas.installRoot") +
File.separator + SE_BUNDLE;
return seBundle;
| public java.lang.String | install(java.lang.String zipFilePath)Installs the service engine and starts it
//Use InstallationServiceMBean to install new component
String result = null;
if(zipFilePath == null) {
zipFilePath = getServiceEngineBundle();
if(casInstallation) {
log(Level.FINE, "Java EE Service Engine Bundle :" , zipFilePath);
try {
ObjectName objName = mbeanHelper.getObjectName(
MBeanHelper.ESB_INSTALLATION_SERVICE);
log(Level.FINEST, "installation_service_log_name" , objName.toString());
result = (String)mbeanHelper.invokeMBeanOperation(objName,
ADD_COMPONENT_OPERATION, new Object[]{zipFilePath},
new String[] {"java.lang.String"});
log(Level.FINEST, " Status of addComponent ", result );
result = (String)mbeanHelper.invokeMBeanOperation(objName,
INSTALL_COMPONENT_OPERATION,
new Object[]{componentName,
java.util.Arrays.asList(new String[]{jbiInstanceName}),
new Properties()},
new String[] {"java.lang.String", "java.util.List","java.util.Properties"});
log(Level.FINEST, " Status of installComponent ", result );
} catch(Exception e) {
log(Level.SEVERE,
"Error occurred during installation of Java EE Service Engine",
e.getMessage());
}
}
}
return result;
| private boolean | isCASInstallation()
try {
ObjectName objName = mbeanHelper.getObjectName(jbiInstanceName,
MBeanHelper.FRAMEWORK);
log(Level.FINEST, "Framework MBean Object" , objName.toString());
Boolean result = (Boolean)mbeanHelper.invokeMBeanOperation(objName,
IS_CAS_OPERATION, null,new String[] {});
return result.booleanValue();
} catch(Exception e) {
log(Level.SEVERE,
"Error occurred during checking if the instance is CAS or not",
e.getMessage());
}
//Should never reach here
return false;
| public boolean | isComponentInstalled()Checks if the compoenent specified by componentName is installed or
not
if(casInstallation) {
try {
ObjectName objName = mbeanHelper.getObjectName(MBeanHelper.ESB_INSTALLATION_SERVICE);
String result = (String)mbeanHelper.invokeMBeanOperation(objName,
"getComponentInfo",
new Object[]{componentName},
new String[] {"java.lang.String"});
if(result == null || result.trim().length() == 0) {
return false;
}
/*
String domainDir = ApplicationServer.getServerContext().getInstanceEnvironment().getInstancesRoot();
String fs = File.separator;
String javaeeSEDir = domainDir + fs + "jbi" + fs + "engines" + fs + "JavaEEServiceEngine";
if(!(new File(javaeeSEDir).exists())) {
return false;
}
*/
} catch(Exception e) {
log(Level.WARNING, "Exception occurred while getting component by name", e.getMessage());
return false;
}
}
return true;
| public boolean | isJBIInstalled()
return jbiInstalled;
| private void | log(java.util.logging.Level level, java.lang.String property, java.lang.String logString)
logger.log(level,property,logString);
| public void | setComponentName(java.lang.String componentName)
this.componentName = componentName;
| public void | start()Starts the component with provided name
if(casInstallation) {
try {
ObjectName objName = mbeanHelper.getObjectName(
MBeanHelper.ESB_LIFECYCLE_SERVICE);
log(Level.FINEST, "lifecycle_service_obj_name" , objName.toString());
String result = (String)mbeanHelper.invokeMBeanOperation(objName,
START_COMPONENT_OPERATION, new Object[]{componentName},
new String[] {"java.lang.String"});
log(Level.FINEST, "Start Component Status", result);
} catch(Exception e) {
log(Level.SEVERE,
"Error occurred during startup of Java EE Service Engine",
e.getMessage());
}
}
| public void | stop()Stops the component with provided name
if(casInstallation) {
try {
ObjectName objName = mbeanHelper.getObjectName(
MBeanHelper.ESB_LIFECYCLE_SERVICE);
log(Level.FINEST, "lifecycle_service_obj_name" , objName.toString());
String result = (String)mbeanHelper.invokeMBeanOperation(objName,
STOP_COMPONENT_OPERATION, new Object[]{componentName},
new String[] {"java.lang.String"});
log(Level.FINEST, "Start Component Status", result);
} catch(Exception e) {
log(Level.SEVERE,
"Error occurred during stopping of Java EE Service Engine",
e.getMessage());
}
}
| public void | uninstall()Uninstalls the component with provided name
if(casInstallation) {
try {
ObjectName objName = mbeanHelper.getObjectName(
MBeanHelper.ESB_INSTALLATION_SERVICE);
log(Level.FINEST, "installation_service_log_name" , objName.toString());
String result = (String)mbeanHelper.invokeMBeanOperation(objName,
UNINSTALL_COMPONENT_OPERATION, new Object[]{componentName},
new String[] {"java.lang.String"});
log(Level.FINEST, " Status of uninstallComponent ", result );
result = (String)mbeanHelper.invokeMBeanOperation(objName,
REMOVE_COMPONENT_OPERATION,
new Object[]{componentName},
new String[] {"java.lang.String"});
log(Level.FINEST, " Status of removeComponent ", result );
} catch(Exception e) {
log(Level.SEVERE,
"Error occurred during uninstallation of Java EE Service Engine",
e.getMessage());
}
}
|
|