FileDocCategorySizeDatePackage
DeploymentEventListenerImpl.javaAPI DocGlassfish v2 API9910Fri May 04 22:34:48 BST 2007com.sun.jdo.spi.persistence.support.ejb.ejbc

DeploymentEventListenerImpl

public class DeploymentEventListenerImpl extends Object implements com.sun.jdo.spi.persistence.utility.database.DatabaseConstants, com.sun.enterprise.deployment.backend.DeploymentEventListener
Implementation of the DeploymentEventListener interface for creating and dropping database schema definitions at the appropriate deployment/undeployment events.

Fields Summary
private static final ResourceBundle
messages
I18N message handler
private static com.sun.jdo.spi.persistence.utility.logging.Logger
logger
The logger
Constructors Summary
DeploymentEventListenerImpl()
Default constructor should not be public


                  
     
        DeploymentEventManager.addListener (new DeploymentEventListenerImpl());
     
Methods Summary
private booleanisDeploy(com.sun.enterprise.deployment.backend.DeploymentRequest request)
This method returns a boolean value that determines if we are trying to do a deployment of an existing application but doesn't throw an exception.

param
request the deployment request object
return
true if we are trying to redeploy an existing application

        boolean deploy = false;
        try {
            if (request != null) {
                deploy = request.isDeploy();
            }
        } catch (IASDeploymentException e) {
            // Ignore? This is a strange exception.
        }
        return deploy;
    
private booleanisRedeploy(com.sun.enterprise.deployment.backend.DeploymentRequest request)
This method returns a boolean value that determines if we are trying to do a redeployment of an existing application but doesn't throw an exception.

param
request the deployment request object
return
true if we are trying to redeploy an existing application

        boolean redeploy = false;
        try {
            if (request != null) {
                redeploy = request.isReDeploy();
            }
        } catch (IASDeploymentException e) {
            // Ignore? This is a strange exception.
        }
        return redeploy;
    
public voidnotifyDeploymentEvent(com.sun.enterprise.deployment.backend.DeploymentEvent event)
This method is called when a DeploymentEventManager needs to deliver a code>DeploymentEvent event.

param
event the DeploymentEvent to be delivered.

        int type = event.getEventType();
        switch (type) {
            case DeploymentEvent.POST_DEPLOY:
                processEvent(event.getEventInfo(), true);
                break;
            case DeploymentEvent.PRE_UNDEPLOY:
            case DeploymentEvent.PRE_DEPLOY:
                processEvent(event.getEventInfo(), false);
                break;
            default:
                break;
        }
    
private voidprocessApplication(com.sun.enterprise.deployment.backend.DeploymentRequest request, com.sun.enterprise.deployment.backend.DeploymentEventInfo info, boolean create, java.lang.String cliCreateTables, java.lang.String cliDropAndCreateTables, java.lang.String cliDropTables)
This is the method that does the actual processing of the deployment event. For each application process the cmp 2.x beans if any followed by processing the ejb 3.0 beans.

param
request the deployment request object
param
info the event source
param
create true if we need to create tables as part of this event.
param
cliCreateTables the cli option for creating tables
param
cliDropAndCreateTables the cli option for dropping old tables and creating new tables
param
cliDropTables the cli option to drop tables at undeploy time

        
        if (logger.isLoggable(logger.FINE)) {
            logger.fine("ejb.DeploymentEventListenerImpl.processingevent", //NOI18N
                (isRedeploy(request)? "redeploy" : ((create)? "deploy" : "undeploy")), //NOI18N
                info.getApplicationDescriptor().getRegistrationName()); 
        }
        
        // Get status value for our use and initialize it.
        DeploymentStatus status = request.getCurrentDeploymentStatus();
        status.setStageStatus(DeploymentStatus.SUCCESS);
        status.setStageStatusMessage(""); 
        
        BaseProcessor processor =
                new CMPProcessor(info, create, cliCreateTables,
            cliDropAndCreateTables, cliDropTables);
        processor.processApplication();

        processor  =
                new PersistenceProcessor(info, create, cliCreateTables,
            cliDropAndCreateTables, cliDropTables);
        processor.processApplication();
    
private voidprocessEvent(com.sun.enterprise.deployment.backend.DeploymentEventInfo info, boolean create)
Event handling.

param
source the event source.
param
create true if we need to create tables as part of this event.

        // Get the CLI overrides.
        String cliCreateTables = null;
        String cliDropTables = null;

        DeploymentRequest request = info.getDeploymentRequest();

        // Do nothing for drop tables on the deploy
        if (isDeploy(request) && !create) {
            return;
        }

        Properties cliOverrides = request.getOptionalArguments();

        String cliDropAndCreateTables = cliOverrides.getProperty(
                Constants.CMP_DROP_AND_CREATE_TABLES, Constants.UNDEFINED);

        if (create) {
            cliCreateTables = cliOverrides.getProperty(
                Constants.CMP_CREATE_TABLES, Constants.UNDEFINED);

            if (cliCreateTables.equals(Constants.UNDEFINED)) {
                // It might have been specified as CMP_DROP_AND_CREATE_TABLES.
                cliCreateTables = cliDropAndCreateTables;
            }
        } else {
            cliDropTables = cliOverrides.getProperty(
                Constants.CMP_DROP_TABLES, Constants.UNDEFINED);
        }

        Application application = info.getApplicationDescriptor();
        if ( application == null) {
            return;
        }

        processApplication(request, info, create, cliCreateTables,
            cliDropAndCreateTables, cliDropTables);