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 javax.enterprise.deploy.shared.ModuleType ; 49 50 import java.util.logging.Level ; 51 import java.util.logging.Logger ; 52 53 58 public class ResourceAdapterStartPhase extends DeploymentPhase { 59 60 61 public static final Logger sLogger = DeploymentLogger.get(); 62 63 64 private static StringManager localStrings = 65 StringManager.getManager( ResourceAdapterStartPhase.class ); 66 67 71 public ResourceAdapterStartPhase(DeploymentContext deploymentCtx) 72 { 73 this.deploymentCtx = deploymentCtx; 74 this.name = RA_START; 75 } 76 77 83 public void runPhase(DeploymentPhaseContext phaseCtx) { 84 String type = null; 85 86 DeploymentRequest req = phaseCtx.getDeploymentRequest(); 87 88 DeploymentStatus status = phaseCtx.getDeploymentStatus(); 89 90 DeploymentTarget target = (DeploymentTarget)req.getTarget(); 91 if(target == null) { 92 String msg = localStrings.getString("enterprise.deployment.phasing.start.targetnotspecified"); 93 sLogger.log(Level.FINEST, msg); 94 status.setStageStatus(DeploymentStatus.SUCCESS); 95 return; 96 } 97 98 boolean containsRar = false; 99 100 if(req.isApplication()) { 101 type = null; 102 Application app = DeploymentServiceUtils.getInstanceManager( 103 DeployableObjectType.APP).getRegisteredDescriptor(req.getName()); 104 105 if ( (app != null) && (app.getRarComponentCount() != 0) ) { 106 containsRar = true; 107 } 108 } 109 else { 110 type = DeploymentServiceUtils.getModuleTypeString(req.getType()); 111 if (req.isConnectorModule()) { 112 containsRar = true; 113 } 114 } 115 116 if (!containsRar) { 117 status.setStageStatus(DeploymentStatus.SUCCESS); 118 return; 119 } 120 121 prePhaseNotify(getPrePhaseEvent(req)); 122 int actionCode = req.getActionCode(); 123 124 boolean success; 125 try { 126 success = target.sendStartEvent(actionCode, req.getName(), type, 129 req.isForced(), Constants.LOAD_RAR); 130 } catch(DeploymentTargetException dte) { 131 status.setStageStatus(DeploymentStatus.WARNING); 132 if (dte.getCause()!=null) { 133 status.setStageStatusMessage(dte.getMessage()); 134 } 135 return; 136 } 137 if (success) { 138 status.setStageStatus(DeploymentStatus.SUCCESS); 139 } else { 140 status.setStageStatus(DeploymentStatus.WARNING); 141 status.setStageStatusMessage("Application failed to load"); 142 } 143 postPhaseNotify(getPostPhaseEvent(req)); 144 145 } 148 149 154 private DeploymentEvent getPrePhaseEvent(DeploymentRequest req) { 155 return new DeploymentEvent(DeploymentEventType.PRE_RA_START, new DeploymentEventInfo(req)); 156 } 157 158 163 private DeploymentEvent getPostPhaseEvent(DeploymentRequest req) { 164 return new DeploymentEvent(DeploymentEventType.POST_RA_START, new DeploymentEventInfo(req)); 165 } 166 167 } 168 | Popular Tags |