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.deployment.backend.DeployableObjectType; 43 import com.sun.enterprise.deployment.Application; 44 import com.sun.enterprise.util.i18n.StringManager; 45 import com.sun.enterprise.admin.event.BaseDeployEvent; 46 import com.sun.enterprise.server.Constants; 47 48 import java.util.logging.Level ; 49 import java.util.logging.Logger ; 50 51 56 public class ApplicationStartPhase extends DeploymentPhase { 57 58 59 public static final Logger sLogger = DeploymentLogger.get(); 60 61 62 private static StringManager localStrings = 63 StringManager.getManager( ApplicationStartPhase.class ); 64 65 69 public ApplicationStartPhase(DeploymentContext deploymentCtx) 70 { 71 this.deploymentCtx = deploymentCtx; 72 this.name = APP_START; 73 } 74 75 81 public void runPhase(DeploymentPhaseContext phaseCtx) { 82 String type = null; 83 84 DeploymentRequest req = phaseCtx.getDeploymentRequest(); 85 86 DeploymentStatus status = phaseCtx.getDeploymentStatus(); 87 88 DeploymentTarget target = (DeploymentTarget)req.getTarget(); 89 if(target == null) { 90 String msg = localStrings.getString("enterprise.deployment.phasing.start.targetnotspecified"); 91 sLogger.log(Level.FINEST, msg); 92 status.setStageStatus(DeploymentStatus.SUCCESS); 93 return; 94 } 95 96 prePhaseNotify(getPrePhaseEvent(req)); 97 int actionCode = req.getActionCode(); 98 99 int loadUnloadAction = Constants.LOAD_ALL; 100 101 if(req.isApplication()) { 102 type = null; 103 Application app = DeploymentServiceUtils.getInstanceManager( 104 DeployableObjectType.APP).getRegisteredDescriptor(req.getName()); 105 106 if ( (app != null) && (app.getRarComponentCount() != 0) ) { 107 loadUnloadAction = Constants.LOAD_REST; 108 } 109 } 110 else { 111 type = DeploymentServiceUtils.getModuleTypeString(req.getType()); 112 } 113 114 boolean success; 115 try { 116 if (! req.isConnectorModule()) { 119 success = target.sendStartEvent(actionCode, req.getName(), type, 120 req.isForced(), loadUnloadAction); 121 } else { 122 status.setStageStatus(DeploymentStatus.SUCCESS); 123 return; 124 } 125 } catch(DeploymentTargetException dte) { 126 status.setStageStatus(DeploymentStatus.WARNING); 127 if (dte.getCause()!=null) { 128 status.setStageStatusMessage(dte.getMessage()); 129 } 130 return; 131 } 132 if (success) { 133 status.setStageStatus(DeploymentStatus.SUCCESS); 134 } else { 135 status.setStageStatus(DeploymentStatus.WARNING); 136 status.setStageStatusMessage("Application failed to load"); 137 } 138 postPhaseNotify(getPostPhaseEvent(req)); 139 140 } 143 144 149 private DeploymentEvent getPrePhaseEvent(DeploymentRequest req) { 150 return new DeploymentEvent(DeploymentEventType.PRE_APP_START, new DeploymentEventInfo(req)); 151 } 152 153 158 private DeploymentEvent getPostPhaseEvent(DeploymentRequest req) { 159 return new DeploymentEvent(DeploymentEventType.POST_APP_START, new DeploymentEventInfo(req)); 160 } 161 162 } 163 | Popular Tags |