FileDocCategorySizeDatePackage
AppUnDeployer.javaAPI DocGlassfish v2 API8918Fri May 04 22:34:30 BST 2007com.sun.enterprise.deployment.backend

AppUnDeployer

public class AppUnDeployer extends AppDeployerBase
AppUnDeployer is responsible for Undeploying Applications.
author
bnevins
version

Fields Summary
private String
failureMessage
private String
successMessage
private boolean
isMaybeCMPDropTables
private com.sun.enterprise.deployment.Application
applicationDD
private static com.sun.enterprise.util.i18n.StringManager
localStrings
Constructors Summary
AppUnDeployer(DeploymentRequest r)

		super(r);
	
Methods Summary
public voidcleanup_internal()
Attempt to delete the deployed directory-tree.

This method call is guaranteed to never throw any kind of Exception

        try {
            if(isMaybeCMPDropTables)
                dropTables();
            
            liquidate();
        }
        catch(Exception e) {
            logger.warning("Caught an Exception in cleanup_internal: " + e);
        }
    
public voiddoRequest()

		doRequestPrepare();
		doRequestFinish();
	
public voiddoRequestFinish()

		try
		{
			predeploy();
			localBegin();	// sets cmp drop table variables
			undeploy();
    removePolicy();    
		}
		catch(IASDeploymentException e)
		{
			throw e;
		}
		catch(Exception e)
		{
			String msg = localStrings.getString(
					"enterprise.deployment.backend.dorequest_exception");
			logger.log(Level.WARNING, msg, e);
			throw new IASDeploymentException(msg, e);
		}
		finally
		{
			finish();
		}
	
public voiddoRequestPrepare()

		try
		{
			begin();
		}
		catch(IASDeploymentException e)
		{
			throw e;
		}
		catch(Exception e)
		{
			String msg = localStrings.getString(
					"enterprise.deployment.backend.dorequest_exception");
			logger.log(Level.WARNING, msg, e);
			throw new IASDeploymentException(msg, e);
		}
	
private voiddropTables()
Call into CMP to drop tables. This is called just before files are deleted as part of the cleanup() call. We do it very late in the process since dropping tables can't be rolled-back. Thus all of the other steps that can have errors that require a rollback have already been done successfully - or we wouldn't be here. bnevins April 2003

This method call is guaranteed to never throw any kind of Exception

        assert isMaybeCMPDropTables; // programmer error if this is false!
        
        try {
            DeploymentEventInfo info = new DeploymentEventInfo(getAppDir(),
                getStubsDir(), applicationDD, getRequest());
            DeploymentEvent ev = new DeploymentEvent(DeploymentEventType.PRE_UNDEPLOY, info);
            DeploymentEventManager.notifyDeploymentEvent(ev);
        }
        catch(Throwable t) {
            logger.warning("Caught a Throwable in dropTables: " + t);
        }
    
private voidlocalBegin()
localBegin -- if we need to drop cmp tables later, create an Application object NOW before the registration information disappears. The reason we don't drop the tables now is that it can NOT be rolled back. So we delay doing it as long as possible -- which is just before the files are deleted.

        // Why is this stuff complicating localBegin() when it could simply be called
        // from cleanup_internal()?  Because there may be problems with doing the actual
        // drop tables late in the process (namely after unregistering.  If that turns out to be the
        // case then the drop tables call will be moved here.  If not, we can clean this code up by
        // moving it into dropTables() later.
        // bnevins April 2003
        
        try {
            if(getRequest().isMaybeCMPDropTables()) {
                isMaybeCMPDropTables = true;

                //  first let's try to get the application from the
                // instance manager cache
                // if it's not there, get it from the request which
                // is set through deployment context cache
                applicationDD = getManager().getRegisteredDescriptor(getAppName());
                if (applicationDD == null) {
                    applicationDD = request.getDescriptor();
                }
            }
        }
        catch(Exception e) {
            logger.warning("Caught an Exception in localBegin: " + e);
        }
    
protected final java.io.FilesetAppDir()

        try {
            return new File(DeploymentServiceUtils.getLocation(getAppName(), 
                request.getType()));
        }
        catch(Exception e) {
            String msg = localStrings.getString(
            "enterprise.deployment.backend.error_getting_app_directory",
            e);
            throw new IASDeploymentException(msg, e);
        }
    
private voidundeploy()

        try {
            getManager().unregisterDescriptor(getAppName());
            addToSummary(successMessage + getAppName());
        }
        catch(Exception e) {
            if(e instanceof IASDeploymentException)
                throw (IASDeploymentException)e;
            else
                throw new IASDeploymentException(e);
        }