FileDocCategorySizeDatePackage
WebModulesManager.javaAPI DocGlassfish v2 API15888Fri Jul 27 04:50:36 BST 2007com.sun.enterprise.instance

WebModulesManager

public class WebModulesManager extends ModulesManager

Fields Summary
Constructors Summary
public WebModulesManager(InstanceEnvironment env)

        super(env, true);
    
public WebModulesManager(InstanceEnvironment env, boolean useBackupServerXml)

        super(env, useBackupServerXml);
        //FIXME: HACK START
	WebModule[] jArray = ((Applications)configBean).getWebModule();
	if(jArray!=null) {
            for(int i=0;i<jArray.length;i++) {
                jArray[i].setConfigContext(configContext);
		jArray[i].setXPath(ServerXPathHelper.getWebModuleIdXpathExpression(jArray[i].getName()));
            }
	}
	//FIXME: HACK END

    
Methods Summary
public java.lang.StringgetContextRoot(java.lang.String modId)

        return getWebModule(modId).getContextRoot();
    
public java.lang.StringgetDescription(java.lang.String modId)

        return getWebModule(modId).getDescription();
    
public com.sun.enterprise.deployment.ApplicationgetDescriptor(java.lang.String modId, java.lang.ClassLoader cl, java.lang.String moduleLoc, boolean validateXML)
Returns the deployment descriptor object for the specified web module.

param
modId web module id
param
cl class loader to associate with the descriptors
param
validateXml use validating parser when true
return
the deployment descriptor object for this web module
throws
ConfigException if unable to load the deployment descriptor

        Application app = getDescriptor(modId, moduleLoc, validateXML);
	app.setClassLoader(cl);
	return app;
    
public com.sun.enterprise.deployment.ApplicationgetDescriptor(java.lang.String modId, java.lang.String modDir)
Returns the deployment descriptor object for the web module in the specified directory.

param
modId web module id
param
modDir The directory containing the web module
return
the deployment descriptor object for this web module
throws
ConfigException if unable to load the deployment descriptor


        return getDescriptor(modId, modDir, false);
    
public com.sun.enterprise.deployment.ApplicationgetDescriptor(java.lang.String modId, java.lang.String modDir, boolean validateXml)
Returns the deployment descriptor object for the web module in the specified directory.

param
modId web module id
param
modDir The directory containing the web module
param
validateXml use validating parser when true
return
the deployment descriptor object for this web module
throws
ConfigException if unable to load the deployment descriptor

            
        Application application = getRegisteredDescriptor(modId);
        if (application!=null) {
            return application;
        }
        try {
	    WebArchivist webArchivist = new WebArchivist();
	    webArchivist.setXMLValidation(validateXml);
	    
	    FileArchive archive = openDDArchive(modId, modDir);
            // Try to load the app from the serialized descriptor file.
            SerializedDescriptorHelper.Loader sdLoader = 
                    SerializedDescriptorHelper.load(modId, this);
            Application deserializedApplication = sdLoader.getApplication();
            if (deserializedApplication != null) {
                application = deserializedApplication;
            } else {
                application = ApplicationArchivist.openArchive(modId, webArchivist, archive, true);
                if(!isSystemAdmin(modId) && !isSystem(modId)) {
                    // we need to read persistence descriptors separately
                    // because they are read from appDir as oppsed to xmlDir.
                    readPersistenceDeploymentDescriptors(modDir, application);
                }
            }
            application.setGeneratedXMLDirectory(getGeneratedXMLLocation(modId));

            if (!application.getWebServiceDescriptors().isEmpty()) {
                ModuleContentLinker visitor = new ModuleContentLinker(archive, true);
                application.visit((com.sun.enterprise.deployment.util.ApplicationVisitor) visitor);
            }
            
            registerDescriptor(modId, application);

            // If needed, save this app in serialized form for faster loading next time.
            sdLoader.store(application);

            return application;
        } catch (IOException ioe) {
            throw new ConfigException(Localizer.getValue(
                ExceptionType.IO_ERROR_LOADING_DD, modId), ioe);
        } catch (Throwable t) {
            throw new ConfigException(Localizer.getValue(
                ExceptionType.FAIL_DD_LOAD, modId), t);
        }
	
public java.lang.StringgetGeneratedXMLLocation(java.lang.String name)

        ModuleEnvironment menv = instanceEnvironment.getModuleEnvironment(name,
                                                     DeployableObjectType.WEB); 
        return menv.getModuleGeneratedXMLPath();
    
public java.lang.StringgetJSPLocation(java.lang.String name)

        ModuleEnvironment menv = instanceEnvironment.getModuleEnvironment(name,
                                                     DeployableObjectType.WEB); 
		return menv.getModuleJSPPath();
	
public java.lang.StringgetLocation(java.lang.String name)

        WebModule webModule = (WebModule)
            ((Applications)this.configBean).getWebModuleByName(name);
        String location = null;
        if (webModule != null)
            location = webModule.getLocation();
        return resolvePath(location);
    
public javax.enterprise.deploy.shared.ModuleTypegetModuleType()

return
the module type this class is managing

        return ModuleType.WAR;
    
