geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r522036 [2/2] - in /geronimo/server/trunk: ./ assemblies/geronimo-jetty6-jee5/ assemblies/geronimo-jetty6-jee5/src/main/resources/var/config/ assemblies/geronimo-tomcat6-jee5/ configs/ configs/ca-helper-jetty/ configs/ca-helper-tomcat/ conf...
Date Sat, 24 Mar 2007 14:38:07 GMT
Added: geronimo/server/trunk/modules/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/JasperServletContextCustomizer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/JasperServletContextCustomizer.java?view=auto&rev=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/JasperServletContextCustomizer.java (added)
+++ geronimo/server/trunk/modules/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/JasperServletContextCustomizer.java Sat Mar 24 07:38:03 2007
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.jasper;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.catalina.lifecycle.LifecycleProvider;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.RuntimeCustomizer;
+import org.apache.geronimo.j2ee.annotation.Holder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class JasperServletContextCustomizer implements RuntimeCustomizer {
+    private final Holder holder;
+    private final ClassLoader classLoader;
+
+
+    public JasperServletContextCustomizer(Holder holder, ClassLoader classLoader) {
+        this.holder = holder;
+        this.classLoader = classLoader;
+    }
+
+    public void customize(Map<Class, Object> context) {
+        Map<String, Object> servletContext = (Map<String, Object>) context.get(Map.class);
+        Context jndiContext = (Context) context.get(Context.class);
+        servletContext.put(LifecycleProvider.class.getName(), new JasperLifecycleProvider(holder, classLoader, jndiContext));
+    }
+
+
+    public static class JasperLifecycleProvider implements LifecycleProvider {
+        private final Holder holder;
+        private final ClassLoader classLoader;
+        private final Context context;
+
+
+        public JasperLifecycleProvider(Holder holder, ClassLoader classLoader, Context context) {
+            this.holder = holder;
+            this.classLoader = classLoader;
+            this.context = context;
+        }
+
+        public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
+            return holder.newInstance(className, classLoader, context);
+        }
+
+        public Object newInstance(String fqcn, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
+            return holder.newInstance(fqcn, classLoader, context);
+        }
+
+        public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException {
+            try {
+                holder.destroyInstance(o);
+            } catch (Exception e) {
+                throw new InvocationTargetException(e, "Attempted to destroy instance");
+            }
+        }
+
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(JasperServletContextCustomizer.class, NameFactory.GERONIMO_SERVICE);
+        infoBuilder.addAttribute("holder", Holder.class, true, true);
+        infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
+        infoBuilder.setConstructor(new String[] {"holder", "classLoader"});
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/JasperServletContextCustomizer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/JasperServletContextCustomizer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-jasper/src/main/java/org/apache/geronimo/jasper/JasperServletContextCustomizer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6-builder/src/main/java/org/apache/geronimo/jetty6/deployment/JettyModuleBuilder.java Sat Mar 24 07:38:03 2007
@@ -172,9 +172,9 @@
         this.pojoWebServiceTemplate = getGBeanData(kernel, pojoWebServiceTemplate);
         this.clusteringBuilders = new NamespaceDrivenBuilderCollection(clusteringBuilders, GerClusteringDocument.type.getDocumentElementName());
 
-        this.defaultWelcomeFiles = defaultWelcomeFiles == null? new ArrayList<String>(): defaultWelcomeFiles;
-        this.defaultLocaleEncodingMappings = defaultLocaleEncodingMappings == null? new HashMap<String, String>(): defaultLocaleEncodingMappings;
-        this.defaultMimeTypeMappings = defaultMimeTypeMappings == null? new HashMap<String, String>(): defaultMimeTypeMappings;
+        this.defaultWelcomeFiles = defaultWelcomeFiles == null ? new ArrayList<String>() : defaultWelcomeFiles;
+        this.defaultLocaleEncodingMappings = defaultLocaleEncodingMappings == null ? new HashMap<String, String>() : defaultLocaleEncodingMappings;
+        this.defaultMimeTypeMappings = defaultMimeTypeMappings == null ? new HashMap<String, String>() : defaultMimeTypeMappings;
     }
 
     private static GBeanData getGBeanData(Kernel kernel, Object template) throws GBeanNotFoundException {
@@ -335,17 +335,17 @@
         WebModule webModule = (WebModule) module;
 
         WebAppType webApp = (WebAppType) webModule.getSpecDD();
-        JettyWebAppType jettyWebApp = (JettyWebAppType)webModule.getVendorDD();
+        JettyWebAppType jettyWebApp = (JettyWebAppType) webModule.getVendorDD();
         GBeanData webModuleData = new GBeanData(moduleName, JettyWebAppContext.GBEAN_INFO);
 
         configureBasicWebModuleAttributes(webApp, jettyWebApp, moduleContext, earContext, webModule, webModuleData);
 
         // unsharableResources, applicationManagedSecurityResources
-         GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
-         //N.B. use earContext not moduleContext
-         //TODO fix this for javaee 5 !!!
-         resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
-         try {
+        GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
+        //N.B. use earContext not moduleContext
+        //TODO fix this for javaee 5 !!!
+        resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRefArray(), jettyWebApp.getResourceRefArray());
+        try {
             moduleContext.addGBean(webModuleData);
             Set<String> securityRoles = collectRoleNames(webApp);
             Map<String, PermissionCollection> rolePermissions = new HashMap<String, PermissionCollection>();
@@ -475,6 +475,18 @@
             if (jettyWebApp.isSetSecurityRealmName()) {
                 configureSecurityRealm(earContext, webApp, jettyWebApp, webModuleData, securityRoles, rolePermissions);
             }
+
+            //TODO this may definitely not be the best place for this!
+            for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
+                mbe.addGBeans(earContext, module, cl, repository);
+            }
+            //not truly metadata complete until MBEs have run
+            if (!webApp.getMetadataComplete()) {
+                webApp.setMetadataComplete(true);
+                module.setOriginalSpecDD(module.getSpecDD().toString());
+                webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
+            }
+
             if (!module.isStandAlone()) {
                 ConfigurationData moduleConfigurationData = moduleContext.getConfigurationData();
                 earContext.addChildConfiguration(module.getTargetPath(), moduleConfigurationData);
@@ -483,17 +495,6 @@
             throw de;
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize webapp GBean for " + module.getName(), e);
-        }
-
-        //TODO this may definitely not be the best place for this!
-        for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
-            mbe.addGBeans(earContext, module, cl, repository);
-        }
-        //not truly metadata complete until MBEs have run
-        if (!webApp.getMetadataComplete()) {
-            webApp.setMetadataComplete(true);
-            module.setOriginalSpecDD(module.getSpecDD().toString());
-            webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
         }
 
     }

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/InternalJettyServletHolder.java Sat Mar 24 07:38:03 2007
@@ -19,27 +19,18 @@
 package org.apache.geronimo.jetty6;
 
 import java.io.IOException;
