FileDocCategorySizeDatePackage
ApplicationStartPhase.javaAPI DocGlassfish v2 API7174Fri May 04 22:34:36 BST 2007com.sun.enterprise.deployment.phasing

ApplicationStartPhase

public class ApplicationStartPhase extends DeploymentPhase
This phase is responsible to send the start events to the actual server instance. This phase is executed as part of Deploy, Associate operations
author
Sandhya E

Fields Summary
public static final Logger
sLogger
Deployment Logger object for this class
private static com.sun.enterprise.util.i18n.StringManager
localStrings
string manager
Constructors Summary
public ApplicationStartPhase(DeploymentContext deploymentCtx)
Creates a new instance of ApplicationStartPhase

param
deploymentCtx DeploymentContext object

    
                     
       
    
         this.deploymentCtx = deploymentCtx;
         this.name = APP_START;
    
Methods Summary
private com.sun.enterprise.deployment.backend.DeploymentEventgetPostPhaseEvent(com.sun.enterprise.deployment.backend.DeploymentRequest req)
Event that will be broadcasted at the end of the phase

param
req Deployment request object
return
DeploymentEvent

        return new DeploymentEvent(DeploymentEventType.POST_APP_START, new DeploymentEventInfo(req));
    
private com.sun.enterprise.deployment.backend.DeploymentEventgetPrePhaseEvent(com.sun.enterprise.deployment.backend.DeploymentRequest req)
Event that will be broadcasted at the start of the phase

param
req Deployment request object
return
DeploymentEvent

        return new DeploymentEvent(DeploymentEventType.PRE_APP_START, new DeploymentEventInfo(req));
    
public voidrunPhase(DeploymentPhaseContext phaseCtx)
Phase specific execution logic will go in this method. Any phase implementing this class will provide its implementation for this method.

param
req DeploymentRequest object
param
phaseCtx the DeploymentPhaseContext object

        String type = null;
        
        DeploymentRequest req = phaseCtx.getDeploymentRequest();

        DeploymentStatus status = phaseCtx.getDeploymentStatus();
        
        DeploymentTarget target = (DeploymentTarget)req.getTarget();
        if(target == null) {
            String msg = localStrings.getString("enterprise.deployment.phasing.start.targetnotspecified");
            sLogger.log(Level.FINEST, msg);
            status.setStageStatus(DeploymentStatus.SUCCESS);            
            return;
        }
        
        prePhaseNotify(getPrePhaseEvent(req));
        int actionCode = req.getActionCode();

        int loadUnloadAction = Constants.LOAD_ALL;
        
        if(req.isApplication()) {
            type = null;
            Application app = DeploymentServiceUtils.getInstanceManager(
               DeployableObjectType.APP).getRegisteredDescriptor(req.getName());

            if ( (app != null) && (app.getRarComponentCount() != 0) ) {
                loadUnloadAction = Constants.LOAD_REST;
            }
        }
        else {
            type = DeploymentServiceUtils.getModuleTypeString(req.getType());
        }
        
        boolean success;
        try { 
           // send this event to load non-rar standalone module or application
           // or to load the non-rar submodules of embedded rar
           if (! req.isConnectorModule()) {
               success = target.sendStartEvent(actionCode, req.getName(), type,
                                           req.isForced(), loadUnloadAction);
           } else {
               status.setStageStatus(DeploymentStatus.SUCCESS);
               return;
           }
        } catch(DeploymentTargetException dte) {
            status.setStageStatus(DeploymentStatus.WARNING);
            if (dte.getCause()!=null) {
                status.setStageStatusMessage(dte.getMessage());
            }
            return;
        }
        if (success) {
            status.setStageStatus(DeploymentStatus.SUCCESS);
        } else {
            status.setStageStatus(DeploymentStatus.WARNING);
            status.setStageStatusMessage("Application failed to load");
        }
        postPhaseNotify(getPostPhaseEvent(req));
        
        // if any exception arrise, we let it unroll this stack, it will
        // be processed by DeploymentService