return;
}
if (deploymentManager == null)
{
throw new DeploymentException("Could not undeploy since deployment manager was not loaded");
}
for(Deployment deployment : deployments)
{
if(deployment.isArchiveDeployment())
{
try
{
PROGRESS_BARRIER.reset();
TargetModuleID moduleInfo = context.get(TargetModuleID.class);
if (moduleInfo == null || moduleInfo.getModuleID() == null)
{
log.log(Level.INFO, "Skipping undeploy since module ID could not be determined");
return;
}
TargetModuleID[] availableModuleIDs = deploymentManager.getAvailableModules(
moduleTypeMapper.getModuleType(deployment.getArchive()), getDeploymentManager().getTargets());
TargetModuleID moduleInfoMatch = null;
for (TargetModuleID candidate : availableModuleIDs)
{
if (candidate.getModuleID().equals(moduleInfo.getModuleID()))
{
moduleInfoMatch = candidate;
break;
}
}
if (moduleInfoMatch != null)
{
TargetModuleID[] targetModuleIDs = { moduleInfoMatch };
ProgressObject progress = deploymentManager.undeploy(targetModuleIDs);
progress.addProgressListener(new JSR88DeploymentListener(this, targetModuleIDs, CommandType.UNDEPLOY));
waitForModuleToUndeploy();
}
else
{
resetModuleStatus();
log.info("Undeploy skipped since could not locate module in list of deployed modules");
}
}
catch (Exception e)
{
throw new DeploymentException("Could not undeploy module", e);
}
}
}
}