1 23 24 32 33 package com.sun.enterprise.deployment.phasing; 34 35 import com.sun.enterprise.deployment.backend.DeploymentEventManager; 36 import com.sun.enterprise.deployment.backend.DeploymentEvent; 37 import com.sun.enterprise.deployment.backend.DeploymentStatus; 38 import com.sun.enterprise.deployment.backend.DeploymentEventInfo; 39 import com.sun.enterprise.deployment.backend.DeploymentRequest; 40 import com.sun.enterprise.deployment.backend.DeployableObjectType; 41 import com.sun.enterprise.deployment.backend.IASDeploymentException; 42 import com.sun.enterprise.admin.common.constant.DeploymentConstants; 43 import com.sun.enterprise.config.ConfigException; 44 import com.sun.enterprise.util.i18n.StringManager; 45 46 56 public abstract class DeploymentPhase implements DeploymentConstants{ 57 58 59 public static final String J2EEC = "J2EEC"; 60 public static final String ASSOCIATE = "Associate"; 61 public static final String DISASSOCIATE = "Disassociate"; 62 public static final String APP_START = "appStart"; 63 public static final String RA_START = "raStart"; 64 public static final String APP_STOP = "appStop"; 65 public static final String RA_STOP = "raStop"; 66 public static final String UNDEPLOY = "Undeploy"; 67 public static final String PRE_RES_CREATION = "preResCreation"; 68 public static final String POST_RES_CREATION = "postResCreation"; 69 public static final String PRE_RES_DELETION = "preResDeletion"; 70 public static final String POST_RES_DELETION = "postResDeletion"; 71 72 73 protected DeploymentContext deploymentCtx; 74 75 76 private static StringManager localStrings = 77 StringManager.getManager( DeploymentPhase.class ); 78 79 80 String name = null; 81 82 88 public final DeploymentPhaseContext executePhase(DeploymentRequest req, DeploymentStatus status) 89 throws DeploymentPhaseException { 90 DeploymentPhaseContext phaseCtx = getPhaseContext(); 91 phaseCtx.setDeploymentRequest(req); 92 phaseCtx.setDeploymentStatus(status); 93 prePhase(phaseCtx); 94 if (status.getStatus()>DeploymentStatus.FAILURE) 95 runPhase(phaseCtx); 96 if (status.getStatus()>DeploymentStatus.FAILURE) 97 postPhase(phaseCtx); 98 return phaseCtx; 99 } 100 101 111 public void rollback(DeploymentPhaseContext phaseCtx) throws DeploymentPhaseException { 112 } 113 114 120 public abstract void runPhase(DeploymentPhaseContext phaseCtx) throws DeploymentPhaseException; 121 122 128 public void prePhase(DeploymentPhaseContext phaseCtx) throws DeploymentPhaseException{ 129 } 131 132 137 public void postPhase(DeploymentPhaseContext phaseCtx) throws DeploymentPhaseException{ 138 } 140 141 145 public void prePhaseNotify(DeploymentEvent event){ 146 DeploymentEventManager.notifyDeploymentEvent(event); 147 } 148 149 153 public void postPhaseNotify(DeploymentEvent event) { 154 DeploymentEventManager.notifyDeploymentEvent(event); 155 } 156 157 161 public String getName() { 162 return name; 163 } 164 165 169 void setName(String name) { 170 this.name = name; 171 } 172 173 179 protected DeploymentTarget getTarget(String targetName) throws DeploymentPhaseException{ 180 try{ 181 DeploymentTarget target = getTargetFactory().getTarget( 182 deploymentCtx.getConfigContext(), targetName); 183 return target; 184 }catch(IASDeploymentException de){ 185 String msg = localStrings.getString("enterprise.deployment.phasing.phase.targetnotfound"); 186 throw new DeploymentPhaseException(getName(), msg, de); 187 } 188 189 } 190 191 196 protected DeploymentPhaseContext getPhaseContext() { 197 return new StandardDeploymentPhaseContext(); 198 } 199 200 private DeploymentTargetFactory getTargetFactory() { 201 return DeploymentTargetFactory.getDeploymentTargetFactory(); 202 } 203 } 204 | Popular Tags |