FileDocCategorySizeDatePackage
PEDeploymentService.javaAPI DocGlassfish v2 API48785Thu Jun 28 08:08:34 BST 2007com.sun.enterprise.deployment.phasing

PEDeploymentService

public class PEDeploymentService extends DeploymentService
Manages the phases and maps deployment operations to deployment phases
author
deployment dev team

Fields Summary
public static final Logger
sLogger
Deployment Logger object for this class
private static final Logger
auditLogger
Deployment auditing logger
private static final ResourceBundle
auditBundle
Auditing resource bundle for message look-up
private static com.sun.enterprise.util.i18n.StringManager
localStrings
resource bundle
protected DeploymentContext
deploymentContext
context object that is used to share context with the phases
private List
deployToDomainPhaseList
phase list for deploy to domain operation
private List
undeployFromDomainPhaseList
phase list for undeploy from domain operation
private List
deployPhaseList
phase list for deploy operation
private List
undeployPhaseList
phase list for undeploy operation
private List
associatePhaseList
phase list for associate operation
private List
disassociatePhaseList
phase list for disassociate operation
private List
stopPhaseList
private List
startPhaseList
static final String
DISASSOCIATE_ACTION
static final String
REDEPLOY_ACTION
static final String
STOP_ACTION
static final String
UNDEPLOY_ACTION
Constructors Summary
public PEDeploymentService(com.sun.enterprise.config.ConfigContext configContext)
Creates a new instance of PEDeploymentService

param
configContext config context object


                      
       
    
        deploymentContext = new DeploymentContext();
        deploymentContext.setConfigContext(configContext);
        initializePhases();
    
Methods Summary
public com.sun.enterprise.deployment.backend.DeploymentStatusassociate(java.lang.String targetName, boolean enabled, java.lang.String virtualServers, java.lang.String referenceName)
This method is used to associate an application to a target. It constructs the DeploymentRequest using the parameters first.

        try {
            long startTime = System.currentTimeMillis();
            //FIXME: add validation code such as checking context root
            DeployableObjectType type = 
                DeploymentServiceUtils.getRegisteredType(referenceName);
        
            final DeploymentTarget target =
                DeploymentServiceUtils.getAndValidateDeploymentTarget(
                    targetName, referenceName, false);
            
            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.DEPLOY);

            /*
             * Force enabled to true for app client modules to address temporarily
             * issue 3248.
             */
            enabled = enabled || type.isCAR();
                
            req.setName(referenceName);
            req.setStartOnDeploy(enabled);
            req.setTarget(target);

            Properties optionalAttributes = new Properties();
            if(virtualServers!=null) {
                optionalAttributes.put(ServerTags.VIRTUAL_SERVERS, 
                    virtualServers);
            }
            req.setOptionalAttributes(optionalAttributes);
            return associate(req, createAuditInfoIfOn(req, AuditInfo.Operation.associate, startTime));
        } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
                throw new IASDeploymentException(e);
            }
        }
    
