geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r446624 [3/4] - in /geronimo/server/trunk: ./ assemblies/geronimo-jetty-j2ee/ configs/jetty-clustering-builder-wadi/ configs/jetty-clustering-builder-wadi/src/ configs/jetty-clustering-builder-wadi/src/plan/ configs/jetty-clustering-wadi/ c...
Date Fri, 15 Sep 2006 15:02:16 GMT
Modified: geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?view=diff&rev=446624&r1=446623&r2=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java Fri Sep 15 08:02:12 2006
@@ -47,6 +47,7 @@
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.deployment.ModuleIDBuilder;
 import org.apache.geronimo.deployment.NamespaceDrivenBuilder;
+import org.apache.geronimo.deployment.NamespaceDrivenBuilderCollection;
 import org.apache.geronimo.deployment.service.EnvironmentBuilder;
 import org.apache.geronimo.deployment.util.DeploymentUtil;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
@@ -64,6 +65,7 @@
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.jetty.DefaultWebApplicationHandlerFactory;
 import org.apache.geronimo.jetty.Host;
 import org.apache.geronimo.jetty.JettyDefaultServletHolder;
 import org.apache.geronimo.jetty.JettyFilterHolder;
@@ -128,6 +130,7 @@
     private final GBeanData pojoWebServiceTemplate;
 
     private final SingleElementCollection webServiceBuilder;
+    protected final NamespaceDrivenBuilderCollection clusteringBuilders;
 
     private final List defaultWelcomeFiles;
     private final Integer defaultSessionTimeoutSeconds;
@@ -143,6 +146,7 @@
             Collection defaultFilterMappings,
             Object pojoWebServiceTemplate,
             Collection webServiceBuilder,
+            Collection clusteringBuilders,
             Collection securityBuilders,
             Collection serviceBuilders,
             NamingBuilder namingBuilders,
@@ -156,6 +160,7 @@
         this.defaultFilterMappings = defaultFilterMappings;
         this.pojoWebServiceTemplate = getGBeanData(kernel, pojoWebServiceTemplate);
         this.webServiceBuilder = new SingleElementCollection(webServiceBuilder);
+        this.clusteringBuilders = new NamespaceDrivenBuilderCollection(clusteringBuilders);
 
         //todo locale mappings
 
@@ -165,7 +170,7 @@
     private WebServiceBuilder getWebServiceBuilder() {
         return (WebServiceBuilder) webServiceBuilder.getElement();
     }
