FileDocCategorySizeDatePackage
TomcatApplicationLoader.javaAPI DocGlassfish v2 API8074Fri May 04 22:35:42 BST 2007com.sun.enterprise.server

TomcatApplicationLoader

public class TomcatApplicationLoader extends ApplicationLoader
This class extends ApplicationLoader to handle per application loading/unloading of web module.
author
Amy Roh

Fields Summary
static Logger
_logger
logger to log loader messages
private com.sun.enterprise.instance.AppsManager
appsManager
The AppsManager for this VS save for unload() since super.unload() calls done() and clears this.configManager
private com.sun.enterprise.web.PEWebContainer
webContainer
The WebContainer instance.
Constructors Summary
public TomcatApplicationLoader(String appID, ClassLoader parentClassLoader, com.sun.enterprise.instance.AppsManager appsManager)
TomcatApplicationLoader loads one application.

param
appID the name of the application
param
parentClassLoader parent class loader for this application
param
appsManager the AppsManager for this VS

    
    
    // ------------------------------------------------------------ Constructor
 
    
                                                         
        
              

        super(appID, parentClassLoader, appsManager);
        _logger.log(Level.FINEST, "[TomcatApplicationLoader] " + appID);
        this.appsManager = appsManager;
        // get the instance of WebContainer
        webContainer = PEWebContainer.getPEWebContainer();
        _logger.log(Level.FINEST, "PEWebContainer " + webContainer);

    
Methods Summary
protected booleandoLoad(boolean jsr77)
Called from ApplicationManager. Called to load an application. This loads the web modules of this application on top of its super loader creating the EJB and MDB container.

return
true if all modules were loaded successfully

    
    
    
                                                 
        

        _logger.log(Level.FINEST, "[TomcatApplicationLoader] load " + jsr77);
        boolean deployed = super.doLoad(jsr77);
        if (loadUnloadAction == Constants.LOAD_RAR || ! deployed) {
            return deployed;
        }
        _logger.log(Level.FINEST, "deployed "+deployed);
        if (webContainer == null) {
            webContainer = PEWebContainer.getPEWebContainer();
        }
        if (deployed) {
            J2eeApplication[] j2eeAppBeans = appsManager.getAllApps();
            if (j2eeAppBeans != null) {
                for (int i = 0; i < j2eeAppBeans.length; i++) {
                    if (j2eeAppBeans[i].getName().equals(id) && webContainer != null) {
                        _logger.log(Level.FINEST, 
                                    "[TomcatApplicationLoader] loadJ2EEAppWebModule with "+j2eeAppBeans[i]);
                        webContainer.loadJ2EEApplicationWebModules(j2eeAppBeans[i]);
                       
                    }
                }
            }
        }
        return deployed;
        
    
protected booleanunload(boolean jsr77)
Unloads this application.

return
true if all modules were removed successfully


        if (loadUnloadAction == Constants.UNLOAD_RAR) {
            return super.unload(jsr77);
        }

        super.unloadWebserviceEndpoints(jsr77);

        Set wbds = null; 
        J2eeApplication[] j2eeAppBeans = appsManager.getAllApps();        
        if (j2eeAppBeans != null) {
            for (int i = 0; i < j2eeAppBeans.length; i++) {
                if (j2eeAppBeans[i].getName().equals(id)) {

                    String virtualServers = null;
                    try {
                        virtualServers = appsManager.
                            getVirtualServersByAppName(j2eeAppBeans[i].getName());
                    } catch(ConfigException ce) {
                        _logger.log(Level.FINEST, "[TomcatApplicationLoader] unload " 
                            + id + ". error getting virtualServers", ce);
                    }
                    
                    _logger.log(Level.FINEST, "[TomcatApplicationLoader] unload "
                                               +id);
                    wbds = application.getWebBundleDescriptors();
                    WebBundleDescriptor wbd = null;
                    if ( wbds == null) continue;

                    Iterator itr = wbds.iterator();
                    
                    while (itr.hasNext()){
                        wbd = (WebBundleDescriptor) itr.next();
                        String appName = wbd.getApplication().getRegistrationName();
                        try {
			    webContainer.unloadWebModule(wbd.getContextRoot(),
                                                         appName,
                                                         virtualServers,
                                                         wbd);
                        
			} finally {
			    try {
				Switch.getSwitch().
				    getNamingManager().unbindObjects(wbd);
			    } catch (javax.naming.NamingException nameEx) {
				_logger.log(Level.FINEST, "[TomcatApplicationLoader] "
					+ " Exception during namingManager.unbindObject",
					nameEx);
			    }
			}
                    }

                }
            }    
        }

        return super.unload(jsr77);