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

TomcatDeploymentConfig

public class TomcatDeploymentConfig extends Object
This class decorates all com.sun.enterprise.deployment.* objects in order to make them usuable by the Catalina container. This avoid having duplicate memory representation of the web.xml (as well as parsing the web.xml twice)
author
Jean-Francois Arcand

Fields Summary
private static final Logger
logger
Constructors Summary
public TomcatDeploymentConfig()
Empty constructor

    
    
           
     
    
Methods Summary
protected static voidconfigureApplicationListener(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure context initialization parameter that is configured in the server configuration file, rather than the application deployment descriptor. This is convenient for establishing default values (which may be configured to allow application overrides or not) without having to modify the application deployment descriptor itself.

  
        
       String[] applicationListeners = (String[])
                     defaultWebModule.getCachedFindOperation()
                                [WebModuleContextConfig.APPLICATION_LISTENERS];
       
       for (int i=0; i < applicationListeners.length ; i++){
            webModule.addApplicationListener(applicationListeners[i]);
       }
         
    
protected static voidconfigureApplicationListener(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure context initialization parameter that is configured in the server configuration file, rather than the application deployment descriptor. This is convenient for establishing default values (which may be configured to allow application overrides or not) without having to modify the application deployment descriptor itself.

        
        Vector vector = wmd.getAppListenerDescriptors();
        for (int i=0; i < vector.size() ; i++){
            webModule.addApplicationListener( 
                        ((AppListenerDescriptor)vector.get(i)).getListener() );
        }
         
    
protected static voidconfigureContextEjb(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.EjbReferenceDescriptor ejbDescriptor)
Configures EJB resource reference for a web application, as represented in a <ejb-local-ref>element in the deployment descriptor.

                                         
        ContextEjbDecorator decorator = new ContextEjbDecorator(ejbDescriptor);
        webModule.addEjb(decorator);
        
    
protected static voidconfigureContextEnvironment(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure application environment entry, as represented in an <env-entry> element in the deployment descriptor.

                                                        
        Set set = wmd.getContextParametersSet();
        Iterator iterator = set.iterator();
          
        ContextEnvironmentDecorator decorator;
        EnvironmentProperty envRef;
        while (iterator.hasNext()){
            envRef = (EnvironmentProperty)iterator.next();
            decorator = new ContextEnvironmentDecorator(envRef);
            webModule.addEnvironment(decorator);
        }
    
protected static voidconfigureContextEnvironment(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure application environment entry, as represented in an <env-entry> element in the deployment descriptor.

 
                                                        
       ContextEnvironment[] contextEnvironment = (ContextEnvironment[])
                    defaultWebModule.getCachedFindOperation()
                                        [WebModuleContextConfig.ENVIRONMENTS];
       for(int i=0; i < contextEnvironment.length; i++){
            webModule.addEnvironment(contextEnvironment[i]);
       }
    
protected static voidconfigureContextLocalEjb(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.EjbReferenceDescriptor ejbDescriptor)
Configures EJB resource reference for a web application, as represented in a <ejb-ref> in the deployment descriptor.

        ContextLocalEjbDecorator decorator = 
                                new ContextLocalEjbDecorator(ejbDescriptor);
        webModule.addLocalEjb(decorator);
    
    
protected static voidconfigureContextParam(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure context parameter defined in the deployment descriptor.

        
       Set set = wmd.getContextParametersSet();
       if ( set.isEmpty() ){
           return;
       }
       Iterator iterator = set.iterator();
       
       ContextParameter ctxParam;
       while(iterator.hasNext()){
           ctxParam = (ContextParameter)iterator.next();
           
           webModule.addParameter(ctxParam.getName(), ctxParam.getValue());
       }
    
protected static voidconfigureContextParam(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure context parameter defined in the deployment descriptor.

 
        
        ApplicationParameter[] params = (ApplicationParameter[])
                    defaultWebModule.getCachedFindOperation()
                            [WebModuleContextConfig.APPLICATION_PARAMETERS];
       
        for (int i=0 ; i < params.length; i++){
            webModule.addParameter(params[i].getName(), params[i].getValue());
        }
    
protected static voidconfigureContextResource(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure a resource reference for a web application, as represented in a <resource-ref> element in the deployment descriptor.

        Set set = wmd.getResourceReferenceDescriptors();
        if ( set.isEmpty() ){
            return;
        }
        Iterator iterator = set.iterator();
        
        ResourceReferenceDescriptor resRefDesc;
        ContextResourceDecorator decorator;
        while(iterator.hasNext()){
            resRefDesc = (ResourceReferenceDescriptor)iterator.next();
            decorator = new ContextResourceDecorator(resRefDesc);
                        
            webModule.addResource(decorator);                      
        }

    
protected static voidconfigureEjbReference(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configures EJB resource reference for a web application, as represented in a <ejb-ref> and <ejb-local-ref>element in the deployment descriptor.

                                                        
       Set set = wmd.getEjbReferenceDescriptors();
       Iterator iterator =  set.iterator();
       
       EjbReferenceDescriptor ejbDescriptor;
       while( iterator.hasNext() ){
            
           ejbDescriptor = (EjbReferenceDescriptor)iterator.next();
           if ( ejbDescriptor.isLocal() ){
                configureContextLocalEjb(webModule,ejbDescriptor);
           } else {
                configureContextEjb(webModule,ejbDescriptor);               
           }           
       }                                                        
    
protected static voidconfigureEjbReference(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
:q Configures EJB resource reference for a web application, as represented in a <ejb-ref> and <ejb-local-ref>element in the deployment descriptor.

 
         
        ContextLocalEjb[] localEjbs = (ContextLocalEjb[])
                            defaultWebModule.getCachedFindOperation()
                                        [WebModuleContextConfig.LOCAL_EJBS];   
        for (int i=0; i < localEjbs.length; i++){
            webModule.addLocalEjb(localEjbs[i]);
        }
        
        ContextEjb[] ejbs = (ContextEjb[])
                            defaultWebModule.getCachedFindOperation()
                                                [WebModuleContextConfig.EJBS];
        for (int i=0; i <ejbs.length; i++){
            webModule.addEjb(ejbs[i]);
        }
    
protected static voidconfigureErrorPage(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure error page element for a web application, as represented in a <error-page> element in the deployment descriptor.

            
       Enumeration enumeration = wmd.getErrorPageDescriptors();
       
       ErrorPageDescriptor errorPageDesc;
       ErrorPageDecorator decorator;
       while (enumeration.hasMoreElements()){
            errorPageDesc = (ErrorPageDescriptor)enumeration.nextElement();
            decorator = new ErrorPageDecorator(errorPageDesc);
            webModule.addErrorPage(decorator);
       }
                                             
    
protected static voidconfigureErrorPage(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure error page element for a web application, as represented in a <error-page> element in the deployment descriptor.

 
            
       ErrorPage[] errorPages = (ErrorPage[])
                        defaultWebModule.getCachedFindOperation()
                                    [WebModuleContextConfig.ERROR_PAGES];
                                                 
       for(int i=0; i <  errorPages.length; i++){
            webModule.addErrorPage(errorPages[i]);
       }
                                             
    
protected static voidconfigureFilterDef(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure filter definition for a web application, as represented in a <filter> element in the deployment descriptor.

                                                        
       Vector vector = wmd.getServletFilters();
       
       FilterDefDecorator filterDef;
       ServletFilter servletFilter;
       
       for (int i=0; i < vector.size(); i++)  {
           servletFilter = (ServletFilter)vector.get(i);
           filterDef = new FilterDefDecorator(servletFilter);
          
           webModule.addFilterDef(filterDef);          
       }
                                                                     
    
protected static voidconfigureFilterDef(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure filter definition for a web application, as represented in a <filter> element in the deployment descriptor.

 
                                                        
       FilterDef[] filterDefs = (FilterDef[])
            defaultWebModule.getCachedFindOperation()
                                        [WebModuleContextConfig.FILTER_DEFS];
       
       for (int i=0; i < filterDefs.length; i++)  {
           webModule.addFilterDef(filterDefs[i]);          
       }
                                                                     
    
protected static voidconfigureFilterMap(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure filter mapping for a web application, as represented in a <filter-mapping> element in the deployment descriptor. Each filter mapping must contain a filter name plus either a URL pattern or a servlet name.

                                                        
        Vector vector = wmd.getServletFilterMappingDescriptors();
        for (int i=0; i < vector.size(); i++)  {
            webModule.addFilterMap((ServletFilterMapping)vector.get(i));
        }
    
protected static voidconfigureFilterMap(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure filter mapping for a web application, as represented in a <filter-mapping> element in the deployment descriptor. Each filter mapping must contain a filter name plus either a URL pattern or a servlet name.

 
                                                        
        FilterMap[] filterMaps = (FilterMap[])
                        defaultWebModule.getCachedFindOperation()
                                        [WebModuleContextConfig.FILTER_MAPS];
       
        for (int i=0; i < filterMaps.length; i++)  {
            webModule.addFilterMap(filterMaps[i]);           
        }                                                    
    
protected static voidconfigureJspConfig(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure jsp-config element contained in the deployment descriptor


        Vector jspProperties = new Vector();

        webModule.setAttribute(Globals.JSP_PROPERTY_GROUPS_CONTEXT_ATTRIBUTE,
                               jspProperties);
        webModule.setAttribute(Globals.WEB_XML_VERSION_CONTEXT_ATTRIBUTE,
                               wmd.getSpecVersion());
                                      
        JspConfigDescriptor jspConfig = wmd.getJspConfigDescriptor();
        if (jspConfig == null) {
            return;
        }

        Enumeration<TagLibConfigurationDescriptor> taglibs
            = jspConfig.getTagLibs();
        if (taglibs != null) {
            while (taglibs.hasMoreElements()) {
                TagLibConfigurationDescriptor taglib = taglibs.nextElement();
                webModule.addTaglib(taglib.getTagLibURI(),
                                    taglib.getTagLibLocation()); 
            }
        }
       
        Collection set = jspConfig.getJspGroupSet();
        if (set.isEmpty()) {
            return;
        }

        Iterator<JspGroupDescriptor> jspPropertyGroups = set.iterator();
        while (jspPropertyGroups.hasNext()){

            JspGroupDescriptor jspGroup = jspPropertyGroups.next();

            Vector urlPatterns = null;
            Vector includePreludes = null;
            Vector includeCodas = null;

            String pageEncoding = jspGroup.getPageEncoding();
            String scriptingInvalid = jspGroup.getScriptingInvalid();
            String elIgnored = jspGroup.getElIgnored();
            String isXml = jspGroup.getIsXml();
            String trimSpaces = jspGroup.getTrimDirectiveWhitespaces();
            String poundAllowed = jspGroup.getDeferredSyntaxAllowedAsLiteral();
           
            // url-pattern
            Enumeration<String> e = jspGroup.getUrlPatterns();
            if (e != null) {
                while (e.hasMoreElements()) {
                    if (urlPatterns == null) {
                        urlPatterns = new Vector();
                    }
                    String urlPattern = e.nextElement();
                    urlPatterns.addElement(urlPattern);
                    webModule.addJspMapping(urlPattern);
                }
            }
            if (urlPatterns == null || urlPatterns.size() == 0) {
                continue;
            }

            // include-prelude
            e = jspGroup.getIncludePreludes();
            if (e != null) {
                while (e.hasMoreElements()) {
                    if (includePreludes == null) {
                        includePreludes = new Vector();
                    }
                    includePreludes.addElement(e.nextElement());
                }
            }

            // include-coda
            e = jspGroup.getIncludeCodas();
            if (e != null) {
                while (e.hasMoreElements()) {
                    if (includeCodas == null) {
                        includeCodas = new Vector();
                    }
                    includeCodas.addElement(e.nextElement());
                }
            }

            JspConfig.makeJspPropertyGroups(jspProperties,
                                            urlPatterns, 
                                            isXml,
                                            elIgnored,
                                            scriptingInvalid,
                                            trimSpaces,
                                            poundAllowed,
                                            pageEncoding,
                                            includePreludes,
                                            includeCodas);
        }
    
protected static voidconfigureLoginConfig(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure a login configuration element for a web application, as represented in a <login-config> element in the deployment descriptor.

        LoginConfig loginConf = defaultWebModule.getLoginConfig();
        if ( loginConf == null ){
            return;
        }                                          
        webModule.setLoginConfig(loginConf);       
        
    
protected static voidconfigureLoginConfig(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure a login configuration element for a web application, as represented in a <login-config> element in the deployment descriptor.

                                            
        LoginConfiguration loginConf = wmd.getLoginConfiguration();
        if ( loginConf == null ){
            return;
        }

        LoginConfigDecorator decorator = new LoginConfigDecorator(loginConf);
        webModule.setLoginConfig(decorator);         
    
protected static voidconfigureMessageDestination(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure of a message destination for a web application, as represented in a <message-destination> element in the deployment descriptor.

                                                        
        Set set = wmd.getMessageDestinations();
        if ( set.isEmpty() ){
            return;
        }
        Iterator iterator = set.iterator();
        
        MessageDestinationDescriptor msgDrd = null;
        MessageDestinationDecorator decorator;
        while(iterator.hasNext()){
            msgDrd = (MessageDestinationDescriptor)iterator.next();
            decorator = new MessageDestinationDecorator(msgDrd);
            
            webModule.addMessageDestination(decorator);
        }       
                                                       
    
protected static voidconfigureMessageDestination(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure of a message destination for a web application, as represented in a <message-destination> element in the deployment descriptor.

 
                                                        
        MessageDestination[] messageDestinations = (MessageDestination[])
                    defaultWebModule.getCachedFindOperation()
                                [WebModuleContextConfig.MESSAGE_DESTINATIONS];
        
        for(int i=0; i < messageDestinations.length; i++){
            webModule.addMessageDestination(messageDestinations[i]);
        }                                                           
    
protected static voidconfigureMessageDestinationRef(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Representation of a message destination reference for a web application, as represented in a <message-destination-ref> element in the deployment descriptor.

                                                        
        Set set = wmd.getMessageDestinationReferenceDescriptors();
        if ( set.isEmpty() ){
            return;
        }
        Iterator iterator = set.iterator();
        
        MessageDestinationReferenceDescriptor msgDrd = null;
        MessageDestinationRefDecorator decorator;
        while(iterator.hasNext()){
            msgDrd = (MessageDestinationReferenceDescriptor)iterator.next();
            decorator = new MessageDestinationRefDecorator(msgDrd);
            
            webModule.addMessageDestinationRef(decorator);
        }                                                             
    
protected static voidconfigureMessageRef(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure of a message destination for a web application, as represented in a <message-destination> element in the deployment descriptor.

 
                                                        
        MessageDestinationRef[] messageDestinationRefs = (MessageDestinationRef[])
                defaultWebModule.getCachedFindOperation()
                            [WebModuleContextConfig.MESSAGE_DESTINATION_REFS];
        
        for(int i=0; i < messageDestinationRefs.length; i++){
            webModule.addMessageDestinationRef(messageDestinationRefs[i]);
        }                                                           
    
protected static voidconfigureMimeMapping(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure mime-mapping defined in the deployment descriptor.

                                                        
        Enumeration enumeration = wmd.getMimeMappings();
        MimeMapping mimeMapping;
        while (enumeration.hasMoreElements()){
            mimeMapping = (MimeMapping)enumeration.nextElement();
            webModule.addMimeMapping(mimeMapping.getExtension(),
                                     mimeMapping.getMimeType());            
        }
                                                        
    
protected static voidconfigureMimeMapping(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Adds the MIME mappings defined in default-web.xml to the given web module.

param
webModule Web module to which the MIME mappings specified in default-web.xml are to be added
param
defaultWebModule Web Module representing default-web.xml

        String[] mimeMappings = (String[])
            defaultWebModule.getCachedFindOperation()
                                    [WebModuleContextConfig.MIME_MAPPINGS];
       
        for (int i=0; mimeMappings!=null && i<mimeMappings.length; i++) {
            webModule.addMimeMapping(
                            mimeMappings[i],
                            defaultWebModule.findMimeMapping(mimeMappings[i]));
        }                                                
    
protected static voidconfigureResourceRef(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure resource-reference defined in the deployment descriptor.

        Set set = wmd.getEnvironmentProperties();
        if ( set.isEmpty() ){
           return;
        }
        Iterator iterator = set.iterator();
        
        EnvironmentEntry envEntry;
        while(iterator.hasNext()){
            envEntry = (EnvironmentEntry)iterator.next();
            
            webModule.addResourceEnvRef(envEntry.getName(), 
                                        envEntry.getType());
                       
        }                                                                     
    
protected static voidconfigureResourceRef(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure resource-reference defined in the deployment descriptor.

 
        
        ContextResource[] contextResources = (ContextResource[])
                                defaultWebModule.getCachedFindOperation()
                                        [WebModuleContextConfig.RESOURCES];

        for (int i=0; i < contextResources.length; i++){
            webModule.addResource(contextResources[i]);
        }
    
protected static voidconfigureSecurityConstraint(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure security constraint element for a web application, as represented in a <security-constraint> element in the deployment descriptor. Configure a web resource collection for a web application's security constraint, as represented in a <web-resource-collection> element in the deployment descriptor.

                                                   
        Enumeration enumeration = wmd.getSecurityConstraints(); 
        SecurityConstraint securityConstraint;
        SecurityConstraintDecorator decorator;
        Enumeration enumeration2;
        SecurityCollectionDecorator secCollDecorator;
        while (enumeration.hasMoreElements()){
            securityConstraint =(SecurityConstraint)enumeration.nextElement();
             
            decorator = new SecurityConstraintDecorator(securityConstraint,
                                                        webModule);
            
            enumeration2 = securityConstraint.getWebResourceCollections();
            while (enumeration2.hasMoreElements()){
                secCollDecorator = new SecurityCollectionDecorator
                            ((WebResourceCollection) enumeration2.nextElement());
                   
                decorator.addCollection(secCollDecorator);           
            }
            webModule.addConstraint(decorator);
        }
                                                
    
protected static voidconfigureSecurityRoles(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Validate the usage of security role names in the web application deployment descriptor. If any problems are found, issue warning messages (for backwards compatibility) and add the missing roles. (To make these problems fatal instead, simply set the ok instance variable to false as well).


        Enumeration<SecurityRoleDescriptor> e = wmd.getSecurityRoles();
        if (e != null) {
            while (e.hasMoreElements()){
                webModule.addSecurityRole(e.nextElement().getName());
            }
        }

        // Check role names used in <security-constraint> elements
        org.apache.catalina.deploy.SecurityConstraint 
                            constraints[] = webModule.findConstraints();
        for (int i = 0; i < constraints.length; i++) {
            String roles[] = constraints[i].findAuthRoles();
            for (int j = 0; j < roles.length; j++) {
                if (!"*".equals(roles[j]) &&
                    !webModule.findSecurityRole(roles[j])) {
                    logger.log(
                        Level.WARNING,"tomcatDeploymentConfig.role.auth", roles[j]);
                    webModule.addSecurityRole(roles[j]);
                }
            }
        }

        // Check role names used in <servlet> elements
        Container wrappers[] = webModule.findChildren();
        for (int i = 0; i < wrappers.length; i++) {
            Wrapper wrapper = (Wrapper) wrappers[i];
            String runAs = wrapper.getRunAs();
            if ((runAs != null) && !webModule.findSecurityRole(runAs)) {
                logger.log(
                    Level.WARNING,"tomcatDeploymentConfig.role.runas", runAs);
                webModule.addSecurityRole(runAs);
            }
            String names[] = wrapper.findSecurityReferences();
            for (int j = 0; j < names.length; j++) {
                String link = wrapper.findSecurityReference(names[j]);
                if ((link != null) && !webModule.findSecurityRole(link)) {
                    logger.log(
                        Level.WARNING,"tomcatDeploymentConfig.role.link", link);
                    webModule.addSecurityRole(link);
                }
            }
        }

    
protected static voidconfigureStandardContext(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor wmd)
Configure the WebModule instance by creating StandardWrapper using the information contained in the deployment descriptor (Welcome Files, JSP, Servlets etc.)

    
       Set set = wmd.getWebComponentDescriptorsSet();
       StandardWrapper wrapper;    
       WebComponentDescriptor webComponentDesc;
       Enumeration enumeration;
       SecurityRoleReference securityRoleReference;
       
       Set set2;
       Iterator iterator2;
       
       if ( !set.isEmpty() ){
           Iterator iterator = set.iterator();

           while (iterator.hasNext()) {

                webComponentDesc = (WebComponentDescriptor)iterator.next();

                wrapper = (StandardWrapper)webModule.createWrapper();
                wrapper.setName(webComponentDesc.getCanonicalName());
                webModule.addChild(wrapper);

                enumeration = webComponentDesc.getInitializationParameters();
                InitializationParameter initP = null;
                while (enumeration.hasMoreElements()){
                    initP = (InitializationParameter)enumeration.nextElement();
                    wrapper.addInitParameter(initP.getName(), initP.getValue());
                }

                if (webComponentDesc.isServlet()){
                        wrapper.setServletClass(
                                webComponentDesc.getWebComponentImplementation());
                } else {
                    wrapper.setJspFile(webComponentDesc.
                                                 getWebComponentImplementation());                
                }

                wrapper.setLoadOnStartup(webComponentDesc.getLoadOnStartUp());
                if (webComponentDesc.getRunAsIdentity() != null)
                    wrapper.setRunAs(webComponentDesc.getRunAsIdentity().getRoleName());


                set2 = webComponentDesc.getUrlPatternsSet();
                iterator2 = set2.iterator();
                while (iterator2.hasNext()){
                    webModule.addServletMapping((String)iterator2.next(),
                                                webComponentDesc.getCanonicalName());
                }

                enumeration = webComponentDesc.getSecurityRoleReferences();
                while (enumeration.hasMoreElements()){
                    securityRoleReference = 
                                (SecurityRoleReference)enumeration.nextElement();
                    wrapper.
                        addSecurityReference(securityRoleReference.getRolename(),
                             securityRoleReference.getSecurityRoleLink().getName());
                }
            }
        }
       
        webModule.setSessionTimeout(wmd.getSessionTimeout());
           
        enumeration = wmd.getWelcomeFiles();
        while (enumeration.hasMoreElements()){
            webModule.addWelcomeFile((String)enumeration.nextElement());
        }
        
        LocaleEncodingMappingListDescriptor lemds = 
                            wmd.getLocaleEncodingMappingListDescriptor();
        if (lemds != null) {
            set2 = lemds.getLocaleEncodingMappingSet();
            iterator2 = set2.iterator();
            LocaleEncodingMappingDescriptor lemd;
            while (iterator2.hasNext()){
                lemd = (LocaleEncodingMappingDescriptor) iterator2.next();
                webModule.
                    addLocaleEncodingMappingParameter(lemd.getLocale(),
                                                      lemd.getEncoding());
            }
        }
    
protected static voidconfigureStandardContext(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)

 
                                                      
        // 1. Add the default Wrapper
        Container wrappers[] = (Container[])
                            defaultWebModule.getCachedFindOperation()
                                            [WebModuleContextConfig.CHILDREN];
        
        StandardWrapper wrapper, defaultWrapper;
        for(int i=0; i < wrappers.length; i++){    
            defaultWrapper = (StandardWrapper)wrappers[i];
            wrapper = (StandardWrapper)webModule.createWrapper();
            wrapper.setName(defaultWrapper.getName());
            webModule.addChild(wrapper);
            
            String[] initParams = defaultWrapper.findInitParameters();
            for (int j=0; j < initParams.length; j++){
                wrapper.addInitParameter(
                    initParams[j], defaultWrapper.findInitParameter(initParams[j]));
            }
       
            if (defaultWrapper.getJspFile() == null){
                wrapper.setServletClass(defaultWrapper.getServletClass());
            } else {
                wrapper.setJspFile(defaultWrapper.getJspFile());
            }
    
            wrapper.setLoadOnStartup(defaultWrapper.getLoadOnStartup());
            if (defaultWrapper.getRunAs() != null)
                wrapper.setRunAs(defaultWrapper.getRunAs());
        }
                           
        String[] servletMappings = (String[])
                    defaultWebModule.getCachedFindOperation()
                                    [WebModuleContextConfig.SERVLET_MAPPINGS];
        
        String servletName;
        for (int j=0; j < servletMappings.length; j++){
            servletName = 
                defaultWebModule.findServletMapping(servletMappings[j]);
            if (servletName.equals("jsp")){
                webModule.addServletMapping(
                    servletMappings[j], servletName, true);
            } else {
                webModule.addServletMapping(servletMappings[j],servletName);
            }
        }
        
        webModule.setSessionTimeout(defaultWebModule.getSessionTimeout());
           
        String[] welcomeFiles = defaultWebModule.getWelcomeFiles();
        for(int i=0; i < welcomeFiles.length; i++){
            webModule.addWelcomeFile(welcomeFiles[i]);
        }
        
        webModule.setCharsetMapper((CharsetMapper)
            defaultWebModule.getCharsetMapper().clone()); 
    
public static voidconfigureWebModule(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.web.WebModule defaultWebModule)
Configure a WebModule by applying default-web.xml information contained in the default WebModule.

param
webModule Web Module to be configured with default web module
param
defaultWebModule Default web module

 
                                              
        configureStandardContext(webModule,defaultWebModule);
        
        configureContextParam(webModule,defaultWebModule);

        configureApplicationListener(webModule,defaultWebModule);
        
        configureEjbReference(webModule,defaultWebModule);
 
        configureContextEnvironment(webModule,defaultWebModule);
        
        configureErrorPage(webModule,defaultWebModule);

        configureFilterDef(webModule,defaultWebModule);

        configureFilterMap(webModule,defaultWebModule);
        
        configureLoginConfig(webModule,defaultWebModule);
        
        configureMimeMapping(webModule,defaultWebModule);
        
        configureResourceRef(webModule,defaultWebModule);

        configureMessageDestination(webModule,defaultWebModule); 
        
        configureMessageRef(webModule,defaultWebModule); 
        
 
    
public static voidconfigureWebModule(com.sun.enterprise.web.WebModule webModule, com.sun.enterprise.deployment.WebBundleDescriptor webModuleDescriptor)
Configure a WebModule by applying web.xml information contained in WebBundleDescriptor. This astatic void calling Tomcat 5 internal deployment mechanism by re-using the DOL objects.

 

        // When context root = "/"
        if ( webModuleDescriptor == null ){
            return;
        }
        
        webModule.setDisplayName(webModuleDescriptor.getDisplayName());
        webModule.setDistributable(webModuleDescriptor.isDistributable());
        webModule.setReplaceWelcomeFiles(true);
        
        configureStandardContext(webModule,webModuleDescriptor);
        
        configureContextParam(webModule,webModuleDescriptor);

        configureApplicationListener(webModule,webModuleDescriptor);
        
        configureEjbReference(webModule,webModuleDescriptor);
 
        configureContextEnvironment(webModule,webModuleDescriptor);
        
        configureErrorPage(webModule,webModuleDescriptor);

        configureFilterDef(webModule,webModuleDescriptor);

        configureFilterMap(webModule,webModuleDescriptor);
        
        configureLoginConfig(webModule,webModuleDescriptor);
        
        configureMimeMapping(webModule,webModuleDescriptor);
        
        configureResourceRef(webModule,webModuleDescriptor);

        configureMessageDestination(webModule,webModuleDescriptor);

        configureContextResource(webModule,webModuleDescriptor);

        configureSecurityConstraint(webModule,webModuleDescriptor);
        
        configureJspConfig(webModule,webModuleDescriptor);
        
        configureSecurityRoles(webModule, webModuleDescriptor);