public void run() {
if (deployer == null) {
return;
}
try {
if (spool) {
if (moduleStream != null) {
moduleArchive = createTempFile(moduleType == null? null: moduleType.getModuleExtension());
copyTo(moduleArchive, moduleStream);
}
if (deploymentStream != null) {
deploymentPlan = createTempFile(null);
copyTo(deploymentPlan, deploymentStream);
}
}
Artifact configID = null;
if(deploymentPlan != null) {
String extracted = ConfigIDExtractor.extractModuleIdFromPlan(deploymentPlan);
if(extracted != null) {
configID = Artifact.create(extracted);
}
} else {
String extracted = ConfigIDExtractor.extractModuleIdFromArchive(moduleArchive);
if(extracted != null) {
configID = Artifact.create(extracted);
}
}
if(configID != null && configID.getGroupId() == null) {
configID = new Artifact(Artifact.DEFAULT_GROUP_ID, configID.getArtifactId(),
configID.getVersion(), configID.getType());
}
ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
try {
for (int i = 0; i < modules.length; i++) {
TargetModuleIDImpl module = (TargetModuleIDImpl) modules[i];
Artifact artifact = Artifact.create(module.getModuleID());
if(configID != null && configID.isResolved()) {
if(configID.getGroupId().equals(artifact.getGroupId()) &&
configID.getArtifactId().equals(artifact.getArtifactId()) &&
configID.getVersion().equals(artifact.getVersion())) {
redeploySameConfiguration(configurationManager, artifact, module.getTarget());
} else {
redeployUpdatedConfiguration(configurationManager, artifact, module.getTarget());
}
} else {
redeployUpdatedConfiguration(configurationManager, artifact, module.getTarget());
}
}
} finally {
ConfigurationUtil.releaseConfigurationManager(kernel, configurationManager);
}
addWebURLs(kernel);
complete("Completed");
} catch (Throwable e) {
doFail(e);
} finally {
if (spool) {
if (moduleArchive != null) {
moduleArchive.delete();
}
if (deploymentPlan != null) {
deploymentPlan.delete();
}
}
}
}
|