geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r180209 - in /geronimo/trunk/modules/tomcat: ./ src/java/org/apache/geronimo/tomcat/
Date Mon, 06 Jun 2005 04:17:56 GMT
Author: jgenender
Date: Sun Jun  5 21:17:54 2005
New Revision: 180209

URL: http://svn.apache.org/viewcvs?rev=180209&view=rev
Log:
Added webservice integration

Modified:
    geronimo/trunk/modules/tomcat/project.xml
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.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/java/org/apache/geronimo/tomcat/TomcatContext.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
    geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java

Modified: geronimo/trunk/modules/tomcat/project.xml
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/project.xml?rev=180209&r1=180208&r2=180209&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/project.xml (original)
+++ geronimo/trunk/modules/tomcat/project.xml Sun Jun  5 21:17:54 2005
@@ -130,6 +130,11 @@
             <version>${pom.currentVersion}</version>
         </dependency>
         <dependency>
+            <groupId>geronimo</groupId>
+            <artifactId>geronimo-webservices</artifactId>
+            <version>${pom.currentVersion}</version>
+        </dependency>
+        <dependency>
             <groupId>geronimo-spec</groupId>
             <artifactId>geronimo-spec-j2ee</artifactId>
             <version>${geronimo_spec_j2ee_version}</version>

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=180209&r1=180208&r2=180209&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Sun Jun  5 21:17:54 2005
@@ -16,19 +16,24 @@
  */
 package org.apache.geronimo.tomcat;
 
-import java.util.List;
+import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 
 import javax.naming.NamingException;
 import javax.security.auth.Subject;
 import javax.security.jacc.PolicyContext;
+import javax.servlet.Servlet;
 
+import org.apache.catalina.Container;
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.Valve;
+import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.StandardContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.kernel.StoredObject;
 import org.apache.geronimo.naming.java.SimpleReadOnlyContext;
 import org.apache.geronimo.naming.reference.ClassLoaderAwareReference;
 import org.apache.geronimo.naming.reference.KernelAwareReference;
@@ -43,6 +48,9 @@
 import org.apache.geronimo.tomcat.valve.PolicyContextValve;
 import org.apache.geronimo.tomcat.valve.TransactionContextValve;
 import org.apache.geronimo.transaction.context.TransactionContextManager;
+import org.apache.geronimo.webservices.POJOWebServiceServlet;
+import org.apache.geronimo.webservices.WebServiceContainer;
+import org.apache.geronimo.webservices.WebServiceContainerInvoker;
 
 public class GeronimoStandardContext extends StandardContext{
     
@@ -52,6 +60,8 @@
 
     private Subject defaultSubject = null;
     
+    private Map webServiceMap = null;
+    
     public void setContextProperties(TomcatContext ctx){
     
         // Create ReadOnlyContext
@@ -128,7 +138,7 @@
             }
         }
 
-
+        this.webServiceMap = ctx.getWebServices();
     }
 
     public synchronized void start() throws LifecycleException {
@@ -144,5 +154,51 @@
        super.stop();
     }
     
+    public void addChild(Container child){
+        Wrapper wrapper = (Wrapper) child;
+        
+        String servletClassName = wrapper.getServletClass();
+        
+        ClassLoader cl = this.getParentClassLoader();
+        
+        Class baseServletClass = null;
+        Class servletClass = null;
+        try{
+            baseServletClass = cl.loadClass(Servlet.class.getName());
+            servletClass = cl.loadClass(servletClassName);
+            //Check if the servlet is of type Servlet class
+            if (!baseServletClass.isAssignableFrom(servletClass)){
+                //Nope - its probably a webservice, so lets see...
+                if (webServiceMap != null){
+                    StoredObject storedObject = (StoredObject)webServiceMap.get(wrapper.getName());
+                        
+                    if (storedObject != null){
+                        WebServiceContainer webServiceContainer = null;
+                        try{
+                            webServiceContainer = (WebServiceContainer)storedObject.getObject(cl);
+                        } catch(IOException io){
+                            throw new RuntimeException(io);
+                        }
+                        //Yep its a web service
+                        //So swap it out with a POJOWebServiceServlet
+                        wrapper.setServletClass("org.apache.geronimo.webservices.POJOWebServiceServlet");
+                    
+                        //Set the WebServiceContainer stuff
+                        String webServicecontainerID = wrapper.getName() + WebServiceContainerInvoker.WEBSERVICE_CONTAINER
+ webServiceContainer.hashCode();
+                        getServletContext().setAttribute(webServicecontainerID, webServiceContainer);
+                        wrapper.addInitParameter(WebServiceContainerInvoker.WEBSERVICE_CONTAINER,
webServicecontainerID);
     
+                        //Set the SEI Class in the attribute
+                        String pojoClassID = wrapper.getName() + POJOWebServiceServlet.POJO_CLASS
+ servletClass.hashCode();
+                        getServletContext().setAttribute(pojoClassID, servletClass);
+                        wrapper.addInitParameter(POJOWebServiceServlet.POJO_CLASS, pojoClassID);
+                    }
+                }
+            }
+        } catch (ClassNotFoundException e){
+            throw new RuntimeException(e.getMessage(), e);
+        }
+                
+        super.addChild(child);
+    }
 }

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=180209&r1=180208&r2=180209&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
Sun Jun  5 21:17:54 2005
@@ -96,10 +96,10 @@
                    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") ||