-import java.util.List;
-import java.util.Map;
 
+import javax.security.auth.Subject;
+import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
-import javax.servlet.ServletException;
 import javax.servlet.UnavailableException;
-import javax.security.auth.Subject;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
 
-import org.mortbay.jetty.servlet.ServletHolder;
 import org.apache.geronimo.jetty6.handler.AbstractImmutableHandler;
 import org.apache.geronimo.jetty6.handler.LifecycleCommand;
 import org.apache.geronimo.security.Callers;
 import org.apache.geronimo.security.ContextManager;
-import org.apache.geronimo.j2ee.annotation.Injection;
-import org.apache.xbean.recipe.ObjectRecipe;
-import org.apache.xbean.recipe.Option;
-import org.apache.xbean.recipe.StaticRecipe;
+import org.mortbay.jetty.servlet.ServletHolder;
 
 /**
  * @version $Rev$ $Date$
@@ -51,6 +42,7 @@
     private final AbstractImmutableHandler lifecycleChain;
     private final Subject runAsSubject;
     private final JettyServletRegistration servletRegistration;
+    private boolean stopped;
 
     public InternalJettyServletHolder(AbstractImmutableHandler lifecycleChain, Subject runAsSubject, JettyServletRegistration servletRegistration) {
         this.lifecycleChain = lifecycleChain;
@@ -90,7 +82,9 @@
     }
 
     public void destroyInstance(Object o) throws Exception {
-        servletRegistration.destroyInstance(o);
+        if (!stopped) {
+            servletRegistration.destroyInstance(o);
+        }
     }
 
     /**
@@ -127,6 +121,7 @@
 
     private void internalDoStop() {
         super.doStop();
+        stopped = true;
     }
 
     public class StartCommand implements LifecycleCommand {

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyFilterHolder.java Sat Mar 24 07:38:03 2007
@@ -51,11 +51,11 @@
     }
 
     public void doStart() throws Exception {
-            filterHolder.start();
+        filterHolder.start();
     }
 
     public void doStop() throws Exception {
-                filterHolder.stop();
+        filterHolder.stop();
     }
 
     public void doFail() {
@@ -68,6 +68,7 @@
 
     private static class InternalFilterHolder extends FilterHolder {
         private final JettyServletRegistration servletRegistration;
+        private boolean destroyed;
 
         public InternalFilterHolder(JettyServletRegistration servletRegistration) {
             this.servletRegistration = servletRegistration;
@@ -79,12 +80,15 @@
         }
 
         public void destroyInstance(Object o) throws Exception {
-            super.destroyInstance(o);
-            servletRegistration.destroyInstance(o);
+            if (!destroyed) {
+                super.destroyInstance(o);
+                servletRegistration.destroyInstance(o);
+                destroyed = true;
+            }
         }
 
     }
-    
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {
@@ -95,7 +99,7 @@
 
         infoBuilder.addReference("JettyServletRegistration", JettyServletRegistration.class, NameFactory.WEB_MODULE);
 
-        infoBuilder.setConstructor(new String[] {"filterName", "filterClass", "initParams", "JettyServletRegistration"});
+        infoBuilder.setConstructor(new String[]{"filterName", "filterClass", "initParams", "JettyServletRegistration"});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
 

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyServletHolder.java Sat Mar 24 07:38:03 2007
@@ -116,6 +116,7 @@
     }
 
     public void doStop() throws Exception {
+        servletHolder.stop();
         if (servletRegistration != null) {
             servletRegistration.unregisterServletHolder(servletHolder, servletHolder.getName(), null, objectName);
         }
@@ -123,7 +124,7 @@
 
     public void doFail() {
         try {
-            servletHolder.stop();
+            doStop();
         } catch (Exception e) {
             //?? ignore
         }

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/java/org/apache/geronimo/jetty6/JettyWebAppContext.java Sat Mar 24 07:38:03 2007
@@ -34,6 +34,7 @@
 import javax.management.ObjectName;
 import javax.naming.Context;
 import javax.transaction.TransactionManager;
+import javax.servlet.ServletContext;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -45,6 +46,7 @@
 import org.apache.geronimo.j2ee.annotation.LifecycleMethod;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
+import org.apache.geronimo.j2ee.RuntimeCustomizer;
 import org.apache.geronimo.jetty6.handler.AbstractImmutableHandler;
 import org.apache.geronimo.jetty6.handler.ComponentContextHandler;
 import org.apache.geronimo.jetty6.handler.InstanceContextHandler;
@@ -134,6 +136,8 @@
             TransactionManager transactionManager,
             TrackedConnectionAssociator trackedConnectionAssociator,
             JettyContainer jettyContainer,
+            RuntimeCustomizer contextCustomizer,
+
             J2EEServer server,
             J2EEApplication application,
             Kernel kernel) throws Exception {
@@ -177,6 +181,18 @@
         this.componentContext = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, userTransaction, kernel, classLoader);
         contextHandler = new ComponentContextHandler(webAppContext, this.componentContext);
 
+        //install jasper injection support if required
+        if (contextCustomizer != null) {
+            Map<String, Object> servletContext = new HashMap<String, Object>();
+            Map<Class, Object> customizerContext = new HashMap<Class, Object>();
+            customizerContext.put(Map.class, servletContext);
+            customizerContext.put(Context.class, JettyWebAppContext.this.componentContext);
+            contextCustomizer.customize(customizerContext);
+            for (Map.Entry<String, Object> entry: servletContext.entrySet()) {
+                webAppContext.setAttribute(entry.getKey(), entry.getValue());
+            }
+        }
+
         // localize access to next
         {
             //install the other handlers inside the web app context
@@ -205,7 +221,8 @@
         this.jettyContainer = jettyContainer;
         this.originalSpecDD = originalSpecDD;
 
-        webAppContext.setConfigurationClasses(new String[]{"org.mortbay.jetty.webapp.TagLibConfiguration"});
+        //DONT install the jetty TLD configuration as we find and create all the listeners ourselves
+        webAppContext.setConfigurationClasses(new String[]{});
 
         webAppRoot = configurationBaseUrl.toString();
         webClassLoader = classLoader;
@@ -572,6 +589,7 @@
         infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.TRANSACTION_MANAGER);
         infoBuilder.addReference("TrackedConnectionAssociator", TrackedConnectionAssociator.class, NameFactory.JCA_CONNECTION_TRACKER);
         infoBuilder.addReference("JettyContainer", JettyContainer.class, NameFactory.GERONIMO_SERVICE);
+        infoBuilder.addReference("ContextCustomizer", RuntimeCustomizer.class, NameFactory.GERONIMO_SERVICE);
 
         infoBuilder.addInterface(JettyServletRegistration.class);
 
@@ -632,6 +650,7 @@
                 "TransactionManager",
                 "TrackedConnectionAssociator",
                 "JettyContainer",
+                "ContextCustomizer",
 
                 "J2EEServer",
                 "J2EEApplication",

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/main/resources/META-INF/geronimo-dependency.xml Sat Mar 24 07:38:03 2007
@@ -28,24 +28,24 @@
         <dep:groupId>org.apache.xbean</dep:groupId>
         <dep:artifactId>xbean-reflect</dep:artifactId>
     </dep:dependency>
-    <dep:dependency>
-        <dep:groupId>org.apache.tomcat</dep:groupId>
-        <dep:artifactId>jasper</dep:artifactId>
-    </dep:dependency>
-    <dep:dependency>
-        <dep:groupId>org.apache.tomcat</dep:groupId>
-        <dep:artifactId>jasper-jdt</dep:artifactId>
-    </dep:dependency>
-    <dep:dependency>
-        <dep:groupId>org.apache.tomcat</dep:groupId>
-        <dep:artifactId>jasper-el</dep:artifactId>
-    </dep:dependency>
-    <dep:dependency>
-        <dep:groupId>org.apache.tomcat.extras</dep:groupId>
-        <dep:artifactId>juli</dep:artifactId>
-    </dep:dependency>
-    <dep:dependency>
-        <dep:groupId>org.apache.tomcat.extras</dep:groupId>
-        <dep:artifactId>juli-adapters</dep:artifactId>
-    </dep:dependency>
+    <!--<dep:dependency>-->
+        <!--<dep:groupId>org.apache.tomcat</dep:groupId>-->
+        <!--<dep:artifactId>jasper</dep:artifactId>-->
+    <!--</dep:dependency>-->
+    <!--<dep:dependency>-->
+        <!--<dep:groupId>org.apache.tomcat</dep:groupId>-->
+        <!--<dep:artifactId>jasper-jdt</dep:artifactId>-->
+    <!--</dep:dependency>-->
+    <!--<dep:dependency>-->
+        <!--<dep:groupId>org.apache.tomcat</dep:groupId>-->
+        <!--<dep:artifactId>jasper-el</dep:artifactId>-->
+    <!--</dep:dependency>-->
+    <!--<dep:dependency>-->
+        <!--<dep:groupId>org.apache.tomcat.extras</dep:groupId>-->
+        <!--<dep:artifactId>juli</dep:artifactId>-->
+    <!--</dep:dependency>-->
+    <!--<dep:dependency>-->
+        <!--<dep:groupId>org.apache.tomcat.extras</dep:groupId>-->
+        <!--<dep:artifactId>juli-adapters</dep:artifactId>-->
+    <!--</dep:dependency>-->
 </dep:service>

Modified: geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-jetty6/src/test/java/org/apache/geronimo/jetty6/AbstractWebModuleTest.java Sat Mar 24 07:38:03 2007
@@ -24,12 +24,9 @@
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.List;
 
 import javax.transaction.TransactionManager;
 
-import org.apache.geronimo.testsupport.TestSupport;
-
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
 import org.apache.geronimo.connector.outbound.connectiontracking.GeronimoTransactionListener;
 import org.apache.geronimo.jetty6.connector.HTTPConnector;
@@ -47,9 +44,8 @@
 import org.apache.geronimo.security.realm.GenericSecurityRealm;
 import org.apache.geronimo.system.serverinfo.BasicServerInfo;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.testsupport.TestSupport;
 import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
-import org.apache.geronimo.j2ee.annotation.Injection;
-import org.apache.geronimo.j2ee.annotation.Holder;
 import org.mortbay.jetty.security.Authenticator;
 import org.mortbay.jetty.security.FormAuthenticator;
 
@@ -122,6 +118,7 @@
                 transactionManager,
                 connectionTrackingCoordinator,
                 container,
+                null,
                 null,
                 null,
                 null);

Modified: geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/modules/geronimo-myfaces-builder/src/main/java/org/apache/geronimo/myfaces/deployment/MyFacesModuleBuilderExtension.java Sat Mar 24 07:38:03 2007
@@ -141,6 +141,10 @@
         Map<NamingBuilder.Key, Object> buildingContext = new HashMap<NamingBuilder.Key, Object>();
         buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);
 
+        //use the same jndi context as the web app
+        Map compContext = NamingBuilder.JNDI_KEY.get(module.getSharedContext());
+        buildingContext.put(NamingBuilder.JNDI_KEY, compContext);
+
         //use the same holder object as the web app.
         Holder holder = NamingBuilder.INJECTION_KEY.get(sharedContext);
         buildingContext.put(NamingBuilder.INJECTION_KEY, holder);
@@ -153,8 +157,6 @@
         webModule.setClassFinder(classFinder);
 
         namingBuilders.buildNaming(webApp, jettyWebApp, earConfiguration, earConfiguration, webModule, buildingContext);
-
-        Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);
 
         AbstractName providerName = moduleContext.getNaming().createChildName(moduleName, "jsf-lifecycle", "jsf");
         GBeanData providerData = new GBeanData(providerName, LifecycleProviderGBean.GBEAN_INFO);

Modified: geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Sat Mar 24 07:38:03 2007
@@ -19,8 +19,8 @@
 
 import java.io.File;
 import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.FileWriter;
+import java.io.IOException;
 import java.net.URL;
 import java.security.Permission;
 import java.security.PermissionCollection;
@@ -51,18 +51,17 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.ReferencePatterns;
-import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
 import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
+import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
 import org.apache.geronimo.j2ee.deployment.NamingBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
 import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
-import org.apache.geronimo.j2ee.deployment.ModuleBuilderExtension;
+import org.apache.geronimo.j2ee.deployment.annotation.AnnotatedWebApp;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.Naming;
-import org.apache.geronimo.kernel.config.Configuration;
 import org.apache.geronimo.kernel.config.ConfigurationData;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
@@ -84,6 +83,7 @@
 import org.apache.geronimo.xbeans.javaee.ServletType;
 import org.apache.geronimo.xbeans.javaee.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.XmlOptions;
@@ -99,6 +99,7 @@
     private final AbstractNameQuery tomcatContainerName;
 
     private static final String TOMCAT_NAMESPACE = TomcatWebAppDocument.type.getDocumentElementName().getNamespaceURI();
+    private static final String IS_JAVAEE = "IS_JAVAEE";
 
     public TomcatModuleBuilder(Environment defaultEnvironment,
             AbstractNameQuery tomcatContainerName,
@@ -123,6 +124,7 @@
         // parse the spec dd
         String specDD = null;
         WebAppType webApp = null;
+        Boolean isJavaee;
         try {
             if (specDDUrl == null) {
                 specDDUrl = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/web.xml");
@@ -134,6 +136,15 @@
 
             // we found web.xml, if it won't parse that's an error.
             XmlObject parsed = XmlBeansUtil.parse(specDD);
+            //Dont save updated xml if it isn't javaee
+            XmlCursor cursor = parsed.newCursor();
+            try {
+                cursor.toStartDoc();
+                cursor.toFirstChild();
+                isJavaee = "http://java.sun.com/xml/ns/javaee".equals(cursor.getName().getNamespaceURI());
+            } finally {
+                cursor.dispose();
+            }
             WebAppDocument webAppDoc = convertToServletSchema(parsed);
             webApp = webAppDoc.getWebApp();
             check(webApp);
@@ -147,6 +158,7 @@
                 //not for us
                 return null;
             }
+            isJavaee = true;
             //else ignore as jee5 allows optional spec dd for .war's
         }
 
@@ -204,9 +216,10 @@
         AnnotatedWebApp annotatedWebApp = new AnnotatedWebApp(webApp);
 
         WebModule module = new WebModule(standAlone, moduleName, environment, moduleFile, targetPath, webApp, tomcatWebApp, specDD, contextRoot, TOMCAT_NAMESPACE, annotatedWebApp);
-        for (ModuleBuilderExtension mbe: moduleBuilderExtensions) {
+        for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.createModule(module, plan, moduleFile, targetPath, specDDUrl, environment, contextRoot, earName, naming, idBuilder);
         }
+        module.getSharedContext().put(IS_JAVAEE, isJavaee);
         return module;
     }
 
@@ -271,7 +284,7 @@
         TomcatWebAppType gerWebApp = (TomcatWebAppType) module.getVendorDD();
         boolean hasSecurityRealmName = gerWebApp.isSetSecurityRealmName();
         buildSubstitutionGroups(gerWebApp, hasSecurityRealmName, module, earContext);
-        for (ModuleBuilderExtension mbe: moduleBuilderExtensions) {
+        for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
             mbe.initContext(earContext, module, cl);
         }
     }
@@ -284,90 +297,20 @@
 
         WebAppType webApp = (WebAppType) webModule.getSpecDD();
 
-        /**
-         * This next bit of code is kind of a kludge to get Tomcat to get a default
-         * web.xml if one does not exist.  This is primarily for jaxws.  This code is
-         * necessary because Tomcat either has a bug or there is a problem dynamically
-         * adding a wrapper to an already running context.  Although the wrapper
-         * can be added, the url mappings do not get picked up at the proper level
-         * and therefore Tomcat cannot dispatch the request.  Hence, creating and
-         * writing out a web.xml to the deployed location is the only way around this
-         * until Tomcat fixes that bug.
-         */
-        File webXml = new File(moduleContext.getBaseDir(), "/WEB-INF/web.xml");
-        File inPlaceDir = moduleContext.getInPlaceConfigurationDir();
-        boolean webXmlExists = (inPlaceDir != null && new File(inPlaceDir,"/WEB-INF/web.xml").exists()) || webXml.exists();
-        if (!webXmlExists) {
-        	webXml.getParentFile().mkdirs();
-            try {
-                FileWriter outFile = new FileWriter(webXml);
-
-                XmlOptions opts = new XmlOptions();
-                opts.setUseDefaultNamespace();
-                opts.setSavePrettyPrint();
-
-                WebAppDocument doc = WebAppDocument.Factory.newInstance();
-                doc.setWebApp(webApp);
-
-                outFile.write(doc.xmlText(opts));
-                outFile.flush();
-                outFile.close();
-            } catch (Exception e) {
-                throw new DeploymentException(e);
-            }
-        }
-
         TomcatWebAppType tomcatWebApp = (TomcatWebAppType) webModule.getVendorDD();
 
         GBeanData webModuleData = new GBeanData(moduleName, TomcatWebAppContext.GBEAN_INFO);
