1 23 24 32 33 package com.sun.enterprise.deployment.phasing; 34 35 import javax.management.MBeanServer ; 36 import javax.management.ObjectName ; 37 import com.sun.enterprise.admin.util.Assert; 38 import com.sun.enterprise.admin.common.exception.DeploymentException; 39 import com.sun.enterprise.admin.common.constant.DeploymentConstants; 40 import com.sun.enterprise.deployment.backend.Deployer; 41 import com.sun.enterprise.deployment.backend.DeployerFactory; 42 import com.sun.enterprise.deployment.backend.DeploymentRequest; 43 import com.sun.enterprise.deployment.backend.DeployableObjectType; 44 import com.sun.enterprise.deployment.backend.DeploymentEvent; 45 import com.sun.enterprise.deployment.backend.DeploymentEventType; 46 import com.sun.enterprise.deployment.backend.DeploymentEventInfo; 47 import com.sun.enterprise.deployment.backend.DeploymentLogger; 48 import com.sun.enterprise.deployment.backend.DeploymentStatus; 49 import com.sun.enterprise.admin.common.MBeanServerFactory; 50 import com.sun.enterprise.admin.common.ObjectNames; 51 import com.sun.enterprise.util.i18n.StringManager; 52 53 import java.util.logging.Level ; 54 import java.util.logging.Logger ; 55 56 57 63 public class UndeployFromDomainPhase extends DeploymentPhase { 64 65 66 public static final Logger sLogger = DeploymentLogger.get(); 67 68 69 private static StringManager localStrings = 70 StringManager.getManager( UndeployFromDomainPhase.class ); 71 72 76 public UndeployFromDomainPhase(DeploymentContext deploymentCtx) 77 { 78 this.deploymentCtx = deploymentCtx; 79 this.name=UNDEPLOY; 80 } 81 82 88 public void runPhase(DeploymentPhaseContext phaseCtx) 89 { 90 DeploymentStatus status = phaseCtx.getDeploymentStatus(); 91 92 DeploymentRequest req = phaseCtx.getDeploymentRequest(); 93 DeploymentTarget target = (DeploymentTarget)req.getTarget(); 94 String type = null; 95 Deployer deployer = null; 96 try{ 97 if(!req.isApplication()) 98 { 99 type = DeploymentServiceUtils.getModuleTypeString(req.getType()); 100 } 101 deployer = DeployerFactory.getDeployer(req); 102 deployer.doRequest(); 103 104 DeploymentStatus cleanupStatus = 107 new DeploymentStatus(status); 108 req.setCurrentDeploymentStatus(cleanupStatus); 109 110 deployer.cleanup(); 111 112 DeploymentServiceUtils.removeFromConfig(req.getName(), 113 req.getType()); 114 115 status.setStageStatus(DeploymentStatus.SUCCESS); 116 117 postPhaseNotify(getPostPhaseEvent(req)); 118 119 }catch(Throwable t){ 120 status.setStageStatus(DeploymentStatus.FAILURE); 121 status.setStageException(t); 122 status.setStageStatusMessage(t.getMessage()); 123 124 try { 126 if (deployer != null) { 127 deployer.removePolicy(); 128 } 129 DeploymentServiceUtils.removeFromConfig(req.getName(), req.getType()); 130 } catch (Exception eee){} 131 } 132 } 133 134 139 protected DeploymentEvent getPrePhaseEvent(DeploymentRequest req) 140 { 141 return new DeploymentEvent(DeploymentEventType.PRE_UNDEPLOY, new DeploymentEventInfo(req)); 142 } 143 144 149 protected DeploymentEvent getPostPhaseEvent(DeploymentRequest req) 150 { 151 return new DeploymentEvent(DeploymentEventType.POST_UNDEPLOY, new DeploymentEventInfo(req)); 152 } 153 154 } 155 | Popular Tags |