1 23 24 32 33 package com.sun.enterprise.deployment.phasing; 34 35 import javax.management.MBeanServer ; 36 import javax.management.ObjectName ; 37 import javax.management.MBeanException ; 38 39 import com.sun.enterprise.deployment.backend.IASDeploymentException; 40 import com.sun.enterprise.deployment.backend.DeploymentRequest; 41 import com.sun.enterprise.deployment.backend.DeploymentEvent; 42 import com.sun.enterprise.deployment.backend.DeploymentEventType; 43 import com.sun.enterprise.deployment.backend.DeploymentEventInfo; 44 import com.sun.enterprise.deployment.backend.DeploymentLogger; 45 import com.sun.enterprise.deployment.backend.DeploymentStatus; 46 import com.sun.enterprise.deployment.backend.DeployableObjectType; 47 import com.sun.enterprise.deployment.Application; 48 import com.sun.enterprise.util.i18n.StringManager; 49 import com.sun.enterprise.admin.event.BaseDeployEvent; 50 import com.sun.enterprise.admin.common.MBeanServerFactory; 51 import com.sun.enterprise.admin.common.ObjectNames; 52 import com.sun.enterprise.admin.server.core.AdminNotificationHelper; 53 import com.sun.enterprise.admin.server.core.AdminService; 54 import com.sun.enterprise.admin.AdminContext; 55 import com.sun.enterprise.server.Constants; 56 57 import java.util.logging.Level ; 58 import java.util.logging.Logger ; 59 60 65 public class ApplicationStopPhase extends DeploymentPhase { 66 67 68 public static final Logger sLogger = DeploymentLogger.get(); 69 70 71 private static StringManager localStrings = 72 StringManager.getManager( ApplicationStopPhase.class ); 73 74 78 public ApplicationStopPhase(DeploymentContext deploymentCtx) 79 { 80 this.deploymentCtx = deploymentCtx; 81 this.name = APP_STOP; 82 } 83 84 89 public void runPhase(DeploymentPhaseContext phaseCtx) 90 { 91 String type = null; 92 93 DeploymentRequest req = phaseCtx.getDeploymentRequest(); 94 95 DeploymentTarget target = (DeploymentTarget)req.getTarget(); 96 DeploymentStatus status = phaseCtx.getDeploymentStatus(); 97 98 int loadUnloadAction = Constants.UNLOAD_ALL; 99 100 if(!req.isApplication()) 101 { 102 type = DeploymentServiceUtils.getModuleTypeString(req.getType()); 103 } else { 104 Application app = DeploymentServiceUtils.getInstanceManager( 105 DeployableObjectType.APP).getRegisteredDescriptor(req.getName()); 106 107 if ( (app != null) && (app.getRarComponentCount() != 0) ) { 108 loadUnloadAction = Constants.UNLOAD_REST; 109 } 110 } 111 112 prePhaseNotify(getPrePhaseEvent(req)); 113 114 boolean success; 115 try { 116 if (! req.isConnectorModule()) { 119 success = target.sendStopEvent(req.getActionCode(), req.getName(), type, req.getCascade(), req.isForced(), loadUnloadAction); 120 } else { 121 status.setStageStatus(DeploymentStatus.SUCCESS); 122 return; 123 } 124 } catch(DeploymentTargetException dte) { 125 status.setStageStatus(DeploymentStatus.FAILURE); 126 if (dte.getCause()!=null) { 127 status.setStageException(dte.getCause()); 128 status.setStageStatusMessage(dte.getMessage()); 129 } 130 return; 131 } 132 if (success) { 133 status.setStageStatus(DeploymentStatus.SUCCESS); 134 } else { 135 status.setStageStatus(DeploymentStatus.FAILURE); 136 status.setStageStatusMessage("Application failed to stop"); 137 } 138 139 postPhaseNotify(getPostPhaseEvent(req)); 140 141 } 144 145 150 protected DeploymentEvent getPrePhaseEvent(DeploymentRequest req) 151 { 152 return new DeploymentEvent(DeploymentEventType.PRE_APP_STOP, new DeploymentEventInfo(req)); 153 } 154 155 160 protected DeploymentEvent getPostPhaseEvent(DeploymentRequest req) 161 { 162 return new DeploymentEvent(DeploymentEventType.POST_APP_STOP,new DeploymentEventInfo(req) ); 163 } 164 165 } 166 | Popular Tags |