-
+    
     private static GBeanData getGBeanData(Kernel kernel, Object template) throws GBeanNotFoundException {
         if (template == null) {
             return null;
@@ -222,6 +227,11 @@
 
         EnvironmentType environmentType = jettyWebApp.getEnvironment();
         Environment environment = EnvironmentBuilder.buildEnvironment(environmentType, defaultEnvironment);
+        
+        Boolean distributable = webApp.getDistributableArray().length == 1 ? Boolean.TRUE : Boolean.FALSE;
+        if (Boolean.TRUE == distributable) {
+            clusteringBuilders.buildEnvironment(jettyWebApp, environment);
+        }
 
         getNamingBuilders().buildEnvironment(webApp, jettyWebApp, environment);
         
@@ -337,6 +347,7 @@
 
         GBeanData webModuleData = new GBeanData(moduleName, JettyWebAppContext.GBEAN_INFO);
         try {
+            moduleContext.addGBean(webModuleData);
             if (moduleContext.getServerName() != null) {
                 webModuleData.setReferencePattern("J2EEServer", moduleContext.getServerName());
             }
@@ -348,26 +359,8 @@
             Set securityRoles = collectRoleNames(webApp);
             Map rolePermissions = new HashMap();
 
-            String[] hosts = jettyWebApp.getHostArray();
-            for (int i = 0; i < hosts.length; i++) {
-                hosts[i] = hosts[i].trim();
-            }
-            String[] virtualHosts = jettyWebApp.getVirtualHostArray();
-            for (int i = 0; i < virtualHosts.length; i++) {
-                virtualHosts[i] = virtualHosts[i].trim();
-            }
-            if (hosts.length > 0 || virtualHosts.length > 0) {
-                //use name same as module
-                AbstractName hostName = earContext.getNaming().createChildName(moduleName, "Host", "Host");
-                GBeanData hostData = new GBeanData(hostName, Host.GBEAN_INFO);
-                hostData.setAttribute("hosts", hosts);
-                hostData.setAttribute("virtualHosts", virtualHosts);
-                earContext.addGBean(hostData);
-                webModuleData.setReferencePattern("Host", hostName);
-            }
-
-            //session manager
-            webModuleData.setAttribute("sessionManager", jettyWebApp.getSessionManager());
+            // configure hosts and virtual-hosts
+            configureHosts(earContext, jettyWebApp, webModuleData);
 
             //Add dependencies on managed connection factories and ejbs in this app
             //This is overkill, but allows for people not using java:comp context (even though we don't support it)
@@ -398,191 +391,59 @@
                 webModuleData.setAttribute("displayName", webApp.getDisplayNameArray()[0].getStringValue());
             }
 
-            ParamValueType[] contextParamArray = webApp.getContextParamArray();
-            Map contextParams = new HashMap();
-            for (int i = 0; i < contextParamArray.length; i++) {
-                ParamValueType contextParam = contextParamArray[i];
-                contextParams.put(contextParam.getParamName().getStringValue().trim(), contextParam.getParamValue().getStringValue().trim());
-            }
-            webModuleData.setAttribute("contextParamMap", contextParams);
-
-            ListenerType[] listenerArray = webApp.getListenerArray();
-            Collection listeners = new ArrayList();
-            for (int i = 0; i < listenerArray.length; i++) {
-                ListenerType listenerType = listenerArray[i];
-                listeners.add(listenerType.getListenerClass().getStringValue());
-            }
-            webModuleData.setAttribute("listenerClassNames", listeners);
+            // configure context parameters.
+            configureContextParams(webApp, webModuleData);
 
-            webModuleData.setAttribute("distributable", webApp.getDistributableArray().length == 1 ? Boolean.TRUE : Boolean.FALSE);
+            // configure listeners.
+            configureListeners(webApp, webModuleData);
 
+            Boolean distributable = webApp.getDistributableArray().length == 1 ? Boolean.TRUE : Boolean.FALSE;
+            webModuleData.setAttribute("distributable", distributable);
+            if (Boolean.TRUE == distributable) {
+                clusteringBuilders.build(jettyWebApp, earContext, moduleContext);
+                if (webModuleData.getReferencePatterns(JettyWebAppContext.GBEAN_REF_WEB_APPLICATION_HANDLER_FACTORY) == null) {
+                    log.warn("No clustering builders configured: app will not be clustered");
+                    configureNoClustering(moduleContext, webModuleData);
+                }
+            } else {
+                configureNoClustering(moduleContext, webModuleData);
+            }
+            
             webModuleData.setAttribute("sessionTimeoutSeconds",
                     (webApp.getSessionConfigArray().length == 1 && webApp.getSessionConfigArray(0).getSessionTimeout() != null) ?
                             new Integer(webApp.getSessionConfigArray(0).getSessionTimeout().getBigIntegerValue().intValue() * 60) :
                             defaultSessionTimeoutSeconds);
 
-            MimeMappingType[] mimeMappingArray = webApp.getMimeMappingArray();
-            Map mimeMappingMap = new HashMap();
-            for (int i = 0; i < mimeMappingArray.length; i++) {
-                MimeMappingType mimeMappingType = mimeMappingArray[i];
-                mimeMappingMap.put(mimeMappingType.getExtension().getStringValue(), mimeMappingType.getMimeType().getStringValue());
-            }
-            webModuleData.setAttribute("mimeMap", mimeMappingMap);
-
-            WelcomeFileListType[] welcomeFileArray = webApp.getWelcomeFileListArray();
-            List welcomeFiles;
-            if (welcomeFileArray.length > 0) {
-                welcomeFiles = new ArrayList();
-                for (int i = 0; i < welcomeFileArray.length; i++) {
-                    String[] welcomeFileListType = welcomeFileArray[i].getWelcomeFileArray();
-                    for (int j = 0; j < welcomeFileListType.length; j++) {
-                        String welcomeFile = welcomeFileListType[j].trim();
-                        welcomeFiles.add(welcomeFile);
-                    }
-                }
-            } else {
-                welcomeFiles = new ArrayList(defaultWelcomeFiles);
-            }
-            webModuleData.setAttribute("welcomeFiles", welcomeFiles.toArray(new String[welcomeFiles.size()]));
+            // configure mime mappings.
+            configureMimeMappings(webApp, webModuleData);
 
-            LocaleEncodingMappingListType[] localeEncodingMappingListArray = webApp.getLocaleEncodingMappingListArray();
-            Map localeEncodingMappingMap = new HashMap();
-            for (int i = 0; i < localeEncodingMappingListArray.length; i++) {
-                LocaleEncodingMappingType[] localeEncodingMappingArray = localeEncodingMappingListArray[i].getLocaleEncodingMappingArray();
-                for (int j = 0; j < localeEncodingMappingArray.length; j++) {
-                    LocaleEncodingMappingType localeEncodingMapping = localeEncodingMappingArray[j];
-                    localeEncodingMappingMap.put(localeEncodingMapping.getLocale(), localeEncodingMapping.getEncoding());
-                }
-            }
-            webModuleData.setAttribute("localeEncodingMapping", localeEncodingMappingMap);
+            // configure welcome file lists.
+            configureWelcomeFileLists(webApp, webModuleData);
 
-            ErrorPageType[] errorPageArray = webApp.getErrorPageArray();
-            Map errorPageMap = new HashMap();
-            for (int i = 0; i < errorPageArray.length; i++) {
-                ErrorPageType errorPageType = errorPageArray[i];
-                if (errorPageType.isSetErrorCode()) {
-                    errorPageMap.put(errorPageType.getErrorCode().getStringValue(), errorPageType.getLocation().getStringValue());
-                } else {
-                    errorPageMap.put(errorPageType.getExceptionType().getStringValue(), errorPageType.getLocation().getStringValue());
-                }
-            }
-            webModuleData.setAttribute("errorPages", errorPageMap);
+            // configure local encoding mapping lists.
+            configureLocalEncodingMappingLists(webApp, webModuleData);
 
-            JspConfigType[] jspConfigArray = webApp.getJspConfigArray();
-            if (jspConfigArray.length > 1) {
-                throw new DeploymentException("Web app " + module.getName() + " cannot have more than one jsp-config element.  Currently has " + jspConfigArray.length + " jsp-config elements.");
-            }
-            Map tagLibMap = new HashMap();
-            for (int i = 0; i < jspConfigArray.length; i++) {
-                TaglibType[] tagLibArray = jspConfigArray[i].getTaglibArray();
-                for (int j = 0; j < tagLibArray.length; j++) {
-                    TaglibType taglib = tagLibArray[j];
-                    tagLibMap.put(taglib.getTaglibUri().getStringValue().trim(), taglib.getTaglibLocation().getStringValue().trim());
-                }
-            }
-            webModuleData.setAttribute("tagLibMap", tagLibMap);
+            // configure error pages.
+            configureErrorPages(webApp, webModuleData);
 
-            LoginConfigType[] loginConfigArray = webApp.getLoginConfigArray();
-            if (loginConfigArray.length > 1) {
-                throw new DeploymentException("Web app " + module.getName() + " cannot have more than one login-config element.  Currently has " + loginConfigArray.length + " login-config elements.");
-            }
-            if (loginConfigArray.length == 1) {
-                LoginConfigType loginConfig = loginConfigArray[0];
-                if (loginConfig.isSetAuthMethod()) {
-                    String authMethod = loginConfig.getAuthMethod().getStringValue();
-                    if ("BASIC".equals(authMethod)) {
-                        webModuleData.setAttribute("authenticator", new BasicAuthenticator());
-                    } else if ("DIGEST".equals(authMethod)) {
-                        webModuleData.setAttribute("authenticator", new DigestAuthenticator());
-                    } else if ("FORM".equals(authMethod)) {
-
-                        FormAuthenticator formAuthenticator = new FormAuthenticator();
-                        webModuleData.setAttribute("authenticator", formAuthenticator);
-                        if (loginConfig.isSetFormLoginConfig()) {
-                            FormLoginConfigType formLoginConfig = loginConfig.getFormLoginConfig();
-                            formAuthenticator.setLoginPage(formLoginConfig.getFormLoginPage().getStringValue());
-                            formAuthenticator.setErrorPage(formLoginConfig.getFormErrorPage().getStringValue());
-                        }
-                    } else if ("CLIENT-CERT".equals(authMethod)) {
-                        webModuleData.setAttribute("authenticator", new ClientCertAuthenticator());
-                    }
-                }
-                if (loginConfig.isSetRealmName()) {
-                    webModuleData.setAttribute("realmName", loginConfig.getRealmName().getStringValue());
-                }
+            // configure tag libs.
+            configureTagLibs(module, webApp, webModuleData);
 
-            } else if (jettyWebApp.isSetSecurityRealmName()) {
-                webModuleData.setAttribute("authenticator", new NonAuthenticator());
-            }
-            moduleContext.addGBean(webModuleData);
-
-            // Make sure that servlet mappings point to available servlets
-            ServletType[] servletTypes = webApp.getServletArray();
-            Set knownServlets = new HashSet();
-            for (int i = 0; i < servletTypes.length; i++) {
-                ServletType type = servletTypes[i];
-                knownServlets.add(type.getServletName().getStringValue().trim());
-            }
-            //never add a duplicate pattern.
+            // configure login configs.
+            configureLoginConfigs(module, webApp, jettyWebApp, webModuleData);
+            
+            // Make sure that servlet mappings point to available servlets and never add a duplicate pattern.
             Set knownServletMappings = new HashSet();
-
-            ServletMappingType[] servletMappingArray = webApp.getServletMappingArray();
             Map servletMappings = new HashMap();
-            for (int i = 0; i < servletMappingArray.length; i++) {
-                ServletMappingType servletMappingType = servletMappingArray[i];
-                String servletName = servletMappingType.getServletName().getStringValue().trim();
-                if (!knownServlets.contains(servletName)) {
-                    throw new DeploymentException("Web app " + module.getName() +
-                            " contains a servlet mapping that refers to servlet '" + servletName +
-                            "' but no such servlet was found!");
-                }
-                String urlPattern = servletMappingType.getUrlPattern().getStringValue().trim();
-                if (!knownServletMappings.contains(urlPattern)) {
-                    knownServletMappings.add(urlPattern);
-                    checkString(urlPattern);
-                    Set urlsForServlet = (Set) servletMappings.get(servletName);
-                    if (urlsForServlet == null) {
-                        urlsForServlet = new HashSet();
-                        servletMappings.put(servletName, urlsForServlet);
-                    }
-                    urlsForServlet.add(urlPattern);
-                }
-            }
+
+            buildServletMappings(module, webApp, servletMappings, knownServletMappings);
 
             //"previous" filter mapping for linked list to keep dd's ordering.
             AbstractName previous = null;
 
             //add default filters
             if (defaultFilters != null) {
-                for (Iterator iterator = defaultFilters.iterator(); iterator.hasNext();) {
-                    Object defaultFilter = iterator.next();
-                    GBeanData filterGBeanData = getGBeanData(kernel, defaultFilter);
-                    String filterName = (String) filterGBeanData.getAttribute("filterName");
-                    AbstractName defaultFilterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER);
-                    filterGBeanData.setAbstractName(defaultFilterAbstractName);
-                    filterGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
-                    moduleContext.addGBean(filterGBeanData);
-                    //add a mapping to /*
-
-                    GBeanData filterMappingGBeanData = new GBeanData(JettyFilterMapping.GBEAN_INFO);
-                    if (previous != null) {
-                        filterMappingGBeanData.setReferencePattern("Previous", previous);
-                    }
-                    filterMappingGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
-                    String urlPattern = "/*";
-                    filterMappingGBeanData.setAttribute("urlPattern", urlPattern);
-                    AbstractName filterMappingName = earContext.getNaming().createChildName(defaultFilterAbstractName, urlPattern, NameFactory.URL_WEB_FILTER_MAPPING);
-                    filterMappingGBeanData.setAbstractName(filterMappingName);
-                    previous = filterMappingName;
-
-
-                    filterMappingGBeanData.setAttribute("requestDispatch", Boolean.TRUE);
-                    filterMappingGBeanData.setAttribute("forwardDispatch", Boolean.TRUE);
-                    filterMappingGBeanData.setAttribute("includeDispatch", Boolean.TRUE);
-                    filterMappingGBeanData.setAttribute("errorDispatch", Boolean.FALSE);
-                    filterMappingGBeanData.setReferencePattern("Filter", defaultFilterAbstractName);
-                    moduleContext.addGBean(filterMappingGBeanData);
-                }
+                previous = addDefaultFiltersGBeans(earContext, moduleContext, moduleName, previous);
             }
 
             //add default filtermappings
@@ -610,124 +471,25 @@
 //                }
 //            }
 
-            FilterMappingType[] filterMappingArray = webApp.getFilterMappingArray();
-            for (int i = 0; i < filterMappingArray.length; i++) {
-                FilterMappingType filterMappingType = filterMappingArray[i];
-                String filterName = filterMappingType.getFilterName().getStringValue().trim();
-                GBeanData filterMappingData = new GBeanData(JettyFilterMapping.GBEAN_INFO);
-                if (previous != null) {
-                    filterMappingData.setReferencePattern("Previous", previous);
-                }
-                filterMappingData.setReferencePattern("JettyServletRegistration", moduleName);
-                AbstractName filterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER);
+            // add filter mapping GBeans.
+            addFilterMappingsGBeans(earContext, moduleContext, moduleName, webApp, previous);
 
-                AbstractName filterMappingName = null;
-                if (filterMappingType.isSetUrlPattern()) {
-                    String urlPattern = filterMappingType.getUrlPattern().getStringValue().trim();
-                    filterMappingData.setAttribute("urlPattern", urlPattern);
-                    filterMappingName = earContext.getNaming().createChildName(filterAbstractName, ObjectName.quote(urlPattern), NameFactory.URL_WEB_FILTER_MAPPING);
-                }
-                if (filterMappingType.isSetServletName()) {
-                    String servletName = filterMappingType.getServletName().getStringValue().trim();
-                    AbstractName servletAbstractName = earContext.getNaming().createChildName(moduleName, servletName, NameFactory.SERVLET);
-                    filterMappingData.setReferencePattern("Servlet", servletAbstractName);
-                    filterMappingName = earContext.getNaming().createChildName(filterAbstractName, servletName, NameFactory.SERVLET_WEB_FILTER_MAPPING);
-                }
-                filterMappingData.setAbstractName(filterMappingName);
-                previous = filterMappingName;
-
-                boolean request = filterMappingType.getDispatcherArray().length == 0;
-                boolean forward = false;
-                boolean include = false;
-                boolean error = false;
-                for (int j = 0; j < filterMappingType.getDispatcherArray().length; j++) {
-                    DispatcherType dispatcherType = filterMappingType.getDispatcherArray()[j];
-                    if (dispatcherType.getStringValue().equals("REQUEST")) {
-                        request = true;
-                    } else if (dispatcherType.getStringValue().equals("FORWARD")) {
-                        forward = true;
-                    } else if (dispatcherType.getStringValue().equals("INCLUDE")) {
-                        include = true;
-                    } else if (dispatcherType.getStringValue().equals("ERROR")) {
-                        error = true;
-                    }
-                }
-                filterMappingData.setAttribute("requestDispatch", Boolean.valueOf(request));
-                filterMappingData.setAttribute("forwardDispatch", Boolean.valueOf(forward));
-                filterMappingData.setAttribute("includeDispatch", Boolean.valueOf(include));
-                filterMappingData.setAttribute("errorDispatch", Boolean.valueOf(error));
-                filterMappingData.setReferencePattern("Filter", filterAbstractName);
-                moduleContext.addGBean(filterMappingData);
-            }
-
-            FilterType[] filterArray = webApp.getFilterArray();
-            for (int i = 0; i < filterArray.length; i++) {
-                FilterType filterType = filterArray[i];
-                String filterName = filterType.getFilterName().getStringValue().trim();
-                AbstractName filterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER);
-                GBeanData filterData = new GBeanData(filterAbstractName, JettyFilterHolder.GBEAN_INFO);
-                filterData.setAttribute("filterName", filterName);
-                filterData.setAttribute("filterClass", filterType.getFilterClass().getStringValue().trim());
-                Map initParams = new HashMap();
-                ParamValueType[] initParamArray = filterType.getInitParamArray();
-                for (int j = 0; j < initParamArray.length; j++) {
-                    ParamValueType paramValueType = initParamArray[j];
-                    initParams.put(paramValueType.getParamName().getStringValue().trim(), paramValueType.getParamValue().getStringValue().trim());
-                }
-                filterData.setAttribute("initParams", initParams);
-                filterData.setReferencePattern("JettyServletRegistration", moduleName);
-                moduleContext.addGBean(filterData);
-            }
+            // add filter GBeans.
+            addFiltersGBeans(earContext, moduleContext, moduleName, webApp);
 
             //add default servlets
             if (defaultServlets != null) {
-                for (Iterator iterator = defaultServlets.iterator(); iterator.hasNext();) {
-                    Object defaultServlet = iterator.next();
-                    GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet);
-                    AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName, (String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET);
-                    servletGBeanData.setAbstractName(defaultServletObjectName);
-                    servletGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
-                    Set defaultServletMappings = new HashSet((Collection) servletGBeanData.getAttribute("servletMappings"));
-                    defaultServletMappings.removeAll(knownServletMappings);
-                    servletGBeanData.setAttribute("servletMappings", defaultServletMappings);
-                    moduleContext.addGBean(servletGBeanData);
-                }
+                addDefaultServletsGBeans(earContext, moduleContext, moduleName, knownServletMappings);
             }
 
             //set up servlet gbeans.
             Map portMap = webModule.getPortMap();
 
