You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jg...@apache.org on 2005/04/26 20:02:03 UTC

svn commit: r164844 - in /geronimo/trunk/modules/tomcat/src: etc/ etc/META-INF/ java/org/apache/geronimo/tomcat/ test/org/apache/geronimo/tomcat/

Author: jgenender
Date: Tue Apr 26 11:02:03 2005
New Revision: 164844

URL: http://svn.apache.org/viewcvs?rev=164844&view=rev
Log:
Fixed classloader issue and added default context

Added:
    geronimo/trunk/modules/tomcat/src/etc/
    geronimo/trunk/modules/tomcat/src/etc/META-INF/
    geronimo/trunk/modules/tomcat/src/etc/META-INF/geronimo-service.xml
Modified:
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatClassLoader.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java

Added: geronimo/trunk/modules/tomcat/src/etc/META-INF/geronimo-service.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/etc/META-INF/geronimo-service.xml?rev=164844&view=auto
==============================================================================
--- geronimo/trunk/modules/tomcat/src/etc/META-INF/geronimo-service.xml (added)
+++ geronimo/trunk/modules/tomcat/src/etc/META-INF/geronimo-service.xml Tue Apr 26 11:02:03 2005
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright 2004 The Apache Software Foundation
+
+    Licensed under the Apache License, Version 2.0 (the "License");
+    you may not use this file except in compliance with the License.
+    You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+-->
+
+
+<!--dependencies for jetty-->
+<service xmlns="http://geronimo.apache.org/xml/ns/deployment">
+
+    <dependency>
+        <uri>tomcat/jars/jasper-compiler-${jasper_version}.jar</uri>
+    </dependency>
+    <!--this is the eclipse compiler-->
+    <dependency>
+        <uri>tomcat/jars/jasper-compiler-jdt-${jasper_version}.jar</uri>
+    </dependency>
+    <dependency>
+        <uri>tomcat/jars/jasper-runtime-${jasper_version}.jar</uri>
+    </dependency>
+    <dependency>
+        <uri>commons-el/jars/commons-el-${commons_el_version}.jar</uri>
+    </dependency>
+
+</service>

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java?rev=164844&r1=164843&r2=164844&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/HostGBean.java Tue Apr 26 11:02:03 2005
@@ -18,9 +18,11 @@
 
 import java.util.Map;
 
+import org.apache.catalina.Context;
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
 import org.apache.catalina.Realm;
+import org.apache.catalina.core.StandardContext;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
@@ -49,6 +51,7 @@
         setParameters(host, initParams);
         
         Engine engine = ((Engine)engineGBean.getInternalObject());
+
         if (realmGBean != null)
             host.setRealm((Realm)realmGBean.getInternalObject());
         else

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatClassLoader.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatClassLoader.java?rev=164844&r1=164843&r2=164844&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatClassLoader.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatClassLoader.java Tue Apr 26 11:02:03 2005
@@ -53,6 +53,7 @@
                name.startsWith("java.") ||
                name.startsWith("javax.") ||
                name.startsWith("org.apache.geronimo.") ||
+               name.startsWith("org.apache.jasper.") ||
                name.startsWith("org.apache.tomcat.") ||
                name.startsWith("org.apache.naming.") ||
                name.startsWith("org.apache.catalina.") ||
@@ -95,6 +96,7 @@
                    name.startsWith("java/") ||
                    name.startsWith("javax/") ||
                    name.startsWith("org/apache/geronimo/") ||
+                   name.startsWith("org/apache/jasper") ||
                    name.startsWith("org/apache/tomcat") ||
                    name.startsWith("org/apache/naming") ||
                    name.startsWith("org/apache/catalina") ||

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=164844&r1=164843&r2=164844&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java Tue Apr 26 11:02:03 2005
@@ -63,6 +63,11 @@
     private Context defaultContext;
 
     /**
+     * Geronimo class loader
+     **/
+    private ClassLoader classLoader;
+
+    /**
      * Used only to resolve the paths
      */
     private ServerInfo serverInfo;
@@ -75,12 +80,18 @@
     /**
      * GBean constructor (invoked dynamically when the gbean is declared in a plan)
      */
-    public TomcatContainer(String catalinaHome, ObjectRetriever engineGBean, ServerInfo serverInfo) {
+    public TomcatContainer(ClassLoader classLoader, String catalinaHome, ObjectRetriever engineGBean, ServerInfo serverInfo) {
         setCatalinaHome(catalinaHome);
 
+        if (classLoader == null){
+            throw new IllegalArgumentException("classLoader cannot be null.");
+        }
+
         if (engineGBean == null){
             throw new IllegalArgumentException("engineGBean cannot be null.");
         }
+
+        this.classLoader = classLoader;
         
         this.engine = (Engine)engineGBean.getInternalObject();
         this.serverInfo = serverInfo;
@@ -121,10 +132,13 @@
         // the default Realm if you are using container-managed security.
         embedded.setUseNaming(false);
 
-        // 4. Call createHost() to create at least one virtual Host associated
-        // with the newly created Engine, and then call its property setters as
-        // desired. After you customize this Host, add it to the corresponding
-        // Engine with engine.addChild(host).
+        //Add default contexts
+        Container[] hosts = engine.findChildren();
+        for(int i = 0; i < hosts.length; i++){
+            Context defaultContext = embedded.createContext("","");
+            defaultContext.setParentClassLoader(classLoader);
+            hosts[i].addChild(defaultContext);
+        }
         
         // 6. Call addEngine() to attach this Engine to the set of defined
         // Engines for this object.
@@ -204,7 +218,9 @@
     static {
         GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Tomcat Web Container", TomcatContainer.class);
 
-        infoFactory.setConstructor(new String[] { "catalinaHome", "engineGBean", "ServerInfo" });
+        infoFactory.setConstructor(new String[] { "classLoader", "catalinaHome", "engineGBean", "ServerInfo" });
+
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
 
         infoFactory.addAttribute("catalinaHome", String.class, true);
 
@@ -224,4 +240,4 @@
     public static GBeanInfo getGBeanInfo() {
         return GBEAN_INFO;
     }
-}
\ No newline at end of file
+}

Modified: geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?rev=164844&r1=164843&r2=164844&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java (original)
+++ geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java Tue Apr 26 11:02:03 2005
@@ -321,6 +321,7 @@
 
         // Need to override the constructor for unit tests
         container = new GBeanData(containerName, TomcatContainer.GBEAN_INFO);
+        container.setAttribute("classLoader", cl);
         container.setAttribute("catalinaHome", "target/var/catalina");
         container.setReferencePattern("engineGBean", engineName);
         container.setReferencePattern("ServerInfo", serverInfoName);