try {
if (scanEnabled) { // confirm the scan is still wanted
log.tracef("Scanning directory %s for deployment content changes", deploymentDir.getAbsolutePath());
DeploymentPlanBuilder builder = this.deploymentManager.newDeploymentPlan();
Map<String, File> foundDeployed = new HashMap<String, File>();
Set<String> newlyAdded = new HashSet<String>();
builder = scanDirectory(deploymentDir, builder, foundDeployed, newlyAdded);
// Add remove actions to the plan for anything we count as
// deployed that we didn't find on the scan
Set<String> toRemove = new HashSet<String>(deployed);
toRemove.removeAll(foundDeployed.keySet());
toRemove.removeAll(newlyAdded); // in case user removed the marker and added replacement
for (String missing : toRemove) {
builder = builder.undeploy(missing).andRemoveUndeployed();
}
// Throw away any found marker files that we didn't already know about
Set<String> validFinds = cleanSpuriousMarkerFiles(foundDeployed);
validFinds.addAll(newlyAdded);
this.deployed = validFinds;
DeploymentPlan plan = builder.build();
if (plan.getDeploymentActions().size() > 0) {
if (log.isDebugEnabled()) {
for (DeploymentAction action : plan.getDeploymentActions()) {
log.debugf("Deployment plan %s includes action of type %s affecting deployment %s", plan.getId(), action.getType(), action.getDeploymentUnitUniqueName());