FileDocCategorySizeDatePackage
DeploymentPhase.javaAPI DocGlassfish v2 API8972Fri May 04 22:34:38 BST 2007com.sun.enterprise.deployment.phasing

DeploymentPhase

public abstract class DeploymentPhase extends Object implements com.sun.enterprise.admin.common.constant.DeploymentConstants
This class is a framework for a deployment phase. A deployment phase is a logical part of deployment or undeployment operation Deployment operation has three phases namely J2EEC, Associate, Start Undeployment has UndeployFromDomain,Disassociate,Stop phases. These phases are invoked from DeploymentService. There is no state associated with these phases, that makes it possible for running phases concurrently. This class also provides methods for notifications, and pre post conditions.
author
Sandhya E

Fields Summary
public static final String
J2EEC
names used for phases
public static final String
ASSOCIATE
public static final String
DISASSOCIATE
public static final String
APP_START
public static final String
RA_START
public static final String
APP_STOP
public static final String
RA_STOP
public static final String
UNDEPLOY
public static final String
PRE_RES_CREATION
public static final String
POST_RES_CREATION
public static final String
PRE_RES_DELETION
public static final String
POST_RES_DELETION
protected DeploymentContext
deploymentCtx
context object for executing this phase
private static com.sun.enterprise.util.i18n.StringManager
localStrings
string manager
String
name
name of the phase
Constructors Summary
Methods Summary
public final DeploymentPhaseContextexecutePhase(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.backend.DeploymentStatus status)
This method executes the whole phase.

param
req DeploymentRequest object
param
status the DeploymentStatus object to return feedback
throws
DeploymentPhaseException

    
                             
           
          
	DeploymentPhaseContext phaseCtx = getPhaseContext();
        phaseCtx.setDeploymentRequest(req);
        phaseCtx.setDeploymentStatus(status);
        prePhase(phaseCtx);     
        if (status.getStatus()>DeploymentStatus.FAILURE)
            runPhase(phaseCtx);
        if (status.getStatus()>DeploymentStatus.FAILURE)
            postPhase(phaseCtx);
	return phaseCtx;
    
public java.lang.StringgetName()
Gets the name of this phase

return
name of the phase

        return name;
    
protected DeploymentPhaseContextgetPhaseContext()

return
a new @see DeploymentPhaseContext instance to hold information about this phase. Can be used at rollback time to undo a succesful deployment phase.

	  return new StandardDeploymentPhaseContext();
      
protected DeploymentTargetgetTarget(java.lang.String targetName)
Returns the deployment target of the specified name

param
targetName target that has to be returned, if targetName is null default target is returned
return
deploymentTarget DeploymentTarget

        try{
            DeploymentTarget target   = getTargetFactory().getTarget(
                                         deploymentCtx.getConfigContext(), targetName);
            return target;
        }catch(IASDeploymentException de){
            String msg = localStrings.getString("enterprise.deployment.phasing.phase.targetnotfound");
            throw new DeploymentPhaseException(getName(), msg, de);
        }
        
    
private DeploymentTargetFactorygetTargetFactory()

        return DeploymentTargetFactory.getDeploymentTargetFactory();
      
public voidpostPhase(DeploymentPhaseContext phaseCtx)
Any postPhase checks and postPhase cleanup can happen here

param
phaseCtx the DeploymentPhaseContext object
throws
DeploymentPhaseException

        //phase specific post conditions must be checked here
    
public voidpostPhaseNotify(com.sun.enterprise.deployment.backend.DeploymentEvent event)
All listeners registered with DeploymentEventManager will be notified at the end of the phase

        DeploymentEventManager.notifyDeploymentEvent(event);
    
public voidprePhase(DeploymentPhaseContext phaseCtx)
Any prePhase checks can be done here, and also any preparation for actual phase execution can happen here

param
phaseCtx the DeploymentPhaseContext object
throws
DeploymentPhaseException

        //phase specific pre conditions must be checked here
    
public voidprePhaseNotify(com.sun.enterprise.deployment.backend.DeploymentEvent event)
All the listeners registered for this phase will be notified at the start of the phase.

        DeploymentEventManager.notifyDeploymentEvent(event);
    
public voidrollback(DeploymentPhaseContext phaseCtx)
This method is called when a successfully executed phase needs to be rollbacked due to a subsequent failure in the deployment process. All information needed for rollbacking should be available in the DeploymentPhaseContext instance returned by the executePhase and passed to this method

param
phaseCtx the DeploymentPhaseContext instance
throws
DeploymentPhaseException

    
public abstract 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
phaseCtx the DeploymentPhaseContext object
throws
DeploymentPhaseException

voidsetName(java.lang.String name)
Sets the name of this phase

param
name name of the phase

        this.name = name;