geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r397614 - in /geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat: TomcatContainer.java TomcatWebAppContext.java
Date Thu, 27 Apr 2006 19:12:53 GMT
Author: djencks
Date: Thu Apr 27 12:12:51 2006
New Revision: 397614

URL: http://svn.apache.org/viewcvs?rev=397614&view=rev
Log:
GERONIMO-1924 Register tomcats url handler.  Register classloader<>dircontext association

Modified:
    geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java

Modified: geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=397614&r1=397613&r2=397614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
Thu Apr 27 12:12:51 2006
@@ -19,6 +19,9 @@
 import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
+import java.net.URLStreamHandlerFactory;
+import java.net.URL;
+
 import org.apache.catalina.Container;
 import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
@@ -39,14 +42,15 @@
 import org.apache.geronimo.tomcat.util.SecurityHolder;
 import org.apache.geronimo.webservices.SoapHandler;
 import org.apache.geronimo.webservices.WebServiceContainer;
+import org.apache.naming.resources.DirContextURLStreamHandlerFactory;
 
 
 /**
  * Apache Tomcat GBean
+ * http://wiki.apache.org/geronimo/Tomcat
+ * http://nagoya.apache.org/jira/browse/GERONIMO-215
  *
  * @version $Rev$ $Date$
- * @see http://wiki.apache.org/geronimo/Tomcat
- * @see http://nagoya.apache.org/jira/browse/GERONIMO-215
  */
 public class TomcatContainer implements SoapHandler, GBeanLifecycle, TomcatWebContainer {
 
@@ -75,6 +79,7 @@
     private final Map webServices = new HashMap();
     private final String objectName;
     private final WebManager manager;
+    private static boolean first = true;
 
     // Required as it's referenced by deployed webapps
     public TomcatContainer() {
@@ -87,6 +92,24 @@
      * GBean constructor (invoked dynamically when the gbean is declared in a plan)
      */
     public TomcatContainer(ClassLoader classLoader, String catalinaHome, ObjectRetriever
engineGBean, ServerInfo serverInfo, String objectName, WebManager manager) {
+        // Register a stream handler factory for the JNDI protocol
+        URLStreamHandlerFactory streamHandlerFactory =
+            new DirContextURLStreamHandlerFactory();
+        if (first) {
+            first = false;
+            try {
+                URL.setURLStreamHandlerFactory(streamHandlerFactory);
+            } catch (Exception e) {
+                // Log and continue anyway, this is not critical
+                log.error("Error registering jndi stream handler", e);
+            } catch (Throwable t) {
+                // This is likely a dual registration
+                log.info("Dual registration of jndi stream handler: "
+                         + t.getMessage());
+            }
+        }
+
+
         if (catalinaHome == null)
             catalinaHome = DEFAULT_CATALINA_HOME;
 

Modified: geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=397614&r1=397613&r2=397614&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/branches/1.1/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Thu Apr 27 12:12:51 2006
@@ -43,9 +43,12 @@
 import org.apache.geronimo.transaction.TrackedConnectionAssociator;
 import org.apache.geronimo.transaction.context.OnlineUserTransaction;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.naming.resources.DirContextURLStreamHandler;
 
 import javax.management.ObjectName;
 import javax.management.MalformedObjectNameException;
+import javax.naming.directory.DirContext;
+
 import java.net.URI;
 import java.net.URL;
 import java.net.MalformedURLException;
@@ -445,13 +448,17 @@
         container.addContext(this);
         // 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.
+        DirContext resources = context.getResources();
+        DirContextURLStreamHandler.bind((ClassLoader) classLoader, resources);
 
         log.debug("TomcatWebAppContext started for " + path);
     }
 
     public void doStop() throws Exception {
         container.removeContext(this);
-
+        DirContextURLStreamHandler.unbind((ClassLoader) classLoader);
+ 
         // No more logging will occur for this ClassLoader. Inform the LogFactory to avoid
a memory leak.
 //        LogFactory.release(classLoader);
 



Mime
View raw message