public com.sun.enterprise.deployment.backend.DeploymentStatusassociate(java.lang.String targetName, java.lang.String referenceName, java.util.Map options)
This method is used to associate an application to a target. It constructs the DeploymentRequest using the parameters first.

        try {
            long startTime = System.currentTimeMillis();
            DeployableObjectType type =
                DeploymentServiceUtils.getRegisteredType(referenceName);

            DeploymentProperties dProps = new DeploymentProperties(options);
            
            /*
             *A preexisting reference is allowed to exist if a redeployment 
             *is underway and the reference's attributes are not changing 
             *during the redeployment, so long as a
             *preceding disassociation phase has recorded this fact.
             */
            boolean enforceValidation = true;
            if (dProps.getRedeploy()) {
                /*
                 *Make sure this app ref was saved during an earlier disassociation.
                 */
                DeploymentContext.SavedApplicationRefInfo info = 
                        deploymentContext.getSavedAppRef(referenceName, targetName);
                enforceValidation = (info == null);
            }

            /*
             * Force enabled to true for app client modules to address temporarily
             * issue 3248.
             */
            if (type.isCAR()) {
                dProps.setEnable(true);
            }
            
            final DeploymentTarget target = enforceValidation ? 
                DeploymentServiceUtils.getAndValidateDeploymentTarget(
                    targetName, referenceName, false) :
                DeploymentServiceUtils.getDeploymentTarget(targetName);

            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.DEPLOY);

            String virtualServers = dProps.getVirtualServers();
            boolean enabled = dProps.getEnable();

            req.setName(referenceName);
            req.setStartOnDeploy(enabled);
            req.setTarget(target);
            req.setIsRedeployInProgress(dProps.getRedeploy());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            Properties optionalAttributes = new Properties();
            if(virtualServers!=null) {
                optionalAttributes.put(ServerTags.VIRTUAL_SERVERS,
                    virtualServers);
            }
            req.setOptionalAttributes(optionalAttributes);

            return associate(req, createAuditInfoIfOn(req, AuditInfo.Operation.associate, startTime));

        } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
                throw new IASDeploymentException(e);
            }
        }
    
private com.sun.enterprise.deployment.backend.DeploymentStatusassociate(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfo auditInfo)
Associates an application to a target.

param
req the DeploymentRequest
param
auditInfo the auditing information object that will audit this operation; null if no auditing desired
return
DeploymentStatus reporting the outcome of the operation

        DeploymentStatus result = executePhases(req, associatePhaseList);
        if (auditInfo != null) {
            auditInfo.reportEnd(result.getStatus());
        }
        return result;
    
public com.sun.enterprise.deployment.backend.DeploymentStatusassociate(com.sun.enterprise.deployment.backend.DeploymentRequest req)
This method is used to associate an application to a target.

param
req DeploymentRequest object

        return associate(req, createAuditInfoIfOn(req, AuditInfo.Operation.associate));
    
private com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfocreateAuditInfoIfOn(com.sun.enterprise.deployment.backend.DeploymentRequest req, AuditInfo.Operation operation)
Returns an instance of AuditInfo if the audit logging level mandates; null otherwise.

param
req the DeploymentRequest to be audited
param
operation the type of work being performed (deployment, undeployment, etc.)
return
AuditInfo or null, depending on the deployment audit logging level

        return auditLogger.isLoggable(Level.INFO) ? new AuditInfo(req, operation, System.currentTimeMillis()) : null;
    
private com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfocreateAuditInfoIfOn(com.sun.enterprise.deployment.backend.DeploymentRequest req, AuditInfo.Operation operation, long startTime)
Returns an instance of AuditInfo if the audit logging level mandates; null otherwise.

param
req the DeploymentRequest to be audited
param
operation the type of work being performed (deployment, undeployment, etc.)
param
startTime start time of the operation being audited (typically via System.currentTimeMillis() )
return
AuditInfo or null, depending on the deployment audit logging level

        return auditLogger.isLoggable(Level.INFO) ? new AuditInfo(req, operation, startTime) : null;
    