+                   name.startsWith("org/apache/jasper/") ||
+                   name.startsWith("org/apache/tomcat/") ||
+                   name.startsWith("org/apache/naming/") ||
+                   name.startsWith("org/apache/catalina/") ||
                    name.startsWith("org/xml/") ||
                    name.startsWith("org/w3c/")) {
                return super.getResource(name);

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=180209&r1=180208&r2=180209&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
Sun Jun  5 21:17:54 2005
@@ -135,8 +135,7 @@
         //Add default contexts
         Container[] hosts = engine.findChildren();
         for(int i = 0; i < hosts.length; i++){
-            Context defaultContext = embedded.createContext("","");
-            defaultContext.setParentClassLoader(classLoader);
+            Context defaultContext = embedded.createContext("","", classLoader);
             hosts[i].addChild(defaultContext);
         }
         
@@ -167,9 +166,7 @@
      * @see org.apache.catalina.Host
      */
     public void addContext(TomcatContext ctx) throws Exception{
-        Context anotherCtxObj = embedded.createContext(ctx.getPath(), ctx.getDocBase());
-        anotherCtxObj.setParentClassLoader(ctx.getWebClassLoader());
-        //anotherCtxObj.setParentClassLoader(this.getClass().getClassLoader());
+        Context anotherCtxObj = embedded.createContext(ctx.getPath(), ctx.getDocBase(), ctx.getWebClassLoader());
 
         // Set the context for the Tomcat implementation
         ctx.setContext(anotherCtxObj);

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java?rev=180209&r1=180208&r2=180209&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContext.java Sun
Jun  5 21:17:54 2005
@@ -61,4 +61,6 @@
     public Realm getRealm();
     
     public List getValveChain();    
+    
+    public Map getWebServices();
 }

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java?rev=180209&r1=180208&r2=180209&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatGeronimoEmbedded.java
Sun Jun  5 21:17:54 2005
@@ -16,8 +16,6 @@
 */
 package org.apache.geronimo.tomcat;
 
-import java.io.File;
-
 import org.apache.catalina.Context;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.startup.ContextConfig;
@@ -28,8 +26,8 @@
 public class TomcatGeronimoEmbedded extends Embedded{
     
     private static final Log log = LogFactory.getLog(TomcatGeronimoEmbedded.class);
-
-    public Context createContext(String path, String docBase) {
+    
+    public Context createContext(String path, String docBase, ClassLoader cl) {
 
         if( log.isDebugEnabled() )
             log.debug("Creating context '" + path + "' with docBase '" +
@@ -39,6 +37,7 @@
 
         context.setDocBase(docBase);
         context.setPath(path);
+        context.setParentClassLoader(cl);
         
         ContextConfig config = new ContextConfig();
         config.setCustomAuthenticators(authenticators);

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java?rev=180209&r1=180208&r2=180209&view=diff
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatWebAppContext.java
Sun Jun  5 21:17:54 2005
@@ -93,6 +93,8 @@
     private final J2EEServer server;
 
     private final J2EEApplication application;
+    
+    private final Map webServices;
 
     public TomcatWebAppContext(
             ClassLoader classLoader,
@@ -114,6 +116,7 @@
             RoleDesignateSource roleDesignateSource,
             ObjectRetriever tomcatRealm,
             ValveGBean tomcatValveChain,
+            Map webServices,
             J2EEServer server, 
             J2EEApplication application, 
             Kernel kernel)
@@ -167,14 +170,16 @@
             valveChain = null;
         }
         
+        this.webServices = webServices;
+        
         URI root = URI.create(configurationBaseUrl.toString());
-        webAppRoot = root.resolve(webAppRoot);
+//        webAppRoot = root.resolve(webAppRoot);
         URL webAppRootURL = webAppRoot.toURL();
         
         URL[] urls = new URL[webClassPath.length];
         for (int i = 0; i < webClassPath.length; i++) {
             URI classPathEntry = webClassPath[i];
-            classPathEntry = root.resolve(classPathEntry);
+            classPathEntry = webAppRoot.resolve(classPathEntry);
             urls[i] = classPathEntry.toURL();
         }
         this.webClassLoader = new TomcatClassLoader(urls, webAppRootURL, classLoader, contextPriorityClassLoader);
@@ -266,6 +271,10 @@
         return valveChain;
     }
 
+    public Map getWebServices(){
+        return webServices;
+    }
+    
     /**
      * ObjectName must match this pattern: <p/>
      * domain:j2eeType=WebModule,name=MyName,J2EEServer=MyServer,J2EEApplication=MyApplication
@@ -359,6 +368,7 @@
                 RoleDesignateSource.class, NameFactory.JACC_MANAGER);
         infoBuilder.addReference("TomcatRealm", ObjectRetriever.class);
         infoBuilder.addReference("TomcatValveChain", ValveGBean.class);
+        infoBuilder.addAttribute("webServices", Map.class, true);
         infoBuilder.addReference("J2EEServer", J2EEServer.class);
         infoBuilder.addReference("J2EEApplication", J2EEApplication.class);
         infoBuilder.addAttribute("kernel", Kernel.class, false);
@@ -383,6 +393,7 @@
                 "RoleDesignateSource", 
                 "TomcatRealm",
                 "TomcatValveChain",
+                "webServices",
                 "J2EEServer", 
                 "J2EEApplication",
                 "kernel" 



Mime
View raw message