+            ServletType[] servletTypes = webApp.getServletArray();
             addServlets(moduleName, webModule.getModuleFile(), servletTypes, servletMappings, securityRoles, rolePermissions, portMap, moduleClassLoader, moduleContext);
 
             if (jettyWebApp.isSetSecurityRealmName()) {
-                if (earContext.getSecurityConfiguration() == null) {
-                    throw new DeploymentException("You have specified a <security-realm-name> for the webapp " + moduleName + " but no <security> configuration (role mapping) is supplied in the Geronimo plan for the web application (or the Geronimo plan for the EAR if the web app is in an EAR)");
-                }
-                String securityRealmName = jettyWebApp.getSecurityRealmName().trim();
-                webModuleData.setAttribute("securityRealmName", securityRealmName);
-
-                /**
-                 * TODO - go back to commented version when possible.
-                 */
-                String policyContextID = moduleName.toString().replaceAll("[, :]", "_");
-                //String policyContextID = webModuleName.getCanonicalName();
-                webModuleData.setAttribute("policyContextID", policyContextID);
-
-                ComponentPermissions componentPermissions = buildSpecSecurityConfig(webApp, securityRoles, rolePermissions);
-                webModuleData.setAttribute("excludedPermissions", componentPermissions.getExcludedPermissions());
-                PermissionCollection checkedPermissions = new Permissions();
-                for (Iterator iterator = rolePermissions.values().iterator(); iterator.hasNext();) {
-                    PermissionCollection permissionsForRole = (PermissionCollection) iterator.next();
-                    for (Enumeration iterator2 = permissionsForRole.elements(); iterator2.hasMoreElements();) {
-                        Permission permission = (Permission) iterator2.nextElement();
-                        checkedPermissions.add(permission);
-                    }
-                }
-                webModuleData.setAttribute("checkedPermissions", checkedPermissions);
-
-                earContext.addSecurityContext(policyContextID, componentPermissions);
-                DefaultPrincipal defaultPrincipal = ((SecurityConfiguration) earContext.getSecurityConfiguration()).getDefaultPrincipal();
-                webModuleData.setAttribute("defaultPrincipal", defaultPrincipal);
+                configureSecurityRealm(earContext, webApp, jettyWebApp, webModuleData, securityRoles, rolePermissions);
             }
             if (!module.isStandAlone()) {
                 ConfigurationData moduleConfigurationData = moduleContext.getConfigurationData();
@@ -740,6 +502,346 @@
         }
     }
 