public com.sun.enterprise.deployment.backend.DeploymentStatusdeploy(java.io.File deployFile, java.io.File planFile, java.lang.String archiveName, java.lang.String moduleID, com.sun.enterprise.deployment.util.DeploymentProperties dProps, com.sun.enterprise.management.deploy.DeploymentCallback callback)
This method deploys application to the domain. It constructs the DeploymentRequest using the parameters first.

        try {
            if (deployFile == null) {
                throw new IASDeploymentException(
                localStrings.getString("deployfile_not_specified"));
            }

            /*
             *Save the current time to use in preparing the audit info later so
             *the audit measurement includes all the logic below.
             */
            long startTime = System.currentTimeMillis();
            sLogger.log(Level.FINE, "mbean.begin_deploy", moduleID);
            DeployableObjectType type = null;
            if (dProps.getType() != null) {
                type = DeploymentServiceUtils.getDeployableObjectType(dProps.getType());
            } else {
                type = DeploymentServiceUtils.getTypeFromFile(
                            moduleID, deployFile.getAbsolutePath());
            }                    

            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.DEPLOY);
    
            DeploymentRequestRegistry.getRegistry().addDeploymentRequest(
                moduleID, req);

            req.setName(moduleID);
            boolean isRegistered = false;
            isRegistered = DeploymentServiceUtils.isRegistered(moduleID, type);
            // FIXME validation for new REDEPLOY property

            if (isRegistered) {
                DeploymentServiceUtils.validate(moduleID,type,REDEPLOY_ACTION, req);
            }

            req.setFileSource(deployFile);
            req.setDeploymentPlan(planFile);
            req.setForced(dProps.getForce());
            if(type.isWEB()) {
                req.setDefaultContextRoot(dProps.getDefaultContextRoot(
                    archiveName));
                req.setContextRoot(dProps.getContextRoot());
            }
            req.setVerifying(dProps.getVerify());
            req.setPrecompileJSP(dProps.getPrecompileJSP());
            req.setGenerateRMIStubs(dProps.getGenerateRMIStubs());
            req.setAvailabilityEnabled(dProps.getAvailabilityEnabled());
            req.setStartOnDeploy(dProps.getEnable());
            req.setDescription(dProps.getDescription());
            req.setLibraries(dProps.getLibraries());
            req.setJavaWebStartEnabled(dProps.getJavaWebStartEnabled());
            req.setExternallyManagedPath(dProps.getExternallyManaged());
            req.setDeploymentCallback(callback);
            req.setIsRedeployInProgress(dProps.getRedeploy());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            Properties optionalAttributes = new Properties();
            String virtualServers = dProps.getVirtualServers();
            if(virtualServers!=null) {
                optionalAttributes.put(ServerTags.VIRTUAL_SERVERS,
                    virtualServers);
            }
            req.setOptionalAttributes(optionalAttributes);

            req.addOptionalArguments(dProps.prune());
            DeploymentServiceUtils.setHostAndPort(req);
            return deploy(req, createAuditInfoIfOn(req, AuditInfo.Operation.deploy, startTime));
        } catch(Exception e) {
            sLogger.log(Level.WARNING, "mbean.deploy_failed", e);
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
                throw new IASDeploymentException(e);
            }
        }
    
private com.sun.enterprise.deployment.backend.DeploymentStatusdeploy(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfo auditInfo)

        // deploy to instance 
        DeploymentStatus result = null;
        if (req.getTarget() != null && 
            !req.getTarget().getName().equals("domain")) {
            result = executePhases(req, getDeployPhaseListForTarget(req));	
        // deploy to domain
        } else {
            result = executePhases(req, deployToDomainPhaseList);
        }
        if (auditInfo != null) {
            auditInfo.reportEnd(result.getStatus());
        }
        return result;
    
public com.sun.enterprise.deployment.backend.DeploymentStatusdeploy(com.sun.enterprise.deployment.backend.DeploymentRequest req)
This method deploys application to the DAS. Prepares the app, stores it in central repository and registers with config

param
req DeploymentRequest object

        return deploy(req, createAuditInfoIfOn(req, AuditInfo.Operation.deploy));
    
private com.sun.enterprise.deployment.backend.DeploymentStatusdisassociate(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfo auditInfo)

        String moduleID = req.getName();
        DeployableObjectType type = req.getType();
        DeploymentServiceUtils.validate(moduleID,type,DISASSOCIATE_ACTION, req);

        DeploymentStatus result = executePhases(req, disassociatePhaseList);
        if (auditInfo != null) {
            auditInfo.reportEnd(result.getStatus());
        }
        return result;
    
public com.sun.enterprise.deployment.backend.DeploymentStatusdisassociate(com.sun.enterprise.deployment.backend.DeploymentRequest req)
This method removes references of an application on a particular target

