FileDocCategorySizeDatePackage
EEWebContainerAdminEventProcessor.javaAPI DocGlassfish v2 API10094Fri May 04 22:36:02 BST 2007com.sun.enterprise.web

EEWebContainerAdminEventProcessor

public class EEWebContainerAdminEventProcessor extends Object implements WebContainerAdminEventProcessor
author
lwhite

Fields Summary
protected static Logger
_logger
The logger to use for logging ALL web container related messages.
protected static ResourceBundle
_rb
The resource bundle containing the message strings for _logger.
protected EmbeddedWebContainer
_embedded
The embedded Catalina object.
private static Hashtable
_deployHistory
Hashtable to keep track of deploy / undeploy events timing HERCULES:add
Constructors Summary
public EEWebContainerAdminEventProcessor()
Creates a new instance of EEWebContainerAdminEventProcessor

    
           
      
        if (_logger == null) {
            _logger = LogDomains.getLogger(LogDomains.WEB_LOGGER);
            _rb = _logger.getResourceBundle();
        }        
    
public EEWebContainerAdminEventProcessor(EmbeddedWebContainer embedded)
Creates a new instance of EEWebContainerAdminEventProcessor

        _embedded = embedded;
        if (_logger == null) {
            _logger = LogDomains.getLogger(LogDomains.WEB_LOGGER);
            _rb = _logger.getResourceBundle();
        }        
    
Methods Summary
public voidapplicationDeployed(com.sun.enterprise.admin.event.ApplicationDeployEvent deployEvent)

        String deployedAppName = deployEvent.getApplicationName();
        _logger.finest("applicationDeployed:" + deployedAppName);
        String key = "App_" + deployedAppName;
        
        boolean deployedRecently = checkDeployHistoryEntry(key, "deployed");
        setDeployHistoryEntry(key, "deployed", System.currentTimeMillis());
        if (deployedRecently) {
            _logger.finest("Returning from MIDDLE of applicationDeployed");
            return;
        }        
    
public voidapplicationDisabled(com.sun.enterprise.admin.event.ApplicationDeployEvent deployEvent)

    
public voidapplicationEnabled(com.sun.enterprise.admin.event.ApplicationDeployEvent deployEvent)

    
public voidapplicationRedeployed(com.sun.enterprise.admin.event.ApplicationDeployEvent deployEvent)

        String deployedAppName = deployEvent.getApplicationName();
        _logger.finest("applicationRedeployed:" + deployedAppName);
        
        String key = "App_" + deployedAppName;
        boolean redeployedRecently = checkDeployHistoryEntry(key, "redeployed");
        setDeployHistoryEntry(key, "redeployed", System.currentTimeMillis());
        if (redeployedRecently) {
            _logger.finest("Returning from MIDDLE of applicationRedeployed");
            return;
        }
    
public voidapplicationUndeployed(com.sun.enterprise.admin.event.ApplicationDeployEvent deployEvent)

        String deployedAppName = deployEvent.getApplicationName();
        _logger.finest("applicationUndeployed:" + deployedAppName);
        
        String key = "App_" + deployedAppName;
        boolean undeployedRecently = checkDeployHistoryEntry(key, "undeployed");
        setDeployHistoryEntry(key, "undeployed", System.currentTimeMillis());
        if (undeployedRecently) {
            _logger.finest("Returning from MIDDLE of applicationUndeployed");
            return;
        }
    
private booleancheckDeployHistoryEntry(java.lang.String key, java.lang.String deployStatus)
This method returns true if the application/module is attempted to be undeployed even though it was already undeployed, or is attempted to be (re)deployed when it was (re)deployed within the last 1 minute (60000 ms)

param
key identifies an application or module
param
deployStatus may have one of the following values : 'deployed', 'undeployed', 'redeployed'. HERCULES:add

        DeployHistoryEntry entry = (DeployHistoryEntry) _deployHistory.get(key);
        if (entry == null) {
            return false;
        }
        String val = entry.value;
        if (val.equals(deployStatus)) {
            /*if (deployStatus.equals("undeployed")) {
                    return true; // no need to check timestamp
            }*/
            if (( System.currentTimeMillis() - entry.lat ) < 60000) {
                    return true;
            }
        }
        return false;
    
public voidinit(EmbeddedWebContainer embedded)

        _embedded = embedded;
    
public voidmoduleDeployed(com.sun.enterprise.admin.event.ModuleDeployEvent deployEvent)

        String deployedModuleName = deployEvent.getModuleName();
        _logger.finest("moduleDeployed:" + deployedModuleName);

        String key = "Mod_" + deployedModuleName;
        boolean deployedRecently = checkDeployHistoryEntry(key, "deployed");
        setDeployHistoryEntry(key, "deployed", System.currentTimeMillis());
        if (deployedRecently) {
            _logger.finest("Returning from MIDDLE of moduleDeployed");	
            return;
        }
                
        ConnectionShutdownUtil shutdownUtil = new ConnectionShutdownUtil(_embedded);
        shutdownUtil.runCloseAllConnections();
        System.gc();
    
public voidmoduleDisabled(com.sun.enterprise.admin.event.ModuleDeployEvent deployEvent)

    
public voidmoduleEnabled(com.sun.enterprise.admin.event.ModuleDeployEvent deployEvent)

    
public voidmoduleRedeployed(com.sun.enterprise.admin.event.ModuleDeployEvent deployEvent)

        String deployedModuleName = deployEvent.getModuleName();
        _logger.finest("moduleRedeployed:" + deployedModuleName);

        String key = "Mod_" + deployedModuleName;
        boolean redeployedRecently = checkDeployHistoryEntry(key, "redeployed");
        setDeployHistoryEntry(key, "redeployed", System.currentTimeMillis());
        if (redeployedRecently) {
            _logger.finest("Returning from MIDDLE of moduleRedeployed");
            return;
        }
                
        ConnectionShutdownUtil shutdownUtil = new ConnectionShutdownUtil(_embedded);
        shutdownUtil.runCloseAllConnections();
        System.gc();
    
public voidmoduleUndeployed(com.sun.enterprise.admin.event.ModuleDeployEvent deployEvent)

        String deployedModuleName = deployEvent.getModuleName();
        _logger.finest("moduleUndeployed:" + deployedModuleName);

        String key = "Mod_" + deployedModuleName;
        boolean undeployedRecently = checkDeployHistoryEntry(key, "undeployed");
        setDeployHistoryEntry(key, "undeployed", System.currentTimeMillis());
        if (undeployedRecently) {
            _logger.finest("Returning from MIDDLE of moduleUndeployed");
            return;
        }

        ConnectionShutdownUtil shutdownUtil = new ConnectionShutdownUtil(_embedded);
        System.out.println("IN WebContainer>>moduleUndeployed: " 
            + deployedModuleName + "about to close all connections");        
        shutdownUtil.runCloseAllConnections();
        System.gc();
    
private voidsetDeployHistoryEntry(java.lang.String key, java.lang.String value, long lat)
set a deploy history entry

param
key identifies an application or module
param
value may have one of the following values : 'deployed', 'undeployed', 'redeployed'.
param
lat the latency HERCULES:add

        DeployHistoryEntry entry = (DeployHistoryEntry) _deployHistory.get(key);		if (entry == null)
            _deployHistory.put(key, new DeployHistoryEntry(value, lat));
        else {
            entry.value = value;
            entry.lat = lat;
        }