geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1061595 - in /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat: GeronimoStandardContext.java TomcatContext.java
Date Fri, 21 Jan 2011 01:54:51 GMT
Author: xuhaihong
Date: Fri Jan 21 01:54:51 2011
New Revision: 1061595

URL: http://svn.apache.org/viewvc?rev=1061595&view=rev
Log:
Use ThreadLocal to keep the context info, and initialization work

Modified:
    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/TomcatContext.java

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=1061595&r1=1061594&r2=1061595&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 Jan 21 01:54:51 2011
@@ -30,6 +30,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Stack;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
@@ -112,7 +113,7 @@ public class GeronimoStandardContext ext
     private Subject defaultSubject = null;
     private RunAsSource runAsSource = RunAsSource.NULL;
 
-    private Map webServiceMap = null;
+    private Map<String, WebServiceContainer> webServiceMap = null;
 
     private boolean pipelineInitialized;
 
@@ -128,6 +129,15 @@ public class GeronimoStandardContext ext
     private Bundle bundle;
     private ServiceRegistration serviceRegistration;
 
+    private ThreadLocal<Stack<Object[]>> beforeAfterContexts = new ThreadLocal<Stack<Object[]>>()
{
+
+        @Override
+        protected Stack<Object[]> initialValue() {
+            return new Stack<Object[]>();
+        }
+
+    };
+
     public GeronimoStandardContext() {
         setXmlNamespaceAware(true);
         // disable Tomcat startup TLD scanning
@@ -285,18 +295,18 @@ public class GeronimoStandardContext ext
         addValve(new SystemMethodValve());
 
         // Add User Defined Valves
-        List valveChain = ctx.getValveChain();
+        List<Valve> valveChain = ctx.getValveChain();
         if (valveChain != null) {
-            for (Object valve : valveChain) {
-                addValve((Valve)valve);
+            for (Valve valve : valveChain) {
+                addValve(valve);
             }
         }
 
         // Add User Defined Listeners
-        List listenerChain = ctx.getLifecycleListenerChain();
+        List<LifecycleListener> listenerChain = ctx.getLifecycleListenerChain();
         if (listenerChain != null) {
-            for (Object listener : listenerChain) {
-                addLifecycleListener((LifecycleListener)listener);
+            for (LifecycleListener listener : listenerChain) {
+                addLifecycleListener(listener);
             }
         }
 
@@ -452,7 +462,7 @@ public class GeronimoStandardContext ext
                 Valve valve = getPipeline().getFirst();
                 valve.invoke(null, null);
 
-                // if a servlet uses run-as then make sure role desgnates have been provided
+                // if a servlet uses run-as then make sure role designates have been provided
                 if (hasRunAsServlet()) {
                     if (runAsSource == null) {
                         throw new GeronimoSecurityException("web.xml or annotation specifies
a run-as role but no subject configuration supplied for run-as roles");
@@ -513,8 +523,8 @@ public class GeronimoStandardContext ext
 
         ClassLoader cl = this.getParentClassLoader();
 
-        Class baseServletClass;
-        Class servletClass;
+        Class<?> baseServletClass;
+        Class<?> servletClass;
         try {
             baseServletClass = cl.loadClass(Servlet.class.getName());
             servletClass = cl.loadClass(servletClassName);
@@ -522,7 +532,7 @@ public class GeronimoStandardContext ext
             if (!baseServletClass.isAssignableFrom(servletClass)) {
                 //Nope - its probably a webservice, so lets see...
                 if (webServiceMap != null) {
-                    WebServiceContainer webServiceContainer = (WebServiceContainer) webServiceMap.get(wrapper.getName());
+                    WebServiceContainer webServiceContainer = webServiceMap.get(wrapper.getName());
 
                     if (webServiceContainer != null) {
                         //Yep its a web service
@@ -816,4 +826,25 @@ public class GeronimoStandardContext ext
         super.addSecurityRole(role);
         webSecurityConstraintStore.declareRoles(role);
     }
+
+    @Override
+    protected ClassLoader bindThread() {
+        ClassLoader oldClassLoader =  super.bindThread();
+        Object context[] = null;
+
+        if (beforeAfter != null){
+            context = new Object[contextCount];
+            beforeAfterContexts.get().push(context);
+            beforeAfter.before(context, null, null, BeforeAfter.EDGE_SERVLET);
+        }
+        return oldClassLoader;
+    }
+
+    @Override
+    protected void unbindThread(ClassLoader oldContextClassLoader) {
+        super.unbindThread(oldContextClassLoader);
+        if (beforeAfter != null){
+            beforeAfter.after(beforeAfterContexts.get().pop(), null, null, 0);
+        }
+    }
 }

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java?rev=1061595&r1=1061594&r2=1061595&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
Fri Jan 21 01:54:51 2011
@@ -24,6 +24,7 @@ import java.util.Set;
 import javax.transaction.UserTransaction;
 
 import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Manager;
 import org.apache.catalina.Realm;
 import org.apache.catalina.Valve;
@@ -32,6 +33,7 @@ import org.apache.geronimo.connector.out
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.web.info.WebAppInfo;
+import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.tomcat.InstanceManager;
 import org.apache.webbeans.config.WebBeansContext;
 import org.osgi.framework.Bundle;
@@ -60,19 +62,19 @@ public interface TomcatContext {
 
     Kernel getKernel();
 
-    Set getApplicationManagedSecurityResources();
+    Set<String> getApplicationManagedSecurityResources();
 
     TrackedConnectionAssociator getTrackedConnectionAssociator();
 
-    Set getUnshareableResources();
+    Set<String> getUnshareableResources();
 
     Realm getRealm();
 
     Valve getClusteredValve();
 
-    List getValveChain();
+    List<Valve> getValveChain();
 
-    List getLifecycleListenerChain();
+    List<LifecycleListener> getLifecycleListenerChain();
 
     CatalinaCluster getCluster();
 
@@ -84,7 +86,7 @@ public interface TomcatContext {
 
     boolean isDisableCookies();
 
-    Map getWebServices();
+    Map<String, WebServiceContainer> getWebServices();
 
     InstanceManager getInstanceManager();
 



Mime
View raw message