param
req DeploymentRequest object

        return disassociate(req, createAuditInfoIfOn(req, AuditInfo.Operation.disassociate));
    
public com.sun.enterprise.deployment.backend.DeploymentStatusdisassociate(java.lang.String targetName, java.lang.String referenceName)
This method removes references of an application on a particular target It constructs the DeploymentRequest using the parameters first.

        try {   
            long startTime = System.currentTimeMillis();
            DeployableObjectType type =
                DeploymentServiceUtils.getRegisteredType(referenceName);
            
            final DeploymentTarget target =
                DeploymentServiceUtils.getAndValidateDeploymentTarget(
                targetName, referenceName, true);
                
            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.UNDEPLOY);

            req.setName(referenceName);
            req.setTarget(target);
        
            return disassociate(req, createAuditInfoIfOn(req, AuditInfo.Operation.disassociate, startTime));
        } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
               throw new IASDeploymentException(e);
            }
        }
    
public com.sun.enterprise.deployment.backend.DeploymentStatusdisassociate(java.lang.String targetName, java.lang.String referenceName, java.util.Map options)

        try {
            long startTime = System.currentTimeMillis();
            DeployableObjectType type = 
                DeploymentServiceUtils.getRegisteredType(referenceName);

            final DeploymentTarget target =
                DeploymentServiceUtils.getAndValidateDeploymentTarget(
                targetName, referenceName, true);

            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.UNDEPLOY);

            req.setName(referenceName);
            req.setTarget(target);

            DeploymentProperties dProps = new DeploymentProperties(options);
            req.setCascade(dProps.getCascade());
            req.setForced(dProps.getForce());
            req.setExternallyManagedPath(dProps.getExternallyManaged());
            req.setIsRedeployInProgress(dProps.getRedeploy());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            return disassociate(req, createAuditInfoIfOn(req, AuditInfo.Operation.disassociate, startTime));
        } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
                throw new IASDeploymentException(e);
            }
        }
    
protected com.sun.enterprise.deployment.backend.DeploymentStatusexecutePhases(com.sun.enterprise.deployment.backend.DeploymentRequest req, java.util.List phases)
utility method to succesively invoke DeploymentPhases instances provided as a list and rollback them in case of an exception during one of the phase execution

Note - after the phases are executed executePhases invokes the done method on the DeploymentRequest to release its resources, in particular the EJBClassLoaders. The DeploymentRequest cannot be reused for another deployment upon return from executePhases.

param
DeploymentRequest the request to be served
param
phases is the @see List of phases to execute

        try {
            Descriptor.setBoundsChecking(true);

            // first we create our deployment status to return feedback to the user
            DeploymentStatus ds = new DeploymentStatus();
            ds.setStageDescription("Deployment");
            req.setCurrentDeploymentStatus(ds);

            DeploymentPhaseContext phaseCtx[] = new DeploymentPhaseContext[phases.size()]; 
            for(int i=0 ; i < phases.size() ; i++)
            {
                try{            
                    // create a new status for this phase
                    DeploymentStatus phaseDs = new DeploymentStatus(ds);

                    // execute the phase
                    phaseCtx[i] = ((DeploymentPhase)phases.get(i)).executePhase(req, phaseDs);

                    // if the previous phase did not excecute successfully.
                    // we need to allow previous phases to rollback.
                    if (phaseDs.getStageStatus()<DeploymentStatus.WARNING) {
                        rollbackPhases(phases, phaseCtx, i-1);
                        // return main deployment status
                        return ds;
                    }

                } catch(Throwable dpe) {
                    // an exception has occured in the I'th phase, we need to rollback
                    // all previously executed phases (and ignore any failures that may
                    // be raised by this rollback).

                    String msg = 
                        localStrings.getString( "enterprise.deployment.phasing.deploymentservice.exception");
                    sLogger.log(Level.SEVERE, msg ,dpe);
                    rollbackPhases(phases, phaseCtx, i-1);

                    // we register the original exception as it was raised
                    // by the executePhase method in our deployment status
                    ds.setStageStatus(DeploymentStatus.FAILURE);
                    if (dpe instanceof java.io.Serializable) {
                        ds.setStageException(dpe);
                    } else {
                        sLogger.severe(localStrings.getString("enterprise.deployment.phasing.exception_notserializable", dpe.getClass()));
                        sLogger.severe(localStrings.getString("enterprise.deployment.phasing.exception_notforwarded", dpe.getMessage()));
                    }                
                    ds.setStageException(dpe);
                    ds.setStageStatusMessage(dpe.getMessage());
                    return ds;
                }
            }
            // we do not set the state of the deployment status
            // since it will be provided by the sub phases status.
            return ds;
        } finally {
            req.done();
        }
    
