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

DisassociationPhase

public class DisassociationPhase extends DeploymentPhase
This phase is responsible to disassociate an application from a target It uses ServerDeploymentTarget, GroupDeploymentTarget to remove references
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 DisassociationPhase(DeploymentContext deploymentCtx)
Creates a new instance of DisassociatePhase

param
deploymentCtx DeploymentContext object

    
                   
       
        this.deploymentCtx = deploymentCtx;
        this.name = DISASSOCIATE;
    
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 DeploymentRequest object
return
DeploymentEvent

        return new DeploymentEvent(DeploymentEventType.POST_DISASSOCIATE,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 DeploymentRequest object
return
DeploymentEvent

        return new DeploymentEvent(DeploymentEventType.PRE_DISASSOCIATE, new DeploymentEventInfo(req));
    
public voidrunPhase(DeploymentPhaseContext phaseCtx)
This method disassociates the application from the target as specified in request object

param
req DeploymentRequest object
param
phaseCtx the DeploymentPhaseContext object

        DeploymentStatus status = phaseCtx.getDeploymentStatus();
        
        try {
            //get the app directory on target's cache deleted
            DeploymentRequest req = phaseCtx.getDeploymentRequest();
            DeploymentTarget target = (DeploymentTarget)req.getTarget();
            
            /*
             *Remove the app ref and send the event unless this is part of a 
             *redeployment sequence of operations and the attributes for the app
             *ref will not change as a result of the deployment, compared to 
             *their current values.
             */
            ApplicationRef ref = ApplicationReferenceHelper.findCurrentAppRef(
                    deploymentCtx, target.getName(), req.getName());
            boolean needToRemoveRef = true;
            DeploymentContext.SavedApplicationRefInfo info = null;
            if (req.isRedeployInProgress()) {
                /*
                 *Save a pointer to the existing app ref for use during the later
                 *disassociate phase.
                 */
                info = deploymentCtx.saveAppRef(
                        req.getName(), target.getName(), ref, req);
                needToRemoveRef = info.isChanging();
            }
            sLogger.fine("DisassociationPhase for " + req.getName() + " on " + target.getName() + 
                    "; isRedeployInProgress = " + req.isRedeployInProgress() +
                    ", savedAppRefInfo is " + (info != null ? info.toString() : "<null>" ) + "need to remove = " + needToRemoveRef);
            if (needToRemoveRef) {
                sLogger.fine("DisassociationPhase removing app ref for " + req.getName() + " on " + target.getName());
                target.removeAppReference(req.getName());
                sendDisassociateEvent(req);
            }
            status.setStageStatus(DeploymentStatus.SUCCESS);
        }catch(Throwable t){
            status.setStageStatus(DeploymentStatus.FAILURE);
            status.setStageException(t);
            status.setStageStatusMessage(t.getMessage());
        }
    
private voidsendDisassociateEvent(com.sun.enterprise.deployment.backend.DeploymentRequest req)

        DeploymentTarget target = (DeploymentTarget)req.getTarget();
        
        String moduleType;
        
        if(req.isApplication()) {
            moduleType = null;
        } else {
            moduleType = DeploymentServiceUtils.getModuleTypeString(req.getType());
        }
        
        int eventType = com.sun.enterprise.admin.event.BaseDeployEvent.APPLICATION_UNREFERENCED;
        String appName = req.getName();
        String targetName = target.getTarget().getName();
        
        boolean success = DeploymentServiceUtils.multicastEvent(
                eventType,
                appName,
                moduleType,
                false,
                true,
                targetName);
        
        sLogger.log(Level.FINE, "sendDisassociateEvent: success=" + success);