private void cleanupPreservedResources(String appName, Properties properties) { if(properties != null){ String preserve = properties.getProperty(DeploymentProperties.PRESERVE_APP_SCOPED_RESOURCES); if(preserve != null && Boolean.valueOf(preserve)){ ResourcesRegistry.remove(appName); preservedApps.remove(appName); } } }
if (deploymentPhase == OpsParams.Origin.deploy || deploymentPhase == OpsParams.Origin.deploy_instance || deploymentPhase == OpsParams.Origin.create_application_ref) { Map<String, Resources> allResources = ResourcesRegistry.remove(appName); if(allResources != null){ for(Map.Entry<String, Resources> entry : allResources.entrySet()){
Map<String, Resources> allResources = ResourcesRegistry.remove(appName); Application oldApp = preservedApps.remove(appName); if (allResources != null && oldApp != null) {
/** * Event listener to listen to </code>application undeploy validation</code> and * if <i>preserveResources</i> flag is set, cache the <resources> * config for persisting it in domain.xml */ public void event(Event event) { if (event.is(Deployment.DEPLOYMENT_BEFORE_CLASSLOADER_CREATION)) { DeploymentContext dc = (DeploymentContext) event.hook(); final DeployCommandParameters deployParams = dc.getCommandParameters(DeployCommandParameters.class); processResources(dc, deployParams); }else if(event.is(Deployment.UNDEPLOYMENT_VALIDATION)){ DeploymentContext dc = (DeploymentContext) event.hook(); final UndeployCommandParameters undeployCommandParameters = dc.getCommandParameters(UndeployCommandParameters.class); preserveResources(dc, undeployCommandParameters); }else if(Deployment.UNDEPLOYMENT_FAILURE.equals(event.type())){ DeploymentContext dc = (DeploymentContext) event.hook(); cleanupPreservedResources(dc, event); }else if(Deployment.DEPLOYMENT_FAILURE.equals(event.type())){ DeploymentContext dc = (DeploymentContext) event.hook(); String appName = getAppNameFromDeployCmdParams(dc); cleanupResources(appName, dc.getCommandParameters(DeployCommandParameters.class).origin); //TODO ASR call this only when the flag is on ? --properties preserveAppScopedResources=true cleanupPreservedResources(dc, event); }else if(Deployment.DEPLOYMENT_SUCCESS.equals(event.type())){ ApplicationInfo applicationInfo = (ApplicationInfo) event.hook(); String appName = applicationInfo.getName(); ResourcesRegistry.remove(appName); } }