try {
DeploymentCallback callback = req.getDeploymentCallback();
if (callback != null) {
int percent = 0;
DeploymentProgress progress = new DeploymentProgressImpl(
(byte)percent, "deployment started", null);
callback.deploymentProgress(progress);
}
// set the current deployment status in deployment request
// to J2EECPhase deployment status
req.setCurrentDeploymentStatus(status);
req.setDescriptor(deploymentCtx.getApplication(req.getName()));
if (DeploymentServiceUtils.isRegistered(req.getName(),
req.getType()) && req.isForced()) {
isRedeploy = true;
//Re-record instrospect/instrument/verifier data if
//any of the application is re-deployed
if (AppVerification.doInstrument()) {
AppVerification.getInstrumentLogger().handleChangeInDeployment();
}
}
if(req.isApplication())
isApp = true;
if (!req.isExtensionModule()) {
deployer = DeployerFactory.getDeployer(req);
deployer.doRequestPrepare();
}
if(isRedeploy) {
// clear the deploymentCtx cache now
deploymentCtx.removeApplication(req.getName());
req.setDescriptor(null);
target = (DeploymentTarget)req.getTarget();
// In the case of redeploy to domain,
// no stop event will be sent.
if(target != null && ! target.getName().equals("domain")) {
targetName = target.getName();
if(isApp) {
type = null;
actionCode = BaseDeployEvent.APPLICATION_UNDEPLOYED;
}
else {
type = DeploymentServiceUtils.getModuleTypeString(req.getType());
actionCode = BaseDeployEvent.MODULE_UNDEPLOYED;
}
DeploymentServiceUtils.multicastEvent(actionCode, req.getName(), type, req.getCascade(), req.isForced(), targetName);
wasUnRegistered = true;
}
}
if (req.isExtensionModule()) {
ModuleType moduleType = req.getType().getModuleType();
extDeployer =
PluggableDeploymentInfo.getExtensionModuleDeployer(
moduleType);
if (isRedeploy) {
extDeployer.redeployToDomain(req);
} else {
extDeployer.deployToDomain(req);
}
} else {
deployer.doRequestFinish();
// cache the updated application object in deployment context
deploymentCtx.addApplication(req.getName(), req.getDescriptor());
parseAndValidateSunResourcesXMLFiles(req);
deployer.cleanup();
}
// check if an abort operation has been issued
// throw exception if true
DeploymentServiceUtils.checkAbort(req.getName());
// do all the config update at the end for easy rollback
if(isRedeploy) {
DeploymentServiceUtils.updateConfig(req);
} else {
DeploymentServiceUtils.addToConfig(req);
}
// set context roots on config bean
ApplicationConfigHelper.resetAppContextRoots(
DeploymentServiceUtils.getConfigContext(), req.getName(),
true);
wasUnRegistered = false; // addToConfig re-registered it...
// everything went fine
status.setStageStatus(DeploymentStatus.SUCCESS);
// some useful information for clients...
sLogger.log(Level.INFO, "deployed with " + DeploymentProperties.MODULE_ID + " = " + req.getName());
populateStatusProperties(status, req);
if (callback != null) {
int percent = 100;
DeploymentProgress progress2 = new DeploymentProgressImpl(
(byte)percent, "deployment finished", null);
callback.deploymentProgress(progress2);
}
} catch(Throwable t) {