+    private void configureNoClustering(EARContext moduleContext, GBeanData webModuleData) throws GBeanAlreadyExistsException {
+        AbstractName name = moduleContext.getNaming().createChildName(moduleContext.getModuleName(), 
+                "DefaultWebApplicationHandlerFactory", 
+                NameFactory.GERONIMO_SERVICE);
+        GBeanData beanData = new GBeanData(name, DefaultWebApplicationHandlerFactory.GBEAN_INFO);
+        webModuleData.setReferencePattern(JettyWebAppContext.GBEAN_REF_WEB_APPLICATION_HANDLER_FACTORY, name);
+        moduleContext.addGBean(beanData);
+    }
+
+    private void configureSecurityRealm(EARContext earContext, WebAppType webApp, JettyWebAppType jettyWebApp, GBeanData webModuleData, Set securityRoles, Map rolePermissions) throws DeploymentException {
+        AbstractName moduleName = webModuleData.getAbstractName();
+        if (earContext.getSecurityConfiguration() == null) {
+            throw new DeploymentException("You have specified a <security-realm-name> for the webapp " + moduleName + " but no <security> configuration (role mapping) is supplied in the Geronimo plan for the web application (or the Geronimo plan for the EAR if the web app is in an EAR)");
+        }
+        String securityRealmName = jettyWebApp.getSecurityRealmName().trim();
+        webModuleData.setAttribute("securityRealmName", securityRealmName);
+
+        /**
+         * TODO - go back to commented version when possible.
+         */
+        String policyContextID = moduleName.toString().replaceAll("[, :]", "_");
+        //String policyContextID = webModuleName.getCanonicalName();
+        webModuleData.setAttribute("policyContextID", policyContextID);
+
+        ComponentPermissions componentPermissions = buildSpecSecurityConfig(webApp, securityRoles, rolePermissions);
+        webModuleData.setAttribute("excludedPermissions", componentPermissions.getExcludedPermissions());
+        PermissionCollection checkedPermissions = new Permissions();
+        for (Iterator iterator = rolePermissions.values().iterator(); iterator.hasNext();) {
+            PermissionCollection permissionsForRole = (PermissionCollection) iterator.next();
+            for (Enumeration iterator2 = permissionsForRole.elements(); iterator2.hasMoreElements();) {
+                Permission permission = (Permission) iterator2.nextElement();
+                checkedPermissions.add(permission);
+            }
+        }
+        webModuleData.setAttribute("checkedPermissions", checkedPermissions);
+
+        earContext.addSecurityContext(policyContextID, componentPermissions);
+        DefaultPrincipal defaultPrincipal = ((SecurityConfiguration) earContext.getSecurityConfiguration()).getDefaultPrincipal();
+        webModuleData.setAttribute("defaultPrincipal", defaultPrincipal);
+    }
+
+    private void addDefaultServletsGBeans(EARContext earContext, EARContext moduleContext, AbstractName moduleName, Set knownServletMappings) throws GBeanNotFoundException, GBeanAlreadyExistsException {
+        for (Iterator iterator = defaultServlets.iterator(); iterator.hasNext();) {
+            Object defaultServlet = iterator.next();
+            GBeanData servletGBeanData = getGBeanData(kernel, defaultServlet);
+            AbstractName defaultServletObjectName = earContext.getNaming().createChildName(moduleName, (String) servletGBeanData.getAttribute("servletName"), NameFactory.SERVLET);
+            servletGBeanData.setAbstractName(defaultServletObjectName);
+            servletGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
+            Set defaultServletMappings = new HashSet((Collection) servletGBeanData.getAttribute("servletMappings"));
+            defaultServletMappings.removeAll(knownServletMappings);
+            servletGBeanData.setAttribute("servletMappings", defaultServletMappings);
+            moduleContext.addGBean(servletGBeanData);
+        }
+    }
+
+    private void addFiltersGBeans(EARContext earContext, EARContext moduleContext, AbstractName moduleName, WebAppType webApp) throws GBeanAlreadyExistsException {
+        FilterType[] filterArray = webApp.getFilterArray();
+        for (int i = 0; i < filterArray.length; i++) {
+            FilterType filterType = filterArray[i];
+            String filterName = filterType.getFilterName().getStringValue().trim();
+            AbstractName filterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER);
+            GBeanData filterData = new GBeanData(filterAbstractName, JettyFilterHolder.GBEAN_INFO);
+            filterData.setAttribute("filterName", filterName);
+            filterData.setAttribute("filterClass", filterType.getFilterClass().getStringValue().trim());
+            Map initParams = new HashMap();
+            ParamValueType[] initParamArray = filterType.getInitParamArray();
+            for (int j = 0; j < initParamArray.length; j++) {
+                ParamValueType paramValueType = initParamArray[j];
+                initParams.put(paramValueType.getParamName().getStringValue().trim(), paramValueType.getParamValue().getStringValue().trim());
+            }
+            filterData.setAttribute("initParams", initParams);
+            filterData.setReferencePattern("JettyServletRegistration", moduleName);
+            moduleContext.addGBean(filterData);
+        }
+    }
+
+    private void addFilterMappingsGBeans(EARContext earContext, EARContext moduleContext, AbstractName moduleName, WebAppType webApp, AbstractName previous) throws GBeanAlreadyExistsException {
+        FilterMappingType[] filterMappingArray = webApp.getFilterMappingArray();
+        for (int i = 0; i < filterMappingArray.length; i++) {
+            FilterMappingType filterMappingType = filterMappingArray[i];
+            String filterName = filterMappingType.getFilterName().getStringValue().trim();
+            GBeanData filterMappingData = new GBeanData(JettyFilterMapping.GBEAN_INFO);
+            if (previous != null) {
+                filterMappingData.setReferencePattern("Previous", previous);
+            }
+            filterMappingData.setReferencePattern("JettyServletRegistration", moduleName);
+            AbstractName filterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER);
+
+            AbstractName filterMappingName = null;
+            if (filterMappingType.isSetUrlPattern()) {
+                String urlPattern = filterMappingType.getUrlPattern().getStringValue().trim();
+                filterMappingData.setAttribute("urlPattern", urlPattern);
+                filterMappingName = earContext.getNaming().createChildName(filterAbstractName, ObjectName.quote(urlPattern), NameFactory.URL_WEB_FILTER_MAPPING);
+            }
+            if (filterMappingType.isSetServletName()) {
+                String servletName = filterMappingType.getServletName().getStringValue().trim();
+                AbstractName servletAbstractName = earContext.getNaming().createChildName(moduleName, servletName, NameFactory.SERVLET);
+                filterMappingData.setReferencePattern("Servlet", servletAbstractName);
+                filterMappingName = earContext.getNaming().createChildName(filterAbstractName, servletName, NameFactory.SERVLET_WEB_FILTER_MAPPING);
+            }
+            filterMappingData.setAbstractName(filterMappingName);
+            previous = filterMappingName;
+
+            boolean request = filterMappingType.getDispatcherArray().length == 0;
+            boolean forward = false;
+            boolean include = false;
+            boolean error = false;
+            for (int j = 0; j < filterMappingType.getDispatcherArray().length; j++) {
+                DispatcherType dispatcherType = filterMappingType.getDispatcherArray()[j];
+                if (dispatcherType.getStringValue().equals("REQUEST")) {
+                    request = true;
+                } else if (dispatcherType.getStringValue().equals("FORWARD")) {
+                    forward = true;
+                } else if (dispatcherType.getStringValue().equals("INCLUDE")) {
+                    include = true;
+                } else if (dispatcherType.getStringValue().equals("ERROR")) {
+                    error = true;
+                }
+            }
+            filterMappingData.setAttribute("requestDispatch", Boolean.valueOf(request));
+            filterMappingData.setAttribute("forwardDispatch", Boolean.valueOf(forward));
+            filterMappingData.setAttribute("includeDispatch", Boolean.valueOf(include));
+            filterMappingData.setAttribute("errorDispatch", Boolean.valueOf(error));
+            filterMappingData.setReferencePattern("Filter", filterAbstractName);
+            moduleContext.addGBean(filterMappingData);
+        }
+    }
+
+    private AbstractName addDefaultFiltersGBeans(EARContext earContext, EARContext moduleContext, AbstractName moduleName, AbstractName previous) throws GBeanNotFoundException, GBeanAlreadyExistsException {
+        for (Iterator iterator = defaultFilters.iterator(); iterator.hasNext();) {
+            Object defaultFilter = iterator.next();
+            GBeanData filterGBeanData = getGBeanData(kernel, defaultFilter);
+            String filterName = (String) filterGBeanData.getAttribute("filterName");
+            AbstractName defaultFilterAbstractName = earContext.getNaming().createChildName(moduleName, filterName, NameFactory.WEB_FILTER);
+            filterGBeanData.setAbstractName(defaultFilterAbstractName);
+            filterGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
+            moduleContext.addGBean(filterGBeanData);
+            //add a mapping to /*
+
+            GBeanData filterMappingGBeanData = new GBeanData(JettyFilterMapping.GBEAN_INFO);
+            if (previous != null) {
+                filterMappingGBeanData.setReferencePattern("Previous", previous);
+            }
+            filterMappingGBeanData.setReferencePattern("JettyServletRegistration", moduleName);
+            String urlPattern = "/*";
+            filterMappingGBeanData.setAttribute("urlPattern", urlPattern);
+            AbstractName filterMappingName = earContext.getNaming().createChildName(defaultFilterAbstractName, urlPattern, NameFactory.URL_WEB_FILTER_MAPPING);
+            filterMappingGBeanData.setAbstractName(filterMappingName);
+            previous = filterMappingName;
+
+
+            filterMappingGBeanData.setAttribute("requestDispatch", Boolean.TRUE);
+            filterMappingGBeanData.setAttribute("forwardDispatch", Boolean.TRUE);
+            filterMappingGBeanData.setAttribute("includeDispatch", Boolean.TRUE);
+            filterMappingGBeanData.setAttribute("errorDispatch", Boolean.FALSE);
+            filterMappingGBeanData.setReferencePattern("Filter", defaultFilterAbstractName);
+            moduleContext.addGBean(filterMappingGBeanData);
+        }
+        return previous;
+    }
+
+    private Map buildServletMappings(Module module, WebAppType webApp, Map servletMappings, Set knownServletMappings) throws DeploymentException {
+        ServletType[] servletTypes = webApp.getServletArray();
+        Set knownServlets = new HashSet();
+        for (int i = 0; i < servletTypes.length; i++) {
+            ServletType type = servletTypes[i];
+            knownServlets.add(type.getServletName().getStringValue().trim());
+        }
+
+        ServletMappingType[] servletMappingArray = webApp.getServletMappingArray();
+        for (int i = 0; i < servletMappingArray.length; i++) {
+            ServletMappingType servletMappingType = servletMappingArray[i];
+            String servletName = servletMappingType.getServletName().getStringValue().trim();
+            if (!knownServlets.contains(servletName)) {
+                throw new DeploymentException("Web app " + module.getName() +
+                        " contains a servlet mapping that refers to servlet '" + servletName +
+                        "' but no such servlet was found!");
+            }
+            String urlPattern = servletMappingType.getUrlPattern().getStringValue().trim();
+            if (!knownServletMappings.contains(urlPattern)) {
+                knownServletMappings.add(urlPattern);
+                checkString(urlPattern);
+                Set urlsForServlet = (Set) servletMappings.get(servletName);
+                if (urlsForServlet == null) {
+                    urlsForServlet = new HashSet();
+                    servletMappings.put(servletName, urlsForServlet);
+                }
+                urlsForServlet.add(urlPattern);
+            }
+        }
+        
+        return servletMappings;
+    }
+
+    private void configureLoginConfigs(Module module, WebAppType webApp, JettyWebAppType jettyWebApp, GBeanData webModuleData) throws DeploymentException {
+        LoginConfigType[] loginConfigArray = webApp.getLoginConfigArray();
+        if (loginConfigArray.length > 1) {
+            throw new DeploymentException("Web app " + module.getName() + " cannot have more than one login-config element.  Currently has " + loginConfigArray.length + " login-config elements.");
+        }
+        if (loginConfigArray.length == 1) {
+            LoginConfigType loginConfig = loginConfigArray[0];
+            if (loginConfig.isSetAuthMethod()) {
+                String authMethod = loginConfig.getAuthMethod().getStringValue();
+                if ("BASIC".equals(authMethod)) {
+                    webModuleData.setAttribute("authenticator", new BasicAuthenticator());
+                } else if ("DIGEST".equals(authMethod)) {
+                    webModuleData.setAttribute("authenticator", new DigestAuthenticator());
+                } else if ("FORM".equals(authMethod)) {
+
+                    FormAuthenticator formAuthenticator = new FormAuthenticator();
+                    webModuleData.setAttribute("authenticator", formAuthenticator);
+                    if (loginConfig.isSetFormLoginConfig()) {
+                        FormLoginConfigType formLoginConfig = loginConfig.getFormLoginConfig();
+                        formAuthenticator.setLoginPage(formLoginConfig.getFormLoginPage().getStringValue());
+                        formAuthenticator.setErrorPage(formLoginConfig.getFormErrorPage().getStringValue());
+                    }
+                } else if ("CLIENT-CERT".equals(authMethod)) {
+                    webModuleData.setAttribute("authenticator", new ClientCertAuthenticator());
+                }
+            }
+            if (loginConfig.isSetRealmName()) {
+                webModuleData.setAttribute("realmName", loginConfig.getRealmName().getStringValue());
+            }
+
+        } else if (jettyWebApp.isSetSecurityRealmName()) {
+            webModuleData.setAttribute("authenticator", new NonAuthenticator());
+        }
+    }
+
+    private void configureTagLibs(Module module, WebAppType webApp, GBeanData webModuleData) throws DeploymentException {
+        JspConfigType[] jspConfigArray = webApp.getJspConfigArray();
+        if (jspConfigArray.length > 1) {
+            throw new DeploymentException("Web app "+ module.getName() +" cannot have more than one jsp-config element.  Currently has " + jspConfigArray.length +" jsp-config elements.");
+        }
+        Map tagLibMap = new HashMap();
+        for (int i = 0; i < jspConfigArray.length; i++) {
+            TaglibType[] tagLibArray = jspConfigArray[i].getTaglibArray();
+            for (int j = 0; j < tagLibArray.length; j++) {
+                TaglibType taglib = tagLibArray[j];
+                tagLibMap.put(taglib.getTaglibUri().getStringValue().trim(), taglib.getTaglibLocation().getStringValue().trim());
+            }
+        }
+        webModuleData.setAttribute("tagLibMap", tagLibMap);
+    }
+
+    private void configureErrorPages(WebAppType webApp, GBeanData webModuleData) {
+        ErrorPageType[] errorPageArray = webApp.getErrorPageArray();
+        Map errorPageMap = new HashMap();
+        for (int i = 0; i < errorPageArray.length; i++) {
+            ErrorPageType errorPageType = errorPageArray[i];
+            if (errorPageType.isSetErrorCode()) {
+                errorPageMap.put(errorPageType.getErrorCode().getStringValue(), errorPageType.getLocation().getStringValue());
+            } else {
+                errorPageMap.put(errorPageType.getExceptionType().getStringValue(), errorPageType.getLocation().getStringValue());
+            }
+        }
+        webModuleData.setAttribute("errorPages", errorPageMap);
+    }
+
+    private void configureLocalEncodingMappingLists(WebAppType webApp, GBeanData webModuleData) {
+        LocaleEncodingMappingListType[] localeEncodingMappingListArray = webApp.getLocaleEncodingMappingListArray();
+        Map localeEncodingMappingMap = new HashMap();
+        for (int i = 0; i < localeEncodingMappingListArray.length; i++) {
+            LocaleEncodingMappingType[] localeEncodingMappingArray = localeEncodingMappingListArray[i].getLocaleEncodingMappingArray();
+            for (int j = 0; j < localeEncodingMappingArray.length; j++) {
+                LocaleEncodingMappingType localeEncodingMapping = localeEncodingMappingArray[j];
+                localeEncodingMappingMap.put(localeEncodingMapping.getLocale(), localeEncodingMapping.getEncoding());
+            }
+        }
+        webModuleData.setAttribute("localeEncodingMapping", localeEncodingMappingMap);
+    }
+
+    private void configureWelcomeFileLists(WebAppType webApp, GBeanData webModuleData) {
+        WelcomeFileListType[] welcomeFileArray = webApp.getWelcomeFileListArray();
+        List welcomeFiles;
+        if (welcomeFileArray.length > 0) {
+            welcomeFiles = new ArrayList();
+            for (int i = 0; i < welcomeFileArray.length; i++) {
+                String[] welcomeFileListType = welcomeFileArray[i].getWelcomeFileArray();
+                for (int j = 0; j < welcomeFileListType.length; j++) {
+                    String welcomeFile = welcomeFileListType[j].trim();
+                    welcomeFiles.add(welcomeFile);
+                }
+            }
+        } else {
+            welcomeFiles = new ArrayList(defaultWelcomeFiles);
+        }
+        webModuleData.setAttribute("welcomeFiles", welcomeFiles.toArray(new String[welcomeFiles.size()]));
+    }
+
+    private void configureMimeMappings(WebAppType webApp, GBeanData webModuleData) {
+        MimeMappingType[] mimeMappingArray = webApp.getMimeMappingArray();
+        Map mimeMappingMap = new HashMap();
+        for (int i = 0; i < mimeMappingArray.length; i++) {
+            MimeMappingType mimeMappingType = mimeMappingArray[i];
+            mimeMappingMap.put(mimeMappingType.getExtension().getStringValue(), mimeMappingType.getMimeType().getStringValue());
+        }
+        webModuleData.setAttribute("mimeMap", mimeMappingMap);
+    }
+
+    private void configureListeners(WebAppType webApp, GBeanData webModuleData) {
+        ListenerType[] listenerArray = webApp.getListenerArray();
+        Collection listeners = new ArrayList();
+        for (int i = 0; i < listenerArray.length; i++) {
+            ListenerType listenerType = listenerArray[i];
+            listeners.add(listenerType.getListenerClass().getStringValue());
+        }
+        webModuleData.setAttribute("listenerClassNames", listeners);
+    }
+
+    private void configureContextParams(WebAppType webApp, GBeanData webModuleData) {
+        ParamValueType[] contextParamArray = webApp.getContextParamArray();
+        Map contextParams = new HashMap();
+        for (int i = 0; i < contextParamArray.length; i++) {
+            ParamValueType contextParam = contextParamArray[i];
+            contextParams.put(contextParam.getParamName().getStringValue().trim(), contextParam.getParamValue().getStringValue().trim());
+        }
+        webModuleData.setAttribute("contextParamMap", contextParams);
+    }
+
+    private void configureHosts(EARContext earContext, JettyWebAppType jettyWebApp, GBeanData webModuleData) throws GBeanAlreadyExistsException {
+        String[] hosts = jettyWebApp.getHostArray();
+        for (int i = 0; i < hosts.length; i++) {
+            hosts[i] = hosts[i].trim();
+        }
+        String[] virtualHosts = jettyWebApp.getVirtualHostArray();
+        for (int i = 0; i < virtualHosts.length; i++) {
+            virtualHosts[i] = virtualHosts[i].trim();
+        }
+        if (hosts.length > 0 || virtualHosts.length > 0) {
+            //use name same as module
+            AbstractName hostName = earContext.getNaming().createChildName(webModuleData.getAbstractName(), "Host", "Host");
+            GBeanData hostData = new GBeanData(hostName, Host.GBEAN_INFO);
+            hostData.setAttribute("hosts", hosts);
+            hostData.setAttribute("virtualHosts", virtualHosts);
+            earContext.addGBean(hostData);
+            webModuleData.setReferencePattern("Host", hostName);
+        }
+    }
+
     public String getSchemaNamespace() {
         return JETTY_NAMESPACE;
     }
