geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r892401 - in /geronimo/server/trunk/plugins/tomcat: geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/ geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/ geronimo-tomcat7/src/test/java/org/apache/geronimo/...
Date Fri, 18 Dec 2009 23:29:06 GMT
Author: djencks
Date: Fri Dec 18 23:29:05 2009
New Revision: 892401

URL: http://svn.apache.org/viewvc?rev=892401&view=rev
Log:
GERONIMO-4992, GERONIMO-4920 Fix a bunch of problems in tomcat, including bad use of Class.forName
in tomcat's StandardContext

Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=892401&r1=892400&r2=892401&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Fri Dec 18 23:29:05 2009
@@ -354,6 +354,9 @@
         //TODO move to method above, also in jetty
         webModuleData.setAttribute("modulePath", webModule.isStandAlone() || webModule.getEarContext()
!= webModule.getRootEarContext()? null: webModule.getTargetPath());
         String contextPath = webModule.getContextRoot();
+        if (!contextPath.startsWith("/")) {
+            contextPath = "/" + contextPath;
+        }
         try {
             moduleContext.addGBean(webModuleData);
             webModuleData.setAttribute("contextPath", contextPath);

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=892401&r1=892400&r2=892401&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Fri Dec 18 23:29:05 2009
@@ -34,9 +34,13 @@
 import org.apache.catalina.Manager;
 import org.apache.catalina.Valve;
 import org.apache.catalina.Wrapper;
+import org.apache.catalina.InstanceListener;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.ContainerListener;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.core.StandardContext;
+import org.apache.catalina.core.StandardWrapper;
 import org.apache.catalina.ha.CatalinaCluster;
 import org.apache.catalina.valves.ValveBase;
 import org.apache.geronimo.common.DeploymentException;
@@ -219,6 +223,66 @@
         }
     }
 
