geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1037595 - in /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src: main/java/org/apache/geronimo/tomcat/ test/java/org/apache/geronimo/tomcat/
Date Mon, 22 Nov 2010 03:05:47 GMT
Author: xuhaihong
Date: Mon Nov 22 03:05:46 2010
New Revision: 1037595

URL: http://svn.apache.org/viewvc?rev=1037595&view=rev
Log:
GERONIMO-5685 No initialized web beans context is attached while creating servlet instance
in Tomcat assembly

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/TomcatInstanceManager.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/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=1037595&r1=1037594&r2=1037595&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
Mon Nov 22 03:05:46 2010
@@ -232,8 +232,11 @@ public class GeronimoStandardContext ext
             owbContext = new HashMap<String, Object>();
             new OpenWebBeansWebInitializer(owbContext, servletContext);
         }
+        if (getInstanceManager() instanceof TomcatInstanceManager) {
+            ((TomcatInstanceManager) getInstanceManager()).setOWBContext(owbContext);
+        }
         interceptor = new OWBBeforeAfter(interceptor, index++, servletContext, owbContext);
-        
+
         //Set a PolicyContext BeforeAfter
         SecurityHolder securityHolder = ctx.getSecurityHolder();
         if (securityHolder != null) {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java?rev=1037595&r1=1037594&r2=1037595&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatInstanceManager.java
Mon Nov 22 03:05:46 2010
@@ -22,12 +22,14 @@ package org.apache.geronimo.tomcat;
 
 
 import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
 
 import javax.naming.Context;
 import javax.naming.NamingException;
 
 import org.apache.tomcat.InstanceManager;
 import org.apache.geronimo.j2ee.annotation.Holder;
+import org.apache.geronimo.openwebbeans.GeronimoSingletonService;
 
 /**
  * @version $Rev$ $Date$
@@ -37,7 +39,7 @@ public class TomcatInstanceManager imple
     private final Holder holder;
     private final ClassLoader classLoader;
     private final Context context;
-
+    private Map<String, Object> owbContext ;
 
     public TomcatInstanceManager(Holder holder, ClassLoader classLoader, Context context)
{
         this.holder = holder;
@@ -46,7 +48,9 @@ public class TomcatInstanceManager imple
     }
 
     public Object newInstance(String fqcn, ClassLoader classLoader) throws IllegalAccessException,
InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException
{
+        Map<String, Object> oldContext = null;
         try {
+            oldContext = GeronimoSingletonService.contextEntered(owbContext);
             return holder.newInstance(fqcn, classLoader, context);
         } catch (IllegalAccessException e) {
             throw e;
@@ -54,14 +58,18 @@ public class TomcatInstanceManager imple
             throw e;
         } catch (Exception e) {
             throw (InstantiationException) new InstantiationException().initCause(e);
+        } finally {
+            GeronimoSingletonService.contextExited(oldContext);
         }
     }
 
     public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException,
NamingException, InstantiationException, ClassNotFoundException {
+        Map<String, Object> oldContext = null;
         try {
             //TODO Specification 13.4.1 p125
             //The @ServletSecurity annotation is not applied to the url-patterns of a ServletRegistration
created using the addServlet(String, Servlet)  method of the ServletContext interface,
             //unless the Servlet was constructed by the createServlet method of the ServletContext
interface.
+            oldContext = GeronimoSingletonService.contextEntered(owbContext);
             return holder.newInstance(className, classLoader, context);
         } catch (IllegalAccessException e) {
             throw e;
@@ -69,14 +77,20 @@ public class TomcatInstanceManager imple
             throw e;
         } catch (Exception e) {
             throw (InstantiationException) new InstantiationException().initCause(e);
+        }finally {
+            GeronimoSingletonService.contextExited(oldContext);
         }
     }
 
     public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException
{
+        Map<String, Object> oldContext = null;
         try {
+            oldContext = GeronimoSingletonService.contextEntered(owbContext);
             holder.destroyInstance(o);
         } catch (Exception e) {
             throw new InvocationTargetException(e, "Attempted to destroy instance");
+        }finally {
+            GeronimoSingletonService.contextExited(oldContext);
         }
     }
 
@@ -87,4 +101,8 @@ public class TomcatInstanceManager imple
         //For a, we should have done the resource injections, for b, we are not need to do
the resource injections
         //Correct me if I miss anything !
     }
+
+    public void setOWBContext(Map<String, Object> owbContext) {
+        this.owbContext = owbContext;
+    }
 }

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=1037595&r1=1037594&r2=1037595&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
Mon Nov 22 03:05:46 2010
@@ -27,7 +27,6 @@ import java.util.Set;
 
 import javax.security.auth.login.LoginException;
 import javax.security.jacc.PolicyContextException;
-import javax.servlet.jsp.JspFactory;
 import javax.transaction.TransactionManager;
 
 import org.apache.felix.karaf.jaas.boot.ProxyLoginModule;



Mime
View raw message