@@ -918,6 +1020,7 @@
         infoBuilder.addReference("DefaultFilterMappings", Object.class);
         infoBuilder.addReference("PojoWebServiceTemplate", Object.class, NameFactory.SERVLET_WEB_SERVICE_TEMPLATE);
         infoBuilder.addReference("WebServiceBuilder", WebServiceBuilder.class, NameFactory.MODULE_BUILDER);
+        infoBuilder.addReference("ClusteringBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("SecurityBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("ServiceBuilders", NamespaceDrivenBuilder.class, NameFactory.MODULE_BUILDER);
         infoBuilder.addReference("NamingBuilders", NamingBuilder.class, NameFactory.MODULE_BUILDER);
@@ -934,6 +1037,7 @@
                 "DefaultFilterMappings",
                 "PojoWebServiceTemplate",
                 "WebServiceBuilder",
+                "ClusteringBuilders",
                 "SecurityBuilders",
                 "ServiceBuilders",
                 "NamingBuilders",

Modified: geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/schema/geronimo-jetty-1.2.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/schema/geronimo-jetty-1.2.xsd?view=diff&rev=446624&r1=446623&r2=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/schema/geronimo-jetty-1.2.xsd (original)
+++ geronimo/server/trunk/modules/geronimo-jetty-builder/src/main/schema/geronimo-jetty-1.2.xsd Fri Sep 15 08:02:12 2006
@@ -41,7 +41,8 @@
             <xs:element ref="sys:environment" minOccurs="0"/>
 
             <xs:element name="context-root" type="xs:string" minOccurs="0"/>
-            <!--<xs:element name="context-priority-classloader" type="xs:boolean" minOccurs="0"/>-->
+
+            <xs:element ref="app:clustering" minOccurs="0"/>
 
             <xs:element ref="naming:web-container" minOccurs="0"/>
 

Modified: geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java?view=diff&rev=446624&r1=446623&r2=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java Fri Sep 15 08:02:12 2006
@@ -83,7 +83,7 @@
  * @version $Rev:385232 $ $Date$
  */
 public class JettyModuleBuilderTest extends TestSupport {
-    
+
     private static Naming naming = new Jsr77Naming();
     private Artifact baseId = new Artifact("test", "base", "1", "car");
     private final AbstractName serverName = naming.createRootName(baseId, "Server", "J2EEServer");
@@ -265,7 +265,20 @@
 
         defaultEnvironment.addDependency(baseId, ImportType.ALL);
         defaultEnvironment.setConfigId(webModuleArtifact);
-        builder = new JettyModuleBuilder(defaultEnvironment, new Integer(1800), Collections.EMPTY_LIST, new AbstractNameQuery(containerName), defaultServlets, defaultFilters, defaultFilterMappings, pojoWebServiceTemplate, Collections.singleton(webServiceBuilder), Collections.singleton(new GeronimoSecurityBuilderImpl()), Collections.singleton(new GBeanBuilder(null, null)), new NamingBuilderCollection(null, null), kernel);
+        builder = new JettyModuleBuilder(defaultEnvironment,
+                         new Integer(1800),
+                         Collections.EMPTY_LIST,
+                         new AbstractNameQuery(containerName),
+                         defaultServlets,
+                         defaultFilters,
+                         defaultFilterMappings,
+                         pojoWebServiceTemplate,
+                         Collections.singleton(webServiceBuilder),
+                         null,
+                         Collections.singleton(new GeronimoSecurityBuilderImpl()),
+                         Collections.singleton(new GBeanBuilder(null, null)),
+                         new NamingBuilderCollection(null, null), 
+                         kernel);
     }
 
     protected void tearDown() throws Exception {

Modified: geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/PlanParsingTest.java?view=diff&rev=446624&r1=446623&r2=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/PlanParsingTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty-builder/src/test/java/org/apache/geronimo/jetty/deployment/PlanParsingTest.java Fri Sep 15 08:02:12 2006
@@ -1,8 +1,17 @@
 package org.apache.geronimo.jetty.deployment;
 
-import org.apache.geronimo.testsupport.TestSupport;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.jar.JarFile;
+  
+import javax.xml.namespace.QName;
 
 import org.apache.geronimo.deployment.util.UnpackedJarFile;
+import org.apache.geronimo.deployment.service.GBeanBuilder;
 import org.apache.geronimo.deployment.xbeans.ArtifactType;
 import org.apache.geronimo.deployment.xbeans.EnvironmentType;
 import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
@@ -17,6 +26,8 @@
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.schema.SchemaConversionUtils;
+import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
+import org.apache.geronimo.testsupport.TestSupport;
 import org.apache.geronimo.web.deployment.GenericToSpecificPlanConverter;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
 import org.apache.geronimo.xbeans.geronimo.web.jetty.JettyWebAppDocument;
@@ -24,19 +35,9 @@
 import org.apache.geronimo.xbeans.geronimo.web.jetty.config.GerJettyDocument;
 import org.apache.geronimo.xbeans.j2ee.WebAppDocument;
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
-import org.apache.geronimo.security.deployment.GeronimoSecurityBuilderImpl;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlObject;
 
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Collections;
-import java.util.jar.JarFile;
-
 /**
  */
 public class PlanParsingTest extends TestSupport {
@@ -53,7 +54,20 @@
     private JettyModuleBuilder builder;
 
     public PlanParsingTest() throws Exception {
-        builder = new JettyModuleBuilder(defaultEnvironment, new Integer(1800), null, jettyContainerObjectName, new HashSet(), new HashSet(), new HashSet(), pojoWebServiceTemplate, Collections.singleton(webServiceBuilder), Collections.singleton(new GeronimoSecurityBuilderImpl()), Collections.singleton(new GBeanBuilder(null, null)), new NamingBuilderCollection(null, null), null);
+        builder = new JettyModuleBuilder(defaultEnvironment,
+            new Integer(1800),
+            null,
+            jettyContainerObjectName,
+            new HashSet(),
+            new HashSet(),
+            new HashSet(),
+            pojoWebServiceTemplate,
+            Collections.singleton(webServiceBuilder),
+            null,
+            Collections.singleton(new GeronimoSecurityBuilderImpl()),
+            Collections.singleton(new GBeanBuilder(null, null)),
+            new NamingBuilderCollection(null, null), 
+            null);
     }
 
     public void testContents() throws Exception {

Modified: geronimo/server/trunk/modules/geronimo-jetty/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/pom.xml?view=diff&rev=446624&r1=446623&r2=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-jetty/pom.xml Fri Sep 15 08:02:12 2006
@@ -56,6 +56,12 @@
             <artifactId>geronimo-webservices</artifactId>
             <version>${pom.version}</version>
         </dependency>
+         
+         <dependency>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-clustering</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
         
         <dependency>
             <groupId>jetty</groupId>

Added: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/DefaultWebApplicationHandlerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/DefaultWebApplicationHandlerFactory.java?view=auto&rev=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/DefaultWebApplicationHandlerFactory.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/DefaultWebApplicationHandlerFactory.java Fri Sep 15 08:02:12 2006
@@ -0,0 +1,42 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.jetty;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.mortbay.jetty.servlet.WebApplicationHandler;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultWebApplicationHandlerFactory implements WebApplicationHandlerFactory {
+
+    public WebApplicationHandler createHandler() {
+        return new JettyWebApplicationHandler();
+    }
+    
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(DefaultWebApplicationHandlerFactory.class, NameFactory.GERONIMO_SERVICE);
+        infoBuilder.addInterface(WebApplicationHandlerFactory.class);
+        infoBuilder.setConstructor(new String[0]);
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/GeronimoServletHttpRequest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/GeronimoServletHttpRequest.java?view=auto&rev=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/GeronimoServletHttpRequest.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/GeronimoServletHttpRequest.java Fri Sep 15 08:02:12 2006
@@ -0,0 +1,72 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.jetty;
+
+import javax.servlet.http.Cookie;
+
+import org.mortbay.http.HttpRequest;
+import org.mortbay.jetty.servlet.ServletHandler;
+import org.mortbay.jetty.servlet.ServletHttpRequest;
+import org.mortbay.jetty.servlet.SessionManager;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoServletHttpRequest extends ServletHttpRequest {
+    private final ServletHandler servletHandler;
+    private final HttpRequest request;
+    private String requestedSessionId;
+    
+    public GeronimoServletHttpRequest(ServletHandler servletHandler, String pathInContext, HttpRequest request) {
+        super(servletHandler, pathInContext, request);
+        this.servletHandler = servletHandler;
+        this.request = request;
+    }
+    
+    public String getRequestedSessionId() {
+        return requestedSessionId;
+    }
+    
+    public void setRequestedSessionId(String pathParams) {
+        if (servletHandler.isUsingCookies()) {
+            Cookie[] cookies= request.getCookies();
+            if (cookies!=null && cookies.length>0) {
+                for (int i=0;i<cookies.length;i++) {
+                    if (SessionManager.__SessionCookie.equalsIgnoreCase(cookies[i].getName())) {
+                        if (null != requestedSessionId) {
+                            // Multiple jsessionid cookies. Probably due to
+                            // multiple paths and/or domains. Pick the first
+                            // known session or the last defined cookie.
+                            SessionManager manager = servletHandler.getSessionManager();
+                            if (manager!=null && manager.getHttpSession(requestedSessionId)!=null)
+                                break;
+                        }
+                        requestedSessionId = cookies[i].getValue();
+                    }
+                }
+            }
+        }
+            
+        // check if there is a url encoded session param.
+        if (null != pathParams && pathParams.startsWith(SessionManager.__SessionURL)) {
+            String id = pathParams.substring(SessionManager.__SessionURL.length() + 1);
+            if (null == requestedSessionId) {
+                requestedSessionId = id;
+            }
+        }
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/HandleInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/HandleInterceptor.java?view=auto&rev=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/HandleInterceptor.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/HandleInterceptor.java Fri Sep 15 08:02:12 2006
@@ -0,0 +1,35 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.jetty;
+
+import java.io.IOException;
+
+import org.mortbay.http.HttpException;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface HandleInterceptor {
+    void handle(String pathInContext, 
+            String pathParams, 
+            HttpRequest httpRequest, 
+            HttpResponse httpResponse,
+            HandleInterceptor end) throws HttpException, IOException;
+}

Modified: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&rev=446624&r1=446623&r2=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java Fri Sep 15 08:02:12 2006
@@ -46,7 +46,6 @@
 import org.apache.geronimo.jetty.interceptor.BeforeAfter;
 import org.apache.geronimo.jetty.interceptor.ComponentContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.InstanceContextBeforeAfter;
-import org.apache.geronimo.jetty.interceptor.RequestWrappingBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.SecurityContextBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.ThreadClassloaderBeforeAfter;
 import org.apache.geronimo.jetty.interceptor.WebApplicationContextBeforeAfter;
@@ -71,7 +70,8 @@
 import org.mortbay.jetty.servlet.FilterHolder;
 import org.mortbay.jetty.servlet.JSR154Filter;
 import org.mortbay.jetty.servlet.ServletHolder;
-import org.mortbay.jetty.servlet.SessionManager;
+import org.mortbay.jetty.servlet.ServletHttpRequest;
+import org.mortbay.jetty.servlet.ServletHttpResponse;
 import org.mortbay.jetty.servlet.WebApplicationContext;
 import org.mortbay.jetty.servlet.WebApplicationHandler;
 
@@ -93,6 +93,7 @@
     private final String webAppRoot;
     private final URL configurationBaseURL;
     private final WebApplicationHandler handler;
+    private final HandleInterceptor handleInterceptor;
     private String displayName;
     private final String[] welcomeFiles;
 
@@ -104,47 +105,6 @@
 
     private final Set servletNames = new HashSet();
 
-    private String sessionManager;
-
-
-    public static class SessionManagerConfiguration implements WebApplicationContext.Configuration {
-
-        private WebApplicationContext webAppContext;
-
-
-        public SessionManagerConfiguration() {
-        }
-
-
-        public void setWebApplicationContext(WebApplicationContext webAppContext) {
-            this.webAppContext = webAppContext;
-        }
-
-        public WebApplicationContext getWebApplicationContext() {
-            return this.webAppContext;
-        }
-
-        public void configureClassPath() throws Exception {
-        }
-
-        public void configureDefaults() throws Exception {
-        }
-
-
-        public void configureWebApp() throws Exception {
-            //setup a SessionManager
-            log.debug("About to configure a SessionManager");
-            String sessionManagerClassName = ((JettyWebAppContext) webAppContext).getSessionManager();
-            if (sessionManagerClassName != null) {
-                Class clazz = Thread.currentThread().getContextClassLoader().loadClass(sessionManagerClassName);
-                Object o = clazz.newInstance();
-                log.debug("Setting SessionManager type=" + clazz.getName() + " instance=" + o);
-                this.webAppContext.getServletHandler().setSessionManager((SessionManager) o);
-            }
-        }
-
-    }
-
     /**
      * @deprecated never use this... this is only here because Jetty WebApplicationContext is externalizable
      */
@@ -156,24 +116,22 @@
         jettyContainer = null;
         webAppRoot = null;
         handler = null;
+        handleInterceptor = null; 
         chain = null;
         contextLength = 0;
         securityInterceptor = null;
         welcomeFiles = null;
         objectName = null;
-        sessionManager = null;
         configurationBaseURL = null;
     }
 
     public JettyWebAppContext(String objectName,
-            String originalSpecDD,
-            String sessionManager,
-            Map componentContext,
-            ClassLoader classLoader,
-            URL configurationBaseUrl,
-            Set unshareableResources,
-            Set applicationManagedSecurityResources,
-
+                              String originalSpecDD,
+                              Map componentContext,
+                              ClassLoader classLoader,
+                              URL configurationBaseUrl,
+                              Set unshareableResources,
+                              Set applicationManagedSecurityResources,
             String displayName,
             Map contextParamMap,
             Collection listenerClassNames,
@@ -186,6 +144,8 @@
             String realmName,
             Map tagLibMap,
             int sessionTimeoutSeconds,
+                              WebApplicationHandlerFactory handlerFactory,
+                              HandleInterceptor handleInterceptor,
 
             String policyContextID,
             String securityRealmName,
@@ -216,11 +176,10 @@
             verifyObjectName(myObjectName);
         }
         this.configurationBaseURL = configurationBaseUrl;
-
         this.jettyContainer = jettyContainer;
-
         this.originalSpecDD = originalSpecDD;
-
+        this.handleInterceptor = handleInterceptor;
+        
         setConfigurationClassNames(new String[]{});
 
         webAppRoot = configurationBaseUrl.toString();
@@ -232,8 +191,7 @@
             setVirtualHosts(host.getVirtualHosts());
         }
 
-        //use our wrapper to avoid leaking subject back to the caller
-        handler = new JettyWebApplicationHandler();
+        handler = handlerFactory.createHandler();
         addHandler(handler);
 
         //stuff from spec dd
@@ -274,7 +232,6 @@
             securityInterceptor = null;
         }
 //      end JACC
-        interceptor = new RequestWrappingBeforeAfter(interceptor, handler);
         chain = interceptor;
         contextLength = index;
 
@@ -283,9 +240,6 @@
         handler.addFilterHolder(jsr154FilterHolder);
         jsr154FilterHolder.setInitParameter("unwrappedDispatch", "true");
         handler.addFilterPathMapping("/*", "jsr154", Dispatcher.__REQUEST | Dispatcher.__FORWARD | Dispatcher.__INCLUDE | Dispatcher.__ERROR);
-
-        configureSessionManager(sessionManager);
-
     }
 
 
@@ -357,7 +311,28 @@
         chain.after(context, httpRequest, httpResponse);
     }
 
+    public void handle(HttpRequest httpRequest, HttpResponse httpResponse) throws HttpException, IOException {
+        super.handle(httpRequest, httpResponse);
+    }
+    
+    public void handle(String pathInContext, String pathParams, HttpRequest httpRequest, HttpResponse httpResponse)
+            throws HttpException, IOException {
+        ServletHttpRequest request = (ServletHttpRequest) httpRequest.getWrapper();
+        if (null == request) {
+            request = new GeronimoServletHttpRequest(handler, null, httpRequest);
+            ((GeronimoServletHttpRequest) request).setRequestedSessionId(pathParams);
+            ServletHttpResponse response = new ServletHttpResponse(request, httpResponse);
+            httpRequest.setWrapper(request);
+            httpResponse.setWrapper(response);
+        }
 
+        if (null != handleInterceptor) {
+            handleInterceptor.handle(pathInContext, pathParams, httpRequest, httpResponse, new EndHandleInterceptor());   
+        } else {
+            super.handle(pathInContext, pathParams, httpRequest, httpResponse);
+        }
+    }
+    
     public ClassLoader getWebClassLoader() {
         return webClassLoader;
     }
@@ -515,26 +490,6 @@
         }
     }
 
-    public String getSessionManager() {
-        return this.sessionManager;
-    }
-
-
-    private void configureSessionManager(String sessionManagerClassName) {
-        this.sessionManager = sessionManagerClassName;
-        if (this.sessionManager != null) {
-            addConfiguration(SessionManagerConfiguration.class.getName());
-        }
-    }
-
-    private void addConfiguration(String configClassName) {
-        String[] configClassNames = getConfigurationClassNames();
-        String[] newConfigClassNames = new String[configClassNames == null ? 1 : configClassNames.length + 1];
-        System.arraycopy(configClassNames, 0, newConfigClassNames, 0, configClassNames.length);
-
-        newConfigClassNames[newConfigClassNames.length - 1] = configClassName;
-    }
-
     /**
      * ObjectName must match this pattern:
      * <p/>
@@ -591,8 +546,22 @@
         return super.checkSecurityConstraints(pathInContext, request, response);
     }
 
+    private void doHandle(String pathInContext, String pathParams, HttpRequest httpRequest, HttpResponse httpResponse)
+            throws HttpException, IOException {
+        super.handle(pathInContext, pathParams, httpRequest, httpResponse);
+    }
+    
+    private class EndHandleInterceptor implements HandleInterceptor {
 
+        public void handle(String pathInContext, String pathParams, HttpRequest httpRequest, HttpResponse httpResponse,
+                HandleInterceptor end) throws HttpException, IOException {
+            doHandle(pathInContext, pathParams, httpRequest, httpResponse);
+        }
+    }
+    
     public static final GBeanInfo GBEAN_INFO;
+    public static final String GBEAN_REF_WEB_APPLICATION_HANDLER_FACTORY = "WebApplicationHandlerFactory";
+    public static final String GBEAN_REF_HANDLE_INTERCEPTOR = "HandleInterceptor";
 
     static {
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("Jetty WebApplication Context", JettyWebAppContext.class, NameFactory.WEB_MODULE);
@@ -612,9 +581,10 @@
         infoBuilder.addAttribute("realmName", String.class, true);
         infoBuilder.addAttribute("tagLibMap", Map.class, true);
         infoBuilder.addAttribute("sessionTimeoutSeconds", int.class, true);
-
-
-        infoBuilder.addAttribute("sessionManager", String.class, true);
+        infoBuilder.addReference(GBEAN_REF_WEB_APPLICATION_HANDLER_FACTORY, WebApplicationHandlerFactory.class,
+                NameFactory.GERONIMO_SERVICE);
+        infoBuilder.addReference(GBEAN_REF_HANDLE_INTERCEPTOR, HandleInterceptor.class, NameFactory.GERONIMO_SERVICE);
+        
         infoBuilder.addAttribute("componentContext", Map.class, true);
         infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
         infoBuilder.addAttribute("configurationBaseUrl", URL.class, true);
@@ -652,7 +622,6 @@
         infoBuilder.setConstructor(new String[]{
                 "objectName",
                 "deploymentDescriptor",
-                "sessionManager",
                 "componentContext",
                 "classLoader",
                 "configurationBaseUrl",
@@ -671,6 +640,8 @@
                 "realmName",
                 "tagLibMap",
                 "sessionTimeoutSeconds",
+                GBEAN_REF_WEB_APPLICATION_HANDLER_FACTORY,
+                GBEAN_REF_HANDLE_INTERCEPTOR,
 
                 "policyContextID",
                 "securityRealmName",

Added: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/WebApplicationHandlerFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/WebApplicationHandlerFactory.java?view=auto&rev=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/WebApplicationHandlerFactory.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/WebApplicationHandlerFactory.java Fri Sep 15 08:02:12 2006
@@ -0,0 +1,27 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.jetty;
+
+import org.mortbay.jetty.servlet.WebApplicationHandler;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public interface WebApplicationHandlerFactory {
+    WebApplicationHandler createHandler();
+}

Added: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/cluster/AbstractClusteredHandleInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/cluster/AbstractClusteredHandleInterceptor.java?view=auto&rev=446624
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/cluster/AbstractClusteredHandleInterceptor.java (added)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/cluster/AbstractClusteredHandleInterceptor.java Fri Sep 15 08:02:12 2006
@@ -0,0 +1,88 @@
+/**
+ *
+ * Copyright 2006 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.jetty.cluster;
+
+import java.io.IOException;
+
+import org.apache.geronimo.clustering.ClusteredInvocation;
+import org.apache.geronimo.clustering.ClusteredInvocationException;
+import org.apache.geronimo.jetty.GeronimoServletHttpRequest;
+import org.apache.geronimo.jetty.HandleInterceptor;
+import org.mortbay.http.HttpException;
+import org.mortbay.http.HttpRequest;
+import org.mortbay.http.HttpResponse;
+
+/**
+ *
+ * @version $Rev$ $Date$
+ */
+public abstract class AbstractClusteredHandleInterceptor implements HandleInterceptor {
+
+    public void handle(String pathInContext, String pathParams, HttpRequest httpRequest, HttpResponse httpResponse,
+            HandleInterceptor end) throws HttpException, IOException {
+        ClusteredInvocation invocation = 
+            newClusteredInvocation(pathInContext, pathParams, httpRequest, httpResponse, end);
+        try {
+            invocation.invoke();
+        } catch (ClusteredInvocationException e) {
+            Throwable cause = e.getCause();
+            if (cause instanceof HttpException) {
+                throw (HttpException) cause;
+            } else if (cause instanceof IOException) {
+                throw (IOException) cause;
+            } else {
+                throw (IOException) new IOException().initCause(cause);
+            }
+        }
+    }
+    
+    protected abstract ClusteredInvocation newClusteredInvocation(String pathInContext, String pathParams,
+            HttpRequest request, HttpResponse response, HandleInterceptor end);
+    
+    protected abstract class WebClusteredInvocation implements ClusteredInvocation {
+        protected final String pathInContext; 
+        protected final String pathParams;
+        protected final HttpRequest request;
+        protected final HttpResponse response;
+        protected final HandleInterceptor end;
+        
+        public WebClusteredInvocation(String pathInContext, String pathParams, HttpRequest request,
+                HttpResponse response, HandleInterceptor end) {
+            this.pathInContext = pathInContext;
+            this.pathParams = pathParams;
+            this.request = request;
+            this.response = response;
+            this.end = end;
+
+            GeronimoServletHttpRequest servletHttpRequest = (GeronimoServletHttpRequest) request.getWrapper();
+            servletHttpRequest.setRequestedSessionId(pathParams);
+        }
+
+        protected void invokeLocally() throws ClusteredInvocationException {
+            try {
+                end.handle(pathInContext, pathParams, request, response, null);
+            } catch (IOException e) {
+                throw new ClusteredInvocationException(e);
+            }
+        }
+
+        public String getRequestedSessionId() {
+            GeronimoServletHttpRequest servletHttpRequest = (GeronimoServletHttpRequest) request.getWrapper();
+            return servletHttpRequest.getRequestedSessionId();
+        }
+    }
+}



Mime
View raw message