public static java.lang.StringgetClientJarPath(java.lang.String moduleID)

return
the path for the client jar file of a deployed application

        
        // let's ensure first that our client jar is ready.
        ClientJarMakerRegistry registry = ClientJarMakerRegistry.getInstance();
        
        if (registry.isRegistered(moduleID)) {
            
            // let's wait until it is finished.
            registry.waitForCompletion(moduleID);
        }
        
        return moduleID + DeploymentImplConstants.ClientJarSuffix;
        
    
protected java.util.ListgetDeployPhaseListForTarget(com.sun.enterprise.deployment.backend.DeploymentRequest req)


        if (deployPhaseList != null) {
            return deployPhaseList;
        }

        //XXX FIXME.  Need to verify the type of the target.
        J2EECPhase j2eec = new J2EECPhase(deploymentContext);
        AssociationPhase associate = new AssociationPhase(deploymentContext);
        ResourceAdapterStartPhase raStart = 
            new ResourceAdapterStartPhase(deploymentContext);
        ApplicationStartPhase appStart = 
            new ApplicationStartPhase(deploymentContext);
        PreResCreationPhase preResCreation = 
            new PreResCreationPhase(deploymentContext);
        PostResCreationPhase postResCreation = 
            new PostResCreationPhase(deploymentContext);

        //(re)deploy phaseList
        deployPhaseList = new ArrayList();
        deployPhaseList.add(j2eec);
        deployPhaseList.add(associate);
        deployPhaseList.add(preResCreation);
        deployPhaseList.add(raStart);
        deployPhaseList.add(postResCreation);
        deployPhaseList.add(appStart);
        return deployPhaseList; 
    
public java.lang.StringgetModuleIDFromDD(java.io.File file)
This method finds moduleID by explicitly loading the dd for its display name. This method is called by the DeployThread if and only if the client uses JSR88.distribute with InputStream signature.