+        configureBasicWebModuleAttributes(webApp, tomcatWebApp, moduleContext, earContext, webModule, webModuleData);
         try {
             moduleContext.addGBean(webModuleData);
-            webModuleData.setReferencePattern("J2EEServer", moduleContext.getServerName());
-            if (!module.isStandAlone()) {
-                webModuleData.setReferencePattern("J2EEApplication", earContext.getModuleName());
-            }
-
             Set securityRoles = collectRoleNames(webApp);
             Map rolePermissions = new HashMap();
-
             webModuleData.setAttribute("contextPath", webModule.getContextRoot());
-
-            //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)
-            //and sidesteps the problem of circular references between ejbs.
-            Set dependencies = findGBeanDependencies(earContext);
-            webModuleData.addDependencies(dependencies);
-
-            //N.B. we use the ear context which has all the gbeans we could possibly be looking up from this ear.
-            Map buildingContext = new HashMap();
-            buildingContext.put(NamingBuilder.GBEAN_NAME_KEY, moduleName);
-            Configuration earConfiguration = earContext.getConfiguration();
-
-            if (!webApp.getMetadataComplete()) {
-                // Create a classfinder and populate it for the naming builder(s). The absence of a
-                // classFinder in the module will convey whether metadata-complete is set (or not)
-                webModule.setClassFinder(createWebAppClassFinder(webApp, webModule));
-            }
-
-            getNamingBuilders().buildNaming(webApp, tomcatWebApp, earConfiguration, earConfiguration, webModule, buildingContext);
-
-            if (!webApp.getMetadataComplete()) {
-                webApp.setMetadataComplete(true);
-                module.setOriginalSpecDD(module.getSpecDD().toString());
-            }
-            webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
-
-            Map compContext = NamingBuilder.JNDI_KEY.get(buildingContext);
-
-            webModuleData.setAttribute("componentContext", compContext);
             // unsharableResources, applicationManagedSecurityResources
             GBeanResourceEnvironmentBuilder rebuilder = new GBeanResourceEnvironmentBuilder(webModuleData);
             //N.B. use earContext not moduleContext
             resourceEnvironmentSetter.setResourceEnvironment(rebuilder, webApp.getResourceRefArray(), tomcatWebApp.getResourceRefArray());
 
-            webModuleData.setReferencePattern("TransactionManager", earContext.getTransactionManagerName());
-            webModuleData.setReferencePattern("TrackedConnectionAssociator", earContext.getConnectionTrackerName());
-
             if (tomcatWebApp.isSetWebContainer()) {
                 AbstractNameQuery webContainerName = ENCConfigBuilder.getGBeanQuery(NameFactory.GERONIMO_SERVICE, tomcatWebApp.getWebContainer());
                 webModuleData.setReferencePattern("Container", webContainerName);
@@ -501,6 +444,61 @@
                 webModuleData.setAttribute("securityHolder", securityHolder);
             }
 
+            //listeners added directly to the StandardContext will get loaded by the tomcat classloader, not the app classloader!
+            //TODO this may definitely not be the best place for this!
+            for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
+                mbe.addGBeans(earContext, module, cl, repository);
+            }
+            //not truly metadata complete until MBEs have run
+            if (!webApp.getMetadataComplete()) {
+                webApp.setMetadataComplete(true);
+                module.setOriginalSpecDD(module.getSpecDD().toString());
+                webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
+            }
+            /**
+             * This next bit of code is kind of a kludge to get Tomcat to get a default
+             * web.xml if one does not exist.  This is primarily for jaxws.  This code is
+             * necessary because Tomcat either has a bug or there is a problem dynamically
+             * adding a wrapper to an already running context.  Although the wrapper
+             * can be added, the url mappings do not get picked up at the proper level
+             * and therefore Tomcat cannot dispatch the request.  Hence, creating and
+             * writing out a web.xml to the deployed location is the only way around this
+             * until Tomcat fixes that bug.
+             *
+             * For myfaces/jsf, the sped dd may have been updated with a listener.  So, we need to write it out again whether or not
+             * there originally was one. This might not work on windows due to file locking problems.
+             */
+
+            if ((Boolean)module.getSharedContext().get(IS_JAVAEE)) {
+                File webXml = new File(moduleContext.getBaseDir(), "/WEB-INF/web.xml");
+                File inPlaceDir = moduleContext.getInPlaceConfigurationDir();
+                if (inPlaceDir != null) {
+                    webXml = new File(inPlaceDir, "/WEB-INF/web.xml");
+                }
+//        boolean webXmlExists = (inPlaceDir != null && new File(inPlaceDir,"/WEB-INF/web.xml").exists()) || webXml.exists();
+//        if (!webXmlExists) {
+                webXml.getParentFile().mkdirs();
+                try {
+                    FileWriter outFile = new FileWriter(webXml);
+
+                    XmlOptions opts = new XmlOptions();
+                    opts.setSaveAggressiveNamespaces();
+                    opts.setSaveSyntheticDocumentElement(WebAppDocument.type.getDocumentElementName());
+                    opts.setUseDefaultNamespace();
+                    opts.setSavePrettyPrint();
+
+    //                WebAppDocument doc = WebAppDocument.Factory.newInstance();
+    //                doc.setWebApp(webApp);
+
+                    outFile.write(webApp.xmlText(opts));
+                    outFile.flush();
+                    outFile.close();
+                } catch (Exception e) {
+                    throw new DeploymentException(e);
+                }
+//        }
+            }
+
             if (!module.isStandAlone()) {
                 ConfigurationData moduleConfigurationData = moduleContext.getConfigurationData();
                 earContext.addChildConfiguration(module.getTargetPath(), moduleConfigurationData);
@@ -509,10 +507,6 @@
             throw de;
         } catch (Exception e) {
             throw new DeploymentException("Unable to initialize GBean for web app " + module.getName(), e);
-        }
-        //TODO this may definitely not be the best place for this!
-        for (ModuleBuilderExtension mbe: moduleBuilderExtensions) {
-            mbe.addGBeans(earContext, module, cl, repository);
         }
     }
 

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java Sat Mar 24 07:38:03 2007
@@ -22,8 +22,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.naming.NamingException;
-import javax.naming.Context;
 import javax.security.auth.Subject;
 import javax.security.jacc.PolicyContext;
 import javax.servlet.Servlet;
