You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2007/12/06 22:21:16 UTC

svn commit: r601860 - in /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat: GeronimoStandardContext.java TomcatContainer.java

Author: gawor
Date: Thu Dec  6 13:21:15 2007
New Revision: 601860

URL: http://svn.apache.org/viewvc?rev=601860&view=rev
Log:
expose jndi in session listener (the listener is called from a background thread). also clean up some other jndi code. (GERONIMO-3528)

Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=601860&r1=601859&r2=601860&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java Thu Dec  6 13:21:15 2007
@@ -191,6 +191,44 @@
         }
     }
 
+    /* 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.
+     */
+    public void backgroundProcess() {
+        Object context[] = null;
+        
+        if (beforeAfter != null){
+            context = new Object[contextCount];
+            beforeAfter.before(context, null, null, BeforeAfter.EDGE_SERVLET);
+        }
+        
+        try {
+            super.backgroundProcess();
+        } finally {
+            if (beforeAfter != null){
+                beforeAfter.after(context, null, null, 0);
+            }
+        }
+    }
+    
+    public void kill() throws Exception {
+        Object context[] = null;
+        
+        if (beforeAfter != null){
+            context = new Object[contextCount];
+            beforeAfter.before(context, null, null, BeforeAfter.EDGE_SERVLET);
+        }
+        
+        try {
+            stop();
+            destroy();
+        } finally {
+            if (beforeAfter != null){
+                beforeAfter.after(context, null, null, 0);
+            }
+        }
+    }
+    
     public synchronized void start() throws LifecycleException {
         if (pipelineInitialized) {
             try {

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=601860&r1=601859&r2=601860&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat6/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java Thu Dec  6 13:21:15 2007
@@ -20,7 +20,6 @@
 import java.net.URL;
 import java.net.URLStreamHandlerFactory;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 import javax.management.ObjectName;
@@ -31,7 +30,6 @@
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Realm;
 import org.apache.catalina.connector.Connector;
-import org.apache.catalina.core.StandardEngine;
 import org.apache.catalina.realm.JAASRealm;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -41,7 +39,6 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.management.geronimo.NetworkConnector;
 import org.apache.geronimo.management.geronimo.WebManager;
-import org.apache.geronimo.naming.java.RootContext;
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.apache.geronimo.tomcat.realm.TomcatGeronimoRealm;
 import org.apache.geronimo.tomcat.realm.TomcatJAASRealm;
@@ -368,16 +365,11 @@
         if (context != null) {
             if (context instanceof GeronimoStandardContext) {
                 GeronimoStandardContext stdctx = (GeronimoStandardContext) context;
-
-                javax.naming.Context oldContext = RootContext.getComponentContext();
-                RootContext.setComponentContext(ctx.getJndiContext());
+                
                 try {
-                    stdctx.stop();
-                    stdctx.destroy();
+                    stdctx.kill();
                 } catch (Exception e) {
                     throw new RuntimeException(e);
-                } finally {
-                    RootContext.setComponentContext(oldContext);
                 }
 
             }