@
todo: Ideally we do not want to load the deployment descriptor more than once. This one is a necessary evil since we need the moduleID *now* before proceeding with the rest of deployment. Bigger re-construction is needed if we want to optimize deployment further for JSR88 using InputStream. NOTE that we choose to load the dd and use the display name as the moduleID instead of the uploaded file name for backward compatibility and clarity (uploaded file name is not descriptive).
param
file the deployed file
return
the moduleID derived from this file using the dd's display name

        Archivist source = ArchivistFactory.getArchivistForArchive(file);
        InputJarArchive archive = new InputJarArchive();
        archive.open(file.getAbsolutePath());
        Descriptor descriptor = null;
        String moduleID = null;
        String displayName = null;
        try {
            descriptor = source.readStandardDeploymentDescriptor(archive);
        } catch (Exception ex) { 
            //ignore 
        }
        if (descriptor != null) {
            displayName = descriptor.getDisplayName();
        }
        if ((displayName != null) && (displayName.length() > 0)) {
            moduleID = displayName;
        } else {
            //We give up.  Use the uploaded file name instead
            moduleID = 
                (new DeploymentProperties()).getName(file.getAbsolutePath());
        }

        moduleID = moduleID.replace(' ",'_");

        // This moduleID will be later used to construct file path,
        // replace the illegal characters in file name
        //  \ / : * ? " < > | with _
        moduleID = moduleID.replace('\\", '_").replace('/", '_");
        moduleID = moduleID.replace(':", '_").replace('*", '_");
        moduleID = moduleID.replace('?", '_").replace('"", '_");
        moduleID = moduleID.replace('<", '_").replace('>", '_");
        moduleID = moduleID.replace('|", '_");

        // This moduleID will also be used to construct an ObjectName 
        // to register the module, so replace additional special 
        // characters , =  used in property parsing with -
        moduleID = moduleID.replace(',", '_").replace('=", '_");

        return moduleID;
    
private voidinitializePhases()
Initializes phaseList corresponding to deploy operations. Each phase is initialized with a deploymentContext object. Deployment operations that are intialized are deploy/undeploy/associate/disassociate.

        J2EECPhase j2eec = new J2EECPhase(deploymentContext);
        AssociationPhase associate = new AssociationPhase(deploymentContext);
        DisassociationPhase disassociate = new DisassociationPhase(deploymentContext);
        UndeployFromDomainPhase undeploy = new UndeployFromDomainPhase(deploymentContext);
        ResourceAdapterStartPhase raStart = 
            new ResourceAdapterStartPhase(deploymentContext);
        ApplicationStartPhase appStart = 
            new ApplicationStartPhase(deploymentContext);
        PreResCreationPhase preResCreation = 
            new PreResCreationPhase(deploymentContext);
        PostResCreationPhase postResCreation = 
            new PostResCreationPhase(deploymentContext);

        ResourceAdapterStopPhase raStop =
            new ResourceAdapterStopPhase(deploymentContext);
        ApplicationStopPhase appStop =
            new ApplicationStopPhase(deploymentContext);
        PreResDeletionPhase preResDeletion = 
            new PreResDeletionPhase(deploymentContext);
        PostResDeletionPhase postResDeletion = 
            new PostResDeletionPhase(deploymentContext);

        //(re)deploy to domain phaseList
        deployToDomainPhaseList = new ArrayList();
        //for special case (re)deploy to domain
        deployToDomainPhaseList.add(preResDeletion);
        deployToDomainPhaseList.add(postResDeletion);
        deployToDomainPhaseList.add(j2eec);
        deployToDomainPhaseList.add(preResCreation);
        deployToDomainPhaseList.add(postResCreation);
        
        //associate phaseList
        associatePhaseList = new ArrayList();
        associatePhaseList.add(associate);
        
        //disassociate phaseList
        disassociatePhaseList = new ArrayList();
        disassociatePhaseList.add(disassociate);
        
        //undeploy phaseList
        undeployPhaseList = new ArrayList();        
        undeployPhaseList.add(appStop);
        undeployPhaseList.add(preResDeletion);
        undeployPhaseList.add(raStop);
        undeployPhaseList.add(postResDeletion);
        undeployPhaseList.add(disassociate);
        undeployPhaseList.add(undeploy);
        
        //undeploy from domain phaseList
        undeployFromDomainPhaseList = new ArrayList();
        undeployFromDomainPhaseList.add(preResDeletion);
        undeployFromDomainPhaseList.add(postResDeletion);
        undeployFromDomainPhaseList.add(undeploy);

        startPhaseList = new ArrayList();
        startPhaseList.add(preResCreation);
        startPhaseList.add(raStart);
        startPhaseList.add(postResCreation);
        startPhaseList.add(appStart);
        
        stopPhaseList = new ArrayList();
        stopPhaseList.add(appStop);
        stopPhaseList.add(preResDeletion);
        stopPhaseList.add(raStop);
        stopPhaseList.add(postResDeletion);
    
public booleanquit(java.lang.String moduleID)

        DeploymentRequest request = DeploymentRequestRegistry.getRegistry().getDeploymentRequest(moduleID);
        if (request != null) {
            request.setAbort(true);
            return true;
        } else {
            return false;
        }
    
private voidrollbackPhases(java.util.List phases, DeploymentPhaseContext[] phaseCtx, int index)
Rollback previously excuted phases

        // now we are going to rollback all the previously executed phases
        for (int j=index; j>=0 ; j--) {
            try {
                ((DeploymentPhase)phases.get(j)).rollback(phaseCtx[j]);
            } catch(Exception rollbackException) {
                // it failed ! just log
                String msg =
                    localStrings.getString( "enterprise.deployment.phasing.deploymentservice.rollbackexception");
                sLogger.log(Level.INFO, msg ,rollbackException);
                // we swallow the exception to allow all phases to execute their
                // rollback
                
            }
        }
        
    
private com.sun.enterprise.deployment.backend.DeploymentStatusstart(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfo auditInfo)

        DeploymentStatus result = executePhases(req, startPhaseList);
        if (auditInfo != null) {
            auditInfo.reportEnd(result.getStatus());
        }
        return result;
    
public com.sun.enterprise.deployment.backend.DeploymentStatusstart(com.sun.enterprise.deployment.backend.DeploymentRequest req)

        return start(req, createAuditInfoIfOn(req, AuditInfo.Operation.start));
    
public com.sun.enterprise.deployment.backend.DeploymentStatusstart(java.lang.String moduleID, java.lang.String targetName, java.util.Map options)

        try {
            long startTime = System.currentTimeMillis();
            DeployableObjectType type =
                DeploymentServiceUtils.getRegisteredType(moduleID);
        
            final DeploymentTarget target =
                DeploymentServiceUtils.getDeploymentTarget(targetName);
            
            InstanceEnvironment env = 
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.DEPLOY);

            int actionCode;
            if(type.isAPP()) {
                actionCode = BaseDeployEvent.APPLICATION_DEPLOYED;
            }
            else {
                actionCode = BaseDeployEvent.MODULE_DEPLOYED;
            }
    
            req.setName(moduleID);
            req.setActionCode(actionCode);
            req.setTarget(target);

            DeploymentProperties dProps = new DeploymentProperties(options);
            req.setForced(dProps.getForce());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            return start(req, createAuditInfoIfOn(req, AuditInfo.Operation.start, startTime));
       } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
                throw new IASDeploymentException(e);
            }
        }
    
private com.sun.enterprise.deployment.backend.DeploymentStatusstop(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfo auditInfo)

        String moduleID = req.getName();
        DeployableObjectType type = req.getType();
        DeploymentServiceUtils.validate(moduleID,type,STOP_ACTION, req);

        DeploymentStatus result = executePhases(req, stopPhaseList);
        if (auditInfo != null) {
            auditInfo.reportEnd(result.getStatus());
        }
        return result;
    
public com.sun.enterprise.deployment.backend.DeploymentStatusstop(com.sun.enterprise.deployment.backend.DeploymentRequest req)

        return stop(req, createAuditInfoIfOn(req, AuditInfo.Operation.stop));
    
public com.sun.enterprise.deployment.backend.DeploymentStatusstop(java.lang.String moduleID, java.lang.String targetName, java.util.Map options)

        try {
            long startTime = System.currentTimeMillis();
            DeployableObjectType type =
                DeploymentServiceUtils.getRegisteredType(moduleID);
     
            final DeploymentTarget target =
                DeploymentServiceUtils.getDeploymentTarget(targetName);
        
            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(
                                    env,
                                    type,
                                    DeploymentCommand.UNDEPLOY);
                
            int actionCode;
            if(type.isAPP()) {
                actionCode = BaseDeployEvent.APPLICATION_UNDEPLOYED;
            }   
            else {
                actionCode = BaseDeployEvent.MODULE_UNDEPLOYED;
            }                       
                                    
            req.setName(moduleID);
            req.setActionCode(actionCode);
            req.setTarget(target);

            DeploymentProperties dProps = new DeploymentProperties(options);
            req.setCascade(dProps.getCascade());
            req.setForced(dProps.getForce());
            req.setExternallyManagedPath(dProps.getExternallyManaged());
            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            return stop(req, createAuditInfoIfOn(req, AuditInfo.Operation.stop, startTime));
        } catch(Exception e) {
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
                throw new IASDeploymentException(e);
            }
        }
    
public com.sun.enterprise.deployment.backend.DeploymentStatusundeploy(java.lang.String mModuleID, java.util.Map mParams)
This method undeploys application from domain. It constructs the DeploymentRequest using the parameters first.

        sLogger.log(Level.FINE, "mbean.begin_undeploy", mModuleID);
        try {
            /*
             *Save the current time to use in preparing the audit info later so
             *the audit measurement includes all the logic below.
             */
            long startTime = System.currentTimeMillis();
            DeployableObjectType objectType = 
                DeploymentServiceUtils.getRegisteredType(mModuleID);

            DeploymentServiceUtils.checkAppReferencesBeforeUndeployFromDomain(
                mModuleID);

            if (objectType.isWEB()) {
                DeploymentServiceUtils.checkWebModuleReferences(mModuleID);
            }

            InstanceEnvironment env =
                ApplicationServer.getServerContext().getInstanceEnvironment();
            DeploymentRequest req = new DeploymentRequest(env,
                objectType, DeploymentCommand.UNDEPLOY);

            DeploymentRequestRegistry.getRegistry().addDeploymentRequest(
                mModuleID, req);

            DeploymentProperties dProps =
                new DeploymentProperties(mParams);
            req.setName(mModuleID);
            req.setCascade(dProps.getCascade());
            req.setExternallyManagedPath(dProps.getExternallyManaged());

            DeploymentServiceUtils.setResourceOptionsInRequest(req, dProps);

            req.addOptionalArguments(dProps.prune());
            return undeploy(req, createAuditInfoIfOn(req, AuditInfo.Operation.undeploy, startTime));
        }
        catch(Exception e) {
            String msg = localStrings.getString(
            "enterprise.deployment.phasing.deploymentservice.undeploy.failed",
            mModuleID, e.getLocalizedMessage());
            sLogger.log(Level.WARNING, msg);
            if (e instanceof IASDeploymentException) {
                throw (IASDeploymentException)e;
            }
            else {
                IASDeploymentException ias = 
                    new IASDeploymentException(e.getLocalizedMessage());
                ias.initCause(e);
                throw ias;
            }
        }
    
public com.sun.enterprise.deployment.backend.DeploymentStatusundeploy(com.sun.enterprise.deployment.backend.DeploymentRequest req)
This method undeploys application from DAS. Removes the application from central repository and unregisters the application from config

param
req DeploymentRequest object

        return undeploy(req, createAuditInfoIfOn(req, AuditInfo.Operation.undeploy));
    
private com.sun.enterprise.deployment.backend.DeploymentStatusundeploy(com.sun.enterprise.deployment.backend.DeploymentRequest req, com.sun.enterprise.deployment.phasing.PEDeploymentService$AuditInfo auditInfo)
This method undeploys application from DAS. Removes the application from central repository and unregisters the application from config, with auditing if turned on.

param
req DeploymentRequest object
param
auditInfo the AuditInfo object, if any, to be used for auditing this operation

        DeploymentStatus result = null;
        //Re-record instrospect/instrument/verifier data if
        //any of the application is un-deployed
        if (AppVerification.doInstrument()) {
            AppVerification.getInstrumentLogger().handleChangeInDeployment();
        }

        String moduleID = req.getName();
        DeployableObjectType type = req.getType();
        DeploymentServiceUtils.validate(moduleID, type, UNDEPLOY_ACTION, req);

        // undeploy from DAS
        if (req.getTarget() != null) {
            result = executePhases(req, undeployPhaseList);	
        // undeploy from domain
         } else {
            result = executePhases(req, undeployFromDomainPhaseList);
        }
        if (auditInfo != null) {
            auditInfo.reportEnd(result.getStatus());
        }
        return result;