ApplicationReferenceActionpublic class ApplicationReferenceAction extends com.sun.enterprise.deployapi.ProgressObjectImpl
Fields Summary |
---|
private static com.sun.enterprise.util.i18n.StringManager | localStrings |
Methods Summary |
---|
private void | handleAppRefActionForLifeCycleModules(com.sun.appserv.management.client.ConnectionSource dasConnection, com.sun.enterprise.deployapi.SunTarget[] targetList, java.lang.String id, javax.enterprise.deploy.shared.CommandType cmd, java.util.Map options)
String action = (CommandType.DISTRIBUTE.equals(cmd)) ? "Creation" : "Removal";
try {
for(int i=0; i<targetList.length; i++) {
DeploymentStatus stat = null;
if(CommandType.DISTRIBUTE.equals(cmd)) {
stat = DeploymentClientUtils.createLifecycleModuleReference(
dasConnection.getExistingMBeanServerConnection(), id, targetList[i].getName(), options);
} else {
stat = DeploymentClientUtils.removeLifecycleModuleReference(
dasConnection.getExistingMBeanServerConnection(), id, targetList[i].getName());
}
if(!checkStatusAndAddStage(targetList[i], null, localStrings.getString("enterprise.deployment.client.change_reference", action, targetList[i].getName()), dasConnection, stat)) {
return;
}
}
setupForNormalExit(localStrings.getString("enterprise.deployment.client.change_reference_lifemodule", action), targetList[0]);
} catch(Throwable ioex) {
finalDeploymentStatus.setStageException(ioex);
setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.change_reference_lifemodule_failed", action, ioex.getMessage()), targetList[0]);
}
return;
| public void | run()
ConnectionSource dasConnection= (ConnectionSource) args[0];
SunTarget[] targetList = (SunTarget[]) args[1];
String moduleID = (String) args[2];
CommandType cmd = (CommandType) args[3];
Map deployOptions = (Map) args[4];
String action = (CommandType.DISTRIBUTE.equals(cmd)) ? "Creation" : "Removal";
try {
// Handle app-ref-creation/app-ref-removal for life-cycle-module as a special case
if(DeploymentClientUtils.isLifecycleModule(dasConnection.getExistingMBeanServerConnection(), moduleID)) {
handleAppRefActionForLifeCycleModules(dasConnection, targetList, moduleID, cmd, deployOptions);
return;
}
// the target module ids in which the operation was successful
ArrayList resultTargetModuleIDs = new ArrayList();
RollBackAction rollback;
if(CommandType.DISTRIBUTE.equals(cmd)) {
rollback = new RollBackAction(RollBackAction.CREATE_APP_REF_OPERATION, moduleID, deployOptions);
} else{
rollback = new RollBackAction(RollBackAction.DELETE_APP_REF_OPERATION, moduleID, deployOptions);
}
for(int i=0; i<targetList.length; i++) {
if(CommandType.DISTRIBUTE.equals(cmd)) {
DeploymentStatus stat =
DeploymentClientUtils.createApplicationReference(
dasConnection.getExistingMBeanServerConnection(),
moduleID, targetList[i], deployOptions);
if(!checkStatusAndAddStage(targetList[i], rollback,
localStrings.getString("enterprise.deployment.client.create_reference", targetList[i].getName()), dasConnection, stat)) {
return;
}
rollback.addTarget(targetList[i], RollBackAction.APP_REF_CREATED);
/*
XXX Start the application regardless the value of "enable"
Otherwise no DeployEvent would be sent to the listeners on
a remote instance, which would in turn synchronize the app
bits. Note that the synchronization is only called during
applicationDeployed, not applicationEnabled. To make sure
the deployment code can work with both the new and the old
mbeans, we will call the start for now (as the old mbeans
would do). The backend listeners are already enhanced to
make sure the apps are not actually loaded unless the enable
attributes are true for both the application and
application-ref elements.
*/
DeploymentClientUtils.setResourceOptions(
deployOptions,
DeploymentProperties.RES_CREATE_REF,
targetList[i].getName());
stat = DeploymentClientUtils.startApplication(
dasConnection.getExistingMBeanServerConnection(),
moduleID, targetList[i], deployOptions);
// We dont rollback for start failure because start failure may be because of server being down
// We just add DeploymentStatus of this phase to the complete DeploymentStatus
checkStatusAndAddStage(targetList[i], null,
localStrings.getString("enterprise.deployment.client.reference_start", targetList[i].getName()), dasConnection, stat, true);
} else {
deployOptions.put(DeploymentProperties.DEPLOY_OPTION_FORCE_KEY, "false");
// We dont rollback for stop failure because the failure may be because of server being down
// We just add DeploymentStatus of this phase to the complete DeploymentStatus
DeploymentClientUtils.setResourceOptions(
deployOptions,
DeploymentProperties.RES_DELETE_REF,
targetList[i].getName());
DeploymentStatus stat =
DeploymentClientUtils.stopApplication(
dasConnection.getExistingMBeanServerConnection(),
moduleID, targetList[i], deployOptions);
if (!checkStatusAndAddStage(targetList[i], null,
localStrings.getString("enterprise.deployment.client.reference_stop", targetList[i].getName()), dasConnection, stat)) {
return;
}
stat = DeploymentClientUtils.deleteApplicationReference(
dasConnection.getExistingMBeanServerConnection(),
moduleID, targetList[i], deployOptions);
if(!checkStatusAndAddStage(targetList[i], rollback,
localStrings.getString("enterprise.deployment.client.remove_reference", targetList[i].getName()), dasConnection, stat)) {
return;
}
rollback.addTarget(targetList[i], RollBackAction.APP_REF_DELETED);
}
resultTargetModuleIDs.add(new SunTargetModuleID(moduleID, targetList[i]));
}
// initialize the instance variable targetModuleIDs using
// the successful module ids
this.targetModuleIDs = new TargetModuleID[resultTargetModuleIDs.size()];
this.targetModuleIDs =
(TargetModuleID[])resultTargetModuleIDs.toArray(this.targetModuleIDs);
setupForNormalExit(localStrings.getString("enterprise.deployment.client.change_reference_application", action), targetList[0]);
} catch (Throwable ioex) {
finalDeploymentStatus.setStageException(ioex);
setupForAbnormalExit(localStrings.getString("enterprise.deployment.client.change_reference_application_failed", action, ioex.getMessage()), targetList[0]);
return;
}
|
|