+    private final Object instanceListenersLock = new Object();
+    private final Object wrapperLifecyclesLock = new Object();
+    private final Object wrapperListenersLock = new Object();
+    public Wrapper createWrapper() {
+
+        Wrapper wrapper = null;
+        if (getWrapperClass() != null) {
+            try {
+                wrapper = (Wrapper) getInstanceManager().newInstance(getWrapperClass());
+            } catch (Throwable t) {
+                getLogger().error("createWrapper", t);
+                return (null);
+            }
+        } else {
+            wrapper = new StandardWrapper();
+        }
+
+        synchronized (instanceListenersLock) {
+            for (String instanceListener: findInstanceListeners()) {
+                try {
+                    InstanceListener listener =
+                      (InstanceListener) getInstanceManager().newInstance(instanceListener);
+                    wrapper.addInstanceListener(listener);
+                } catch (Throwable t) {
+                    getLogger().error("createWrapper", t);
+                    return (null);
+                }
+            }
+        }
+
+        synchronized (wrapperLifecyclesLock) {
+            for (String wrapperLifecycle: findWrapperLifecycles()) {
+                try {
+                    LifecycleListener listener =
+                      (LifecycleListener) getInstanceManager().newInstance(wrapperLifecycle);
+                    if (wrapper instanceof Lifecycle)
+                        ((Lifecycle) wrapper).addLifecycleListener(listener);
+                } catch (Throwable t) {
+                    getLogger().error("createWrapper", t);
+                    return (null);
+                }
+            }
+        }
+
+        synchronized (wrapperListenersLock) {
+            for (String wrapperListener: findWrapperListeners()) {
+                try {
+                    ContainerListener listener =
+                      (ContainerListener) getInstanceManager().newInstance(wrapperListener);
+                    wrapper.addContainerListener(listener);
+                } catch (Throwable t) {
+                    getLogger().error("createWrapper", t);
+                    return (null);
+                }
+            }
+        }
+
+        return (wrapper);
+
+    }
     /* This method is called by a background thread to destroy sessions (among other things)
      * so we need to apply appropriate context to the thread to expose JNDI, etc.
      */

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=892401&r1=892400&r2=892401&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
Fri Dec 18 23:29:05 2009
@@ -272,14 +272,6 @@
      */
     public void addContext(TomcatContext contextInfo) throws Exception {
         Context context = createContext(contextInfo.getContextPath(), contextInfo.getClassLoader());
-
-        // Set the context for the Tomcat implementation
-        contextInfo.setContext(context);
-
-        // Have the context to set its properties if its a GeronimoStandardContext
-        if (context instanceof GeronimoStandardContext) {
-            ((GeronimoStandardContext) context).setContextProperties(contextInfo);
-        }
         //Was a virtual server defined?
         String virtualServer = contextInfo.getVirtualServer();
         if (virtualServer == null) {
@@ -289,6 +281,17 @@
         if (host == null) {
             throw new IllegalArgumentException("Invalid virtual host '" + virtualServer +
"'.  Do you have a matching Host entry in the plan?");
         }
+        context.setParent(host);
+        // set the bundle context attribute in the servlet context
+        context.getServletContext().setAttribute("osgi-bundlecontext", contextInfo.getBundle().getBundleContext());
+
+        // Set the context for the Tomcat implementation
+        contextInfo.setContext(context);
+
+        // Have the context to set its properties if its a GeronimoStandardContext
+        if (context instanceof GeronimoStandardContext) {
+            ((GeronimoStandardContext) context).setContextProperties(contextInfo);
+        }
 
         //Get the security-realm-name if there is one
         SecurityHolder secHolder = contextInfo.getSecurityHolder() == null? new SecurityHolder():
contextInfo.getSecurityHolder();

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=892401&r1=892400&r2=892401&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Fri Dec 18 23:29:05 2009
@@ -17,7 +17,6 @@
 
 package org.apache.geronimo.tomcat;
 
-import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -46,8 +45,6 @@
 import org.slf4j.LoggerFactory;
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
 import org.apache.geronimo.gbean.AbstractName;
-import org.apache.geronimo.gbean.GBeanInfo;
-import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
@@ -67,7 +64,6 @@
 import org.apache.geronimo.management.geronimo.WebModule;
 import org.apache.geronimo.naming.enc.EnterpriseNamingContext;
 import org.apache.geronimo.security.jacc.RunAsSource;
-import org.apache.geronimo.security.SecurityNames;
 import org.apache.geronimo.security.jaas.ConfigurationFactory;
 import org.apache.geronimo.tomcat.cluster.CatalinaClusterGBean;
 import org.apache.geronimo.tomcat.stats.ModuleStats;
@@ -97,7 +93,7 @@
     private final ClassLoader classLoader;
     private final Bundle bundle;
     protected Context context = null;
-    private String path = null;
+    private String contextPath = null;
     private String docBase = null;
     private String virtualServer = null;
     private final Realm realm;
@@ -139,6 +135,7 @@
             @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader,
             @ParamSpecial(type = SpecialAttributeType.bundle) Bundle bundle,
             @ParamSpecial(type = SpecialAttributeType.objectName) String objectName,
+            @ParamAttribute(name = "contextPath") String contextPath,
             @ParamAttribute(name = "deploymentDescriptor") String originalSpecDD,
             @ParamAttribute(name = "configurationBaseUrl") URL configurationBaseUrl,
             @ParamAttribute(name = "modulePath")String modulePath,
@@ -197,6 +194,7 @@
         this.bundle = bundle;
         this.modulePath = modulePath;
         this.originalSpecDD = originalSpecDD;
+        this.contextPath = contextPath;
 
         this.virtualServer = virtualServer;
         this.securityHolder = securityHolder;
@@ -359,9 +357,9 @@
         return docBase;
     }
 
-    public void setDocBase(String docBase) {
-        this.docBase = docBase;
-    }
+//    public void setDocBase(String docBase) {
+//        this.docBase = docBase;
+//    }
 
     public UserTransaction getUserTransaction() {
         return userTransaction;
@@ -396,11 +394,7 @@
     }
 
     public String getContextPath() {
-        return path;
-    }
-
-    public void setContextPath(String path) {
-        this.path = path.startsWith("/") ? path : "/" + path;
+        return contextPath;
     }
 
     public SecurityHolder getSecurityHolder() {
@@ -550,8 +544,6 @@
 
         // See the note of TomcatContainer::addContext
         container.addContext(this);
-        // set the bundle context attribute in the servlet context
-        context.getServletContext().setAttribute("osgi-bundlecontext", bundle.getBundleContext());
         // Is it necessary - doesn't Tomcat Embedded take care of it?
         // super.start();
         //register the classloader <> dir context association so that tomcat's jndi
based getResources works.
@@ -563,7 +555,7 @@
         if (context instanceof StandardContext)
             statsProvider = new ModuleStats((StandardContext) context);
 
-        log.debug("TomcatWebAppContext started for " + path);
+        log.debug("TomcatWebAppContext started for " + contextPath);
     }
 
     public void doStop() throws Exception {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?rev=892401&r1=892400&r2=892401&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/test/java/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
Fri Dec 18 23:29:05 2009
@@ -81,6 +81,7 @@
         TomcatWebAppContext app = new TomcatWebAppContext(cl,
                 bundle,
                 null,
+                "/test",
                 null,
                 locationURI.toURL(),
                 "",
@@ -110,7 +111,6 @@
                 null,
                 null,
                 null);
-        app.setContextPath("/test");
         app.doStart();
         return app;
     }



Mime
View raw message