public java.lang.StringgetStubLocation(java.lang.String name)

        ModuleEnvironment menv = instanceEnvironment.getModuleEnvironment(name,
                                                     DeployableObjectType.WEB); 
		return menv.getModuleStubPath();
	
public java.lang.StringgetVirtualServers(java.lang.String modId)

	Server server = ServerBeansFactory.getServerBean(configContext);
	ApplicationRef ar = server.getApplicationRefByRef(modId);
	return ar.getVirtualServers();
    
private com.sun.enterprise.config.serverbeans.WebModulegetWebModule(java.lang.String modId)

        WebModule mod = (WebModule)
            ((Applications)this.configBean).getWebModuleByName(modId);
        
        if(mod == null)
            throw new ConfigException(Localizer.getValue(ExceptionType.NO_SUCH_WEB_MOD));
        
        return mod;
        
    
public booleanisEnabled(java.lang.String modId)

        return getWebModule(modId).isEnabled();
    
protected booleanisRegistered(java.lang.String modId, com.sun.enterprise.config.ConfigBean bean)

        ConfigBean cb = null;
        try {
            cb = ((Applications)bean).getWebModuleByName(modId);
        } catch(Exception cn) {
        }
        
        if(cb != null) return true;
        return false;
    
public booleanisSystem(java.lang.String modId)
Checks whether this module is a systemmodule ResourceType in domain.xml should start with "system-"

return
true if resourceType starts with "system-"

        WebModule wm =  getWebModule(modId);
        String resourceType = wm.getObjectType();
        if(resourceType.startsWith(SYSTEM_PREFIX))
            return true;
        else
            return false;
    
public booleanisSystemAdmin(java.lang.String modId)
Checks whether this module is a system admin module ResourceType in domain.xml should start with "system-admin"

return
true if resourceType starts with "system-admin"

        WebModule wm =  getWebModule(modId);
        String resourceType = wm.getObjectType();
        if(resourceType.startsWith(SYSTEM_ADMIN_PREFIX))
            return true;
        else
            return false;
    
public booleanisSystemPredeployed(java.lang.String modId)
Checks whether this module is a pre-deployed system module ResourceType in domain.xml should start with "system" Also it should be directory deployed

return
true if its a predeployed system module

        WebModule wm =  getWebModule(modId);
        String resourceType = wm.getObjectType();
        boolean isDirectoryDeployed = wm.isDirectoryDeployed();
        if (resourceType.startsWith(SYSTEM_PREFIX) && isDirectoryDeployed) { 
            return true;
        } else {
            return false;
        }
    
public java.util.ListlistIds()
Returns a list of (type java.lang.String) all web modules deployed to the server.


        ArrayList arr = new ArrayList();
        WebModule[] mods = ((Applications)this.configBean).getWebModule();

        // returns an empty list if there are no web modules in the domain
        if(mods == null) return arr;


        for (int i=0;i<mods.length;i++) {
            String name = mods[i].getName();
            // adds the web module to the list if 
            // it is referenced by this server             
            if ( isReferenced(name) ) {
                arr.add(name);
            }
        }
        return arr;
    
public com.sun.enterprise.config.serverbeans.WebModule[]listWebModules()
Returns a list of all WebModule beans deployed on the server.

        WebModule[] modules = ((Applications)this.configBean).getWebModule();

        if (modules == null) { 
            return new WebModule[0];
        }
        
        ArrayList list = new ArrayList();
        for (int i=0; i<modules.length; i++) {
            // add the modules to the list if it is referenced
            // by this server
            if ( isReferenced(modules[i].getName()) ) {
                list.add(modules[i]);
            }
        }
        // returns an array of modules referenced by this server
        WebModule[] refList = new WebModule[list.size()];
        return ( (WebModule[]) list.toArray(refList) );
    
public voidremove(java.lang.String modId)

        WebModule backEm = (WebModule)
            ((Applications)configBean).getWebModuleByName(modId);
        ((Applications)configBean).removeWebModule(backEm);
    
public voidsetContextRoot(java.lang.String modId, java.lang.String value)

        getWebModule(modId).setContextRoot(value);
    
public voidsetDescription(java.lang.String modId, java.lang.String desc)

        getWebModule(modId).setDescription(desc);
    
public voidsetEnable(java.lang.String modId, boolean enable)

        getWebModule(modId).setEnabled(enable);
    
public voidsetLocation(java.lang.String name, java.lang.String location)

        WebModule webModule = (WebModule)
            ((Applications)this.configBean).getWebModuleByName(name);
        if (webModule != null)
            webModule.setLocation(location);
    
public voidsetOptionalAttributes(java.lang.String modId, java.util.Properties optionalAttributes)
Set the optional attributes for an module

param
modId unique idenitifier for the module
param
optionalAttributes - pairs tag/value to set

        if(optionalAttributes!=null) {
            WebModule wm = getWebModule(modId);
            Enumeration tags = optionalAttributes.keys();
            while(tags.hasMoreElements())
            {
                String tag = (String)tags.nextElement();
                String value = optionalAttributes.getProperty(tag);
                wm.setAttributeValue(tag, value);
            }
        }