if ( !this.registeredDeployments.containsKey( name ) ) {
try {
logger.debug( "New deployment {} has been discovered and will be deployed", name );
// add it to registered deployments
DeploymentConfig deployment = deploymentFactory.newDeployment( deploymentConfig );
// trigger deployment of new element
addedDeploymentEvent.fire( new DeploymentConfigChangedEvent( deployment.getDeploymentUnit() ) );
registeredDeployments.put( deployment.getIdentifier(), deployment );
logger.debug( "Deployment {} deployed successfully", name );
} catch ( RuntimeException e ) {
logger.warn( "Deployment {} failed to deploy due to {}", name, e.getMessage(), e );
}
}
processedDeployments.add( name );
}
Set<String> registeredDeploymedIds = registeredDeployments.keySet();
// process undeploy
for ( String identifier : registeredDeploymedIds ) {
if ( !processedDeployments.contains( identifier ) ) {
try {
logger.debug( "New deployment {} has been discovered and will be deployed", identifier );
DeploymentConfig deployment = registeredDeployments.remove( identifier );
// trigger undeloyment as it was removed
removedDeploymentEvent.fire( new DeploymentConfigChangedEvent( deployment.getDeploymentUnit() ) );
logger.debug( "Deployment {} undeployed successfully", identifier );
} catch ( RuntimeException e ) {
logger.warn( "Undeployment {} failed to deploy due to {}", identifier, e.getMessage(), e );
}
}