1 23 24 32 33 package com.sun.enterprise.deployment.phasing; 34 35 import com.sun.enterprise.deployment.backend.IASDeploymentException; 36 import com.sun.enterprise.deployment.backend.DeploymentRequest; 37 import com.sun.enterprise.deployment.backend.DeploymentEvent; 38 import com.sun.enterprise.deployment.backend.DeploymentEventType; 39 import com.sun.enterprise.deployment.backend.DeploymentEventInfo; 40 import com.sun.enterprise.deployment.backend.DeploymentLogger; 41 import com.sun.enterprise.deployment.backend.DeploymentStatus; 42 import com.sun.enterprise.util.i18n.StringManager; 43 44 import java.util.logging.Level ; 45 import java.util.logging.Logger ; 46 47 52 class DisassociationPhase extends DeploymentPhase { 53 54 55 public static final Logger sLogger = DeploymentLogger.get(); 56 57 58 private static StringManager localStrings = 59 StringManager.getManager( DisassociationPhase.class ); 60 61 65 public DisassociationPhase(DeploymentContext deploymentCtx) { 66 this.deploymentCtx = deploymentCtx; 67 this.name = DISASSOCIATE; 68 } 69 70 76 public void runPhase(DeploymentPhaseContext phaseCtx) 77 { 78 DeploymentStatus status = phaseCtx.getDeploymentStatus(); 79 80 try { 81 DeploymentRequest req = phaseCtx.getDeploymentRequest(); 83 DeploymentTarget target = (DeploymentTarget)req.getTarget(); 84 85 target.removeAppReference(req.getName()); 86 sendDisassociateEvent(req); 87 status.setStageStatus(DeploymentStatus.SUCCESS); 88 }catch(Throwable t){ 89 status.setStageStatus(DeploymentStatus.FAILURE); 90 status.setStageException(t); 91 status.setStageStatusMessage(t.getMessage()); 92 } 93 } 94 95 96 101 private DeploymentEvent getPrePhaseEvent(DeploymentRequest req) { 102 return new DeploymentEvent(DeploymentEventType.PRE_DISASSOCIATE, new DeploymentEventInfo(req)); 103 } 104 105 110 private DeploymentEvent getPostPhaseEvent(DeploymentRequest req) { 111 return new DeploymentEvent(DeploymentEventType.POST_DISASSOCIATE,new DeploymentEventInfo(req)); 112 } 113 114 private void sendDisassociateEvent(DeploymentRequest req) throws 115 Exception { 116 DeploymentTarget target = (DeploymentTarget)req.getTarget(); 117 118 String moduleType; 119 120 if(req.isApplication()) { 121 moduleType = null; 122 } 123 else { 124 moduleType = DeploymentServiceUtils.getModuleTypeString(req.getType()); 125 } 126 127 int eventType = com.sun.enterprise.admin.event.BaseDeployEvent.APPLICATION_UNREFERENCED; 128 String appName = req.getName(); 129 String targetName = target.getTarget().getName(); 130 131 boolean success = DeploymentServiceUtils.multicastEvent( 132 eventType, 133 appName, 134 moduleType, 135 false, 136 true, 137 targetName); 138 139 sLogger.log(Level.FINE, "sendDisassociateEvent: success=" + success); 140 } 141 } 142 | Popular Tags |