@@ -35,7 +33,6 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
 import org.apache.catalina.Wrapper;
-import org.apache.catalina.util.DefaultAnnotationProcessor;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.core.StandardContext;
@@ -45,7 +42,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.common.GeronimoSecurityException;
-import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.SubjectId;
@@ -88,22 +84,8 @@
             setJ2EEServer(tctx.getJ2EEServer());
         }
         // Create ReadOnlyContext
-        javax.naming.Context enc = null;
-        Map componentContext = ctx.getComponentContext();
-        try {
-            if (componentContext != null) {
-                enc = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, ctx.getUserTransaction(), ctx.getKernel(), ctx.getClassLoader());
-            }
-        } catch (NamingException ne) {
-            log.error(ne);
-        }
-        try {
-            Context env = (Context) enc.lookup("env");
-            setAnnotationProcessor(new DefaultAnnotationProcessor(env));
-        } catch (NamingException e) {
-            // ignored
-            log.warn("Could not find env in enterprise naming context", e);
-        }
+        javax.naming.Context enc = ctx.getJndiContext();
+        setLifecycleProvider(ctx.getLifecycleProvider());
 
         int index = 0;
         BeforeAfter interceptor = new InstanceContextBeforeAfter(null,
@@ -334,6 +316,9 @@
                     GeronimoStandardContext.super.start();
                 } catch (LifecycleException e) {
                     throw (IOException) new IOException("wrapping lifecycle exception").initCause(e);
+                }
+                if (GeronimoStandardContext.this.getState() != 1 || !GeronimoStandardContext.this.getAvailable()){
+                    throw new IOException("Context did not start for an unknown reason");
                 }
             } else {
                 getNext().invoke(request, response);

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java Sat Mar 24 07:38:03 2007
@@ -26,9 +26,10 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
 import org.apache.catalina.ha.CatalinaCluster;
+import org.apache.catalina.lifecycle.LifecycleProvider;
+import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
-import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 
 /**
  * @version $Rev$ $Date$
@@ -51,7 +52,7 @@
 
     public UserTransaction getUserTransaction();
 
-    public Map getComponentContext();
+    public javax.naming.Context getJndiContext();
 
     public Kernel getKernel();
 
@@ -74,4 +75,7 @@
     public boolean isDisableCookies();
 
     public Map getWebServices();
+
+    public LifecycleProvider getLifecycleProvider();
+
 }

Added: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLifecycleProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLifecycleProvider.java?view=auto&rev=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLifecycleProvider.java (added)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLifecycleProvider.java Sat Mar 24 07:38:03 2007
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tomcat;
+
+
+import java.lang.reflect.InvocationTargetException;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.catalina.lifecycle.LifecycleProvider;
+import org.apache.geronimo.j2ee.annotation.Holder;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class TomcatLifecycleProvider implements LifecycleProvider {
+
+    private final Holder holder;
+    private final ClassLoader classLoader;
+    private final Context context;
+
+
+    public TomcatLifecycleProvider(Holder holder, ClassLoader classLoader, Context context) {
+        this.holder = holder;
+        this.classLoader = classLoader;
+        this.context = context;
+    }
+
+    public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
+        return holder.newInstance(className, classLoader, context);
+    }
+
+    public Object newInstance(String fqcn, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
+        return holder.newInstance(fqcn, classLoader, context);
+    }
+
+    public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException {
+        try {
+            holder.destroyInstance(o);
+        } catch (Exception e) {
+            throw new InvocationTargetException(e, "Attempted to destroy instance");
+        }
+    }
+
+
+}

Propchange: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLifecycleProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLifecycleProvider.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatLifecycleProvider.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java Sat Mar 24 07:38:03 2007
@@ -28,7 +28,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.faces.FactoryFinder;
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 import javax.management.j2ee.statistics.Stats;
@@ -42,6 +41,7 @@
 import org.apache.catalina.Valve;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.ha.CatalinaCluster;
+import org.apache.catalina.lifecycle.LifecycleProvider;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
@@ -49,6 +49,7 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.annotation.Holder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.j2ee.management.impl.InvalidObjectNameException;
 import org.apache.geronimo.kernel.Kernel;
@@ -59,9 +60,10 @@
 import org.apache.geronimo.management.geronimo.WebConnector;
 import org.apache.geronimo.management.geronimo.WebContainer;
 import org.apache.geronimo.management.geronimo.WebModule;
-import org.apache.geronimo.tomcat.util.SecurityHolder;
+import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
 import org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean;
 import org.apache.geronimo.tomcat.stats.ModuleStats;
+import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.transaction.GeronimoUserTransaction;
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.WebServiceContainerFactory;
@@ -102,7 +104,7 @@
 
     private final UserTransaction userTransaction;
 
-    private final Map componentContext;
+    private final javax.naming.Context componentContext;
 
     private final Kernel kernel;
 
@@ -123,8 +125,10 @@
     private final String originalSpecDD;
 
     private final URL configurationBaseURL;
-    
-    // JSR 77 
+
+    private final Holder holder;
+
+    // JSR 77
     
     private final String j2EEServer;
     
@@ -154,6 +158,7 @@
             boolean crossContext,
             boolean disableCookies,
             Map webServices,
+            Holder holder,
             J2EEServer server,
             J2EEApplication application,
             Kernel kernel)
@@ -182,8 +187,9 @@
         this.virtualServer = virtualServer;
         this.securityHolder = securityHolder;
 
-        this.userTransaction = new GeronimoUserTransaction(transactionManager);
-        this.componentContext = componentContext;
+        userTransaction = new GeronimoUserTransaction(transactionManager);
+        this.componentContext = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext, userTransaction, kernel, classLoader);
+;
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
         this.trackedConnectionAssociator = trackedConnectionAssociator;
@@ -192,6 +198,8 @@
 
         this.configurationBaseURL = configurationBaseUrl;
 
+        this.holder = holder == null? new Holder(): holder;
+
         if (tomcatRealm != null){
             realm = (Realm)tomcatRealm.getInternalObject();
             if (realm == null){
@@ -322,7 +330,7 @@
         return userTransaction;
     }
 
-    public Map getComponentContext() {
+    public javax.naming.Context getJndiContext() {
         return componentContext;
     }
 
@@ -423,6 +431,10 @@
         return webServices;
     }
 
+    public LifecycleProvider getLifecycleProvider() {
+        return new TomcatLifecycleProvider(holder, classLoader, componentContext);
+    }
+
     public String[] getServlets(){
         String[] result = null;
         if ((context != null) && (context instanceof StandardContext)) {
@@ -498,6 +510,9 @@
         // super.start();
         //register the classloader <> dir context association so that tomcat's jndi based getResources works.
         DirContext resources = context.getResources();
+        if (resources == null) {
+            throw new IllegalStateException("JNDI environment was not set up correctly due to previous error");
+        }
         DirContextURLStreamHandler.bind(classLoader, resources);
         if (context instanceof StandardContext)
             statsProvider =  new ModuleStats((StandardContext)context);
@@ -513,9 +528,6 @@
         // No more logging will occur for this ClassLoader. Inform the LogFactory to avoid a memory leak.
 //        LogFactory.release(classLoader);
 
-        // need to release the JSF factories. Otherwise, we'll leak ClassLoaders.
-        FactoryFinder.releaseFactories();
-        
         log.debug("TomcatWebAppContext stopped");
     }
 
@@ -526,9 +538,6 @@
         // No more logging will occur for this ClassLoader. Inform the LogFactory to avoid a memory leak.
 //        LogFactory.release(classLoader);
 
-        // need to release the JSF factories. Otherwise, we'll leak ClassLoaders.
-        FactoryFinder.releaseFactories();
-
         log.warn("TomcatWebAppContext failed");
     }
 
@@ -560,6 +569,7 @@
         infoBuilder.addAttribute("crossContext", boolean.class, true);
         infoBuilder.addAttribute("disableCookies", boolean.class, true);
         infoBuilder.addAttribute("webServices", Map.class, true);
+        infoBuilder.addAttribute("holder", Holder.class, true);
         infoBuilder.addReference("J2EEServer", J2EEServer.class);
         infoBuilder.addReference("J2EEApplication", J2EEApplication.class);
         infoBuilder.addAttribute("kernel", Kernel.class, false);
@@ -586,6 +596,7 @@
                 "crossContext",
                 "disableCookies",
                 "webServices",
+                "holder",
                 "J2EEServer",
                 "J2EEApplication",
                 "kernel"

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/main/resources/META-INF/geronimo-dependency.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/main/resources/META-INF/geronimo-dependency.xml?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/main/resources/META-INF/geronimo-dependency.xml (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/main/resources/META-INF/geronimo-dependency.xml Sat Mar 24 07:38:03 2007
@@ -23,25 +23,25 @@
             <dep:artifactId>catalina</dep:artifactId>
         </dep:dependency>
 
-        <dep:dependency>
-            <dep:groupId>org.apache.tomcat</dep:groupId>
-            <dep:artifactId>annotations-api</dep:artifactId>
-        </dep:dependency>
+        <!--<dep:dependency>-->
+            <!--<dep:groupId>org.apache.tomcat</dep:groupId>-->
+            <!--<dep:artifactId>annotations-api</dep:artifactId>-->
+        <!--</dep:dependency>-->
 
-        <dep:dependency>
-            <dep:groupId>org.apache.tomcat</dep:groupId>
-            <dep:artifactId>jasper</dep:artifactId>
-        </dep:dependency>
+        <!--<dep:dependency>-->
+            <!--<dep:groupId>org.apache.tomcat</dep:groupId>-->
+            <!--<dep:artifactId>jasper</dep:artifactId>-->
+        <!--</dep:dependency>-->
         
-        <dep:dependency>
-            <dep:groupId>org.apache.tomcat</dep:groupId>
-            <dep:artifactId>jasper-el</dep:artifactId>
-        </dep:dependency>
+        <!--<dep:dependency>-->
+            <!--<dep:groupId>org.apache.tomcat</dep:groupId>-->
+            <!--<dep:artifactId>jasper-el</dep:artifactId>-->
+        <!--</dep:dependency>-->
 
-        <dep:dependency>
-            <dep:groupId>org.apache.tomcat</dep:groupId>
-            <dep:artifactId>jasper-jdt</dep:artifactId>
-        </dep:dependency>
+        <!--<dep:dependency>-->
+            <!--<dep:groupId>org.apache.tomcat</dep:groupId>-->
+            <!--<dep:artifactId>jasper-jdt</dep:artifactId>-->
+        <!--</dep:dependency>-->
 
         <dep:dependency>
             <dep:groupId>org.apache.tomcat</dep:groupId>

Modified: geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java Sat Mar 24 07:38:03 2007
@@ -85,6 +85,7 @@
                 null,
                 null,
                 null,
+                null,
                 null);
         app.setContextPath("/test");
         app.doStart();

Added: geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/BasicTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/BasicTest.java?view=auto&rev=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/BasicTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/BasicTest.java Sat Mar 24 07:38:03 2007
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.tomcat;
+
+import junit.framework.TestCase;
+import org.apache.geronimo.gbean.GBeanInfo;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class BasicTest extends TestCase {
+    
+    public void testTomcatWebAppContext() throws Exception {
+        GBeanInfo gBeanInfo = TomcatWebAppContext.getGBeanInfo();
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/BasicTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/BasicTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-tomcat6/src/test/java/org/apache/geronimo/tomcat/BasicTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Sat Mar 24 07:38:03 2007
@@ -334,8 +334,9 @@
             //otherwise assume DTD
             XmlDocumentProperties xmlDocumentProperties = cursor.documentProperties();
             String publicId = xmlDocumentProperties.getDoctypePublicId();
+            boolean is22 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId);
             if ("-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN".equals(publicId) ||
-                    "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN".equals(publicId)) {
+                    is22) {
                 XmlCursor moveable = xmlObject.newCursor();
                 try {
                     moveable.toStartDoc();
@@ -370,6 +371,18 @@
                                 cursor.pop();
                             }
                             cursor.pop();
+                            cursor.push();
+                            if (cursor.toChild(SchemaConversionUtils.JAVAEE_NAMESPACE, "jsp-file")) {
+                                String jspFile = cursor.getTextValue();
+                                if (!jspFile.startsWith("/")){
+                                    if (is22) {
+                                        cursor.setTextValue("/" + jspFile);
+                                    } else {
+                                        throw new XmlException("jsp-file does not start with / and this is not a 2.2 web app: " + jspFile);
+                                    }
+                                }
+                            }
+                            cursor.pop();
                         }
                     } while (cursor.toNextSibling());
                 } finally {
@@ -785,6 +798,8 @@
         Holder holder = NamingBuilder.INJECTION_KEY.get(buildingContext);
 
         webModule.getSharedContext().put(WebModule.WEB_APP_DATA, webModuleData);
+        webModule.getSharedContext().put(NamingBuilder.JNDI_KEY, compContext);
+        webModule.getSharedContext().put(NamingBuilder.INJECTION_KEY, holder);
         if (moduleContext.getServerName() != null) {
             webModuleData.setReferencePattern("J2EEServer", moduleContext.getServerName());
         }

Modified: geronimo/server/trunk/modules/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/pom.xml?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/modules/pom.xml (original)
+++ geronimo/server/trunk/modules/pom.xml Sat Mar 24 07:38:03 2007
@@ -70,6 +70,7 @@
         <module>geronimo-j2ee-builder</module>
         <module>geronimo-j2ee-schema</module>
         <module>geronimo-jasper</module>
+        <module>geronimo-jasper-builder</module>
         <module>geronimo-jmx-remoting</module>
         <module>geronimo-kernel</module>
         <module>geronimo-mail</module>

Modified: geronimo/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Sat Mar 24 07:38:03 2007
@@ -916,7 +916,7 @@
             <dependency>
                 <groupId>org.apache.tomcat</groupId>
                 <artifactId>jasper</artifactId>
-                <version>${tomcatVersion}</version>
+                <version>6.0-G521891</version>
             </dependency>
 
             <dependency>
@@ -946,7 +946,7 @@
             <dependency>
                 <groupId>org.apache.tomcat</groupId>
                 <artifactId>catalina</artifactId>
-                <version>${tomcatVersion}</version>
+                <version>6.0-G521891</version>
             </dependency>
 
             <dependency>
@@ -964,6 +964,12 @@
             <dependency>
                 <groupId>org.apache.tomcat</groupId>
                 <artifactId>coyote</artifactId>
+                <version>${tomcatVersion}</version>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.tomcat</groupId>
+                <artifactId>juli</artifactId>
                 <version>${tomcatVersion}</version>
             </dependency>
 

Added: geronimo/server/trunk/repository/org/apache/tomcat/catalina/6.0-G521891/catalina-6.0-G521891.jar
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/repository/org/apache/tomcat/catalina/6.0-G521891/catalina-6.0-G521891.jar?view=auto&rev=522036
==============================================================================
Binary file - no diff available.

Propchange: geronimo/server/trunk/repository/org/apache/tomcat/catalina/6.0-G521891/catalina-6.0-G521891.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/server/trunk/repository/org/apache/tomcat/catalina/6.0-G521891/catalina-6.0-G521891.jar.md5
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/repository/org/apache/tomcat/catalina/6.0-G521891/catalina-6.0-G521891.jar.md5?view=auto&rev=522036
==============================================================================
--- geronimo/server/trunk/repository/org/apache/tomcat/catalina/6.0-G521891/catalina-6.0-G521891.jar.md5 (added)
+++ geronimo/server/trunk/repository/org/apache/tomcat/catalina/6.0-G521891/catalina-6.0-G521891.jar.md5 Sat Mar 24 07:38:03 2007
@@ -0,0 +1 @@
+MD5 (catalina-6.0-G521891.jar) = 85034ea6f2ba9f00842d66d7826b0084

Added: geronimo/server/trunk/repository/org/apache/tomcat/jasper/6.0-G521891/jasper-6.0-G521891.jar
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/repository/org/apache/tomcat/jasper/6.0-G521891/jasper-6.0-G521891.jar?view=auto&rev=522036
==============================================================================
Binary file - no diff available.

Propchange: geronimo/server/trunk/repository/org/apache/tomcat/jasper/6.0-G521891/jasper-6.0-G521891.jar
------------------------------------------------------------------------------
    svn:mime-type = application/java-archive

Added: geronimo/server/trunk/repository/org/apache/tomcat/jasper/6.0-G521891/jasper-6.0-G521891.jar.md5
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/repository/org/apache/tomcat/jasper/6.0-G521891/jasper-6.0-G521891.jar.md5?view=auto&rev=522036
==============================================================================
--- geronimo/server/trunk/repository/org/apache/tomcat/jasper/6.0-G521891/jasper-6.0-G521891.jar.md5 (added)
+++ geronimo/server/trunk/repository/org/apache/tomcat/jasper/6.0-G521891/jasper-6.0-G521891.jar.md5 Sat Mar 24 07:38:03 2007
@@ -0,0 +1 @@
+MD5 (jasper-6.0-G521891.jar) = 0ce1be7b9c21e4a105d1990d7ef516fa

Modified: geronimo/server/trunk/repository/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/repository/pom.xml?view=diff&rev=522036&r1=522035&r2=522036
==============================================================================
--- geronimo/server/trunk/repository/pom.xml (original)
+++ geronimo/server/trunk/repository/pom.xml Sat Mar 24 07:38:03 2007
@@ -18,7 +18,8 @@
 
 <!-- $Rev$ $Date$ -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
     <modelVersion>4.0.0</modelVersion>
 
@@ -32,12 +33,12 @@
     <artifactId>repository</artifactId>
     <name>Geronimo Local Repository</name>
     <packaging>jar</packaging>
-    
+
     <description>
         Container for local artifacts, this is a temporary solution until a more
         permeant Geronimo specific repository solution can be implemented.
     </description>
-    
+
     <dependencies>
         <dependency>
             <groupId>dwr</groupId>
@@ -48,17 +49,32 @@
             <groupId>juddi</groupId>
             <artifactId>juddi</artifactId>
         </dependency>
-        
+
         <dependency>
             <groupId>jstl</groupId>
             <artifactId>jstl</artifactId>
         </dependency>
-        
+
         <dependency>
             <groupId>org.dojotoolkit</groupId>
             <artifactId>dojo</artifactId>
             <type>zip</type>
         </dependency>
+
+        <!-- See GERONIMO-3010  These artifacts are here temporarily while we discuss the proposed change in
+        managed object lifecycle handling with the tomcat team.  One way or another it should be gone in a couple
+        of weeks -->
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>catalina</artifactId>
+            <version>6.0-G521891</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>jasper</artifactId>
+        </dependency>
+
+
     </dependencies>
 
     <repositories>
@@ -75,7 +91,7 @@
             </releases>
         </repository>
     </repositories>
-    
+
     <build>
         <plugins>
             <!--
@@ -96,7 +112,7 @@
                             <strict>false</strict>
                         </configuration>
                     </execution>
-                    
+
                     <execution>
                         <id>verify-legal-files</id>
                         <phase>verify</phase>



Mime
View raw message