geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r154623 [2/2] - in geronimo/trunk/modules: assembly/src/plan/ axis-builder/ axis-builder/src/java/org/apache/geronimo/axis/builder/ axis-builder/src/test/org/apache/geronimo/axis/builder/ axis/src/java/org/apache/geronimo/axis/client/ j2ee-builder/src/java/org/apache/geronimo/j2ee/deployment/ j2ee-builder/src/test/org/apache/geronimo/j2ee/deployment/ j2ee-schema/ j2ee/src/java/org/apache/geronimo/j2ee/j2eeobjectnames/ jetty-builder/ jetty-builder/src/java/org/apache/geronimo/jetty/deployment/ jetty-builder/src/test/org/apache/geronimo/jetty/deployment/ jetty/src/java/org/apache/geronimo/jetty/ tomcat/src/java/org/apache/geronimo/tomcat/deployment/
Date Mon, 21 Feb 2005 04:43:07 GMT
Modified: geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java?view=diff&r1=154622&r2=154623
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/java/org/apache/geronimo/jetty/deployment/JettyModuleBuilder.java
Sun Feb 20 20:43:02 2005
@@ -58,6 +58,7 @@
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.deployment.ModuleBuilder;
 import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
@@ -67,6 +68,7 @@
 import org.apache.geronimo.jetty.JettyServletHolder;
 import org.apache.geronimo.jetty.JettyWebAppContext;
 import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
@@ -102,6 +104,9 @@
 import org.apache.geronimo.xbeans.j2ee.WebAppType;
 import org.apache.geronimo.xbeans.j2ee.WebResourceCollectionType;
 import org.apache.geronimo.xbeans.j2ee.WelcomeFileListType;
+import org.apache.geronimo.xbeans.j2ee.WebservicesDocument;
+import org.apache.geronimo.axis.builder.WSDescriptorParser;
+import org.apache.geronimo.axis.builder.PortInfo;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.mortbay.http.BasicAuthenticator;
@@ -119,6 +124,9 @@
     private final ObjectName defaultServlets;
     private final ObjectName defaultFilters;
     private final ObjectName defaultFilterMappings;
+    private final ObjectName pojoWebServiceTemplate;
+
+    private final WebServiceBuilder webServiceBuilder;
 
     private final List defaultWelcomeFiles;
     private final Integer defaultSessionTimeoutSeconds;
@@ -133,6 +141,8 @@
                               ObjectName defaultServlets,
                               ObjectName defaultFilters,
                               ObjectName defaultFilterMappings,
+                              ObjectName pojoWebServiceTemplate,
+                              WebServiceBuilder webServiceBuilder,
                               Repository repository,
                               Kernel kernel) {
         this.defaultParentId = defaultParentId;
@@ -141,6 +151,8 @@
         this.defaultServlets = defaultServlets;
         this.defaultFilters = defaultFilters;
         this.defaultFilterMappings = defaultFilterMappings;
+        this.pojoWebServiceTemplate = pojoWebServiceTemplate;
+        this.webServiceBuilder = webServiceBuilder;
         this.repository = repository;
         this.kernel = kernel;
 
@@ -188,6 +200,15 @@
         }
         check(webApp);
 
+        //look for a webservices dd
+        Map portMap = Collections.EMPTY_MAP;
+        try {
+            URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, "WEB-INF/webservices.xml");
+            portMap = WSDescriptorParser.parseWebServiceDescriptor(wsDDUrl, moduleFile, false);
+        } catch (MalformedURLException e) {
+            //no descriptor
+        }
+
         // parse vendor dd
         JettyWebAppType jettyWebApp = getJettyWebApp(plan, moduleFile, standAlone, targetPath,
webApp);
 
@@ -210,7 +231,7 @@
             parentId = defaultParentId;
         }
 
-        WebModule module = new WebModule(standAlone, configId, parentId, moduleFile, targetPath,
webApp, jettyWebApp, specDD);
+        WebModule module = new WebModule(standAlone, configId, parentId, moduleFile, targetPath,
webApp, jettyWebApp, specDD, portMap);
         module.setContextRoot(jettyWebApp.getContextRoot());
         return module;
     }
@@ -673,10 +694,11 @@
 
             //set up servlet gbeans.
             ServletType[] servletTypes = webApp.getServletArray();
+            Map portMap = ((WebModule)module).getPortMap();
 
             for (int i = 0; i < servletTypes.length; i++) {
                 ServletType servletType = servletTypes[i];
-                addServlet(webModuleName, servletType, servletMappings, securityRoles, webClassLoader,
moduleJ2eeContext, earContext);
+                addServlet(webModuleName, servletType, servletMappings, securityRoles, portMap,
webClassLoader, moduleJ2eeContext, earContext);
             }
         } catch (DeploymentException de) {
             throw de;
@@ -704,7 +726,13 @@
         return webClassLoader;
     }
 
-    private void addServlet(ObjectName webModuleName, ServletType servletType, Map servletMappings,
Set securityRoles, ClassLoader webClassLoader, J2eeContext moduleJ2eeContext, EARContext earContext)
throws MalformedObjectNameException, DeploymentException {
+    private void addServlet(ObjectName webModuleName,
+                            ServletType servletType,
+                            Map servletMappings,
+                            Set securityRoles,
+                            Map portMap, ClassLoader webClassLoader,
+                            J2eeContext moduleJ2eeContext,
+                            EARContext earContext) throws MalformedObjectNameException, DeploymentException
{
         String servletName = servletType.getServletName().getStringValue().trim();
         ObjectName servletObjectName = NameFactory.getWebComponentName(null, null, null,
null, servletName, NameFactory.SERVLET, moduleJ2eeContext);
         GBeanData servletData;
@@ -726,9 +754,18 @@
                 servletData = new GBeanData(servletObjectName, JettyServletHolder.GBEAN_INFO);
                 servletData.setAttribute("servletClass", servletClassName);
             } else {
-//                servletData = webServiceBuilder.buildServletGBean();
-                System.out.println("NOT DEPLOYING WEB SERVICE CLASS " + servletClassName);
-                return;
+                try {
+                    servletData = kernel.getGBeanData(pojoWebServiceTemplate);
+                } catch (GBeanNotFoundException e) {
+                    throw new DeploymentException("No POJO web service template gbean found
at object name: " + pojoWebServiceTemplate, e);
+                }
+                servletData.setName(servletObjectName);
+                //let the web service builder deal with configuring the gbean with the web
service stack
+                PortInfo portInfo = (PortInfo) portMap.get(servletName);
+                if (portInfo == null) {
+                    throw new DeploymentException("No web service deployment info for servlet
name " + servletName);
+                }
+                webServiceBuilder.configurePOJO(servletData, portInfo, servletClassName);
             }
         } else if (servletType.isSetJspFile()) {
             servletData = new GBeanData(servletObjectName, JettyServletHolder.GBEAN_INFO);
@@ -1070,6 +1107,8 @@
         infoBuilder.addAttribute("defaultServlets", ObjectName.class, true);
         infoBuilder.addAttribute("defaultFilters", ObjectName.class, true);
         infoBuilder.addAttribute("defaultFilterMappings", ObjectName.class, true);
+        infoBuilder.addAttribute("pojoWebServiceTemplate", ObjectName.class, true);
+        infoBuilder.addReference("WebServiceBuilder", WebServiceBuilder.class);
         infoBuilder.addReference("Repository", Repository.class);
         infoBuilder.addAttribute("kernel", Kernel.class, false);
         infoBuilder.addInterface(ModuleBuilder.class);
@@ -1082,6 +1121,8 @@
             "defaultServlets",
             "defaultFilters",
             "defaultFilterMappings",
+            "pojoWebServiceTemplate",
+            "WebServiceBuilder",
             "Repository",
             "kernel"});
         GBEAN_INFO = infoBuilder.getBeanInfo();

Modified: geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java?view=diff&r1=154622&r2=154623
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/JettyModuleBuilderTest.java
Sun Feb 20 20:43:02 2005
@@ -47,6 +47,7 @@
 import org.apache.geronimo.j2ee.deployment.RefContext;
 import org.apache.geronimo.j2ee.deployment.ResourceReferenceBuilder;
 import org.apache.geronimo.j2ee.deployment.ServiceReferenceBuilder;
+import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContext;
 import org.apache.geronimo.j2ee.j2eeobjectnames.J2eeContextImpl;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
@@ -226,10 +227,12 @@
         kernel.startGBean(baseConfig.getName());
 
         ObjectName defaultServlets = ObjectName.getInstance("test:name=test,type=none,*");
+        ObjectName pojoWebServiceTemplate = null;
+        WebServiceBuilder webServiceBuilder = null;
         //install the policy configuration factory
         SecurityServiceImpl securityService = new SecurityServiceImpl(null, "org.apache.geronimo.security.jacc.GeronimoPolicyConfigurationFactory",
null);
 
-        builder = new JettyModuleBuilder(new URI("null"), new Integer(1800), Collections.EMPTY_LIST,
containerName, defaultServlets, null, null, null, kernel);
+        builder = new JettyModuleBuilder(new URI("null"), new Integer(1800), Collections.EMPTY_LIST,
containerName, defaultServlets, null, null, pojoWebServiceTemplate, webServiceBuilder, null,
kernel);
 
         container = new GBeanData(containerName, JettyContainerImpl.GBEAN_INFO);
 

Modified: geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java?view=diff&r1=154622&r2=154623
==============================================================================
--- geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
(original)
+++ geronimo/trunk/modules/jetty-builder/src/test/org/apache/geronimo/jetty/deployment/PlanParsingTest.java
Sun Feb 20 20:43:02 2005
@@ -9,12 +9,15 @@
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.jetty.JettyWebAppType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerResourceRefType;
+import org.apache.geronimo.j2ee.deployment.WebServiceBuilder;
 
 /**
  */
 public class PlanParsingTest extends TestCase {
     ObjectName jettyContainerObjectName = JMXUtil.getObjectName("test:type=JettyContainer");
-    private JettyModuleBuilder builder = new JettyModuleBuilder(null, new Integer(1800),
null, jettyContainerObjectName, null, null, null, null, null);
+    ObjectName pojoWebServiceTemplate = null;
+    WebServiceBuilder webServiceBuilder = null;
+    private JettyModuleBuilder builder = new JettyModuleBuilder(null, new Integer(1800),
null, jettyContainerObjectName, null, null, null, pojoWebServiceTemplate, webServiceBuilder,
null, null);
     private File basedir = new File(System.getProperty("basedir", "."));
 
     public void testResourceRef() throws Exception {

Added: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyAxisPOJOWebService.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyAxisPOJOWebService.java?view=auto&rev=154623
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyAxisPOJOWebService.java
(added)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyAxisPOJOWebService.java
Sun Feb 20 20:43:02 2005
@@ -0,0 +1,150 @@
+/**
+ *
+ * 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.
+ */
+package org.apache.geronimo.jetty;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.Set;
+import java.util.Collections;
+import javax.security.jacc.PolicyContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.UnavailableException;
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.mortbay.jetty.servlet.ServletHttpRequest;
+
+
+/**
+ * This is intended to hold the web service stack for an axis POJO web service.
+ * It is starting life as a copy of JettyServletHolder.
+ *
+ * @version $Rev: 154436 $ $Date: 2005-02-19 10:22:02 -0800 (Sat, 19 Feb 2005) $
+ */
+public class JettyAxisPOJOWebService extends ServletHolder {
+
+    //todo consider interface instead of this constructor for endpoint use.
+    public JettyAxisPOJOWebService() {
+
+    }
+
+    public JettyAxisPOJOWebService(String servletName,
+                              Map initParams,
+                              Integer loadOnStartup,
+                              Set servletMappings,
+                              Map webRoleRefPermissions,
+                              JettyServletRegistration context) throws Exception {
+        super(context == null? null: context.getServletHandler(), servletName, DummyServlet.class.getName(),
null);
+        //context will be null only for use as "default servlet info holder" in deployer.
+
+        if (context != null) {
+            putAll(initParams);
+            if (loadOnStartup != null) {
+                setInitOrder(loadOnStartup.intValue());
+            }
+            //this now starts the servlet in the appropriate context
+            context.registerServletHolder(this, servletName, servletMappings, webRoleRefPermissions
== null? Collections.EMPTY_MAP: webRoleRefPermissions);
+//            start();
+        }
+    }
+
+    //todo how do we stop/destroy the servlet?
+    //todo is start called twice???
+
+    public String getServletName() {
+        return getName();
+    }
+
+    /**
+     * Service a request with this servlet.  Set the ThreadLocal to hold the
+     * current JettyServletHolder.
+     */
+    public void handle(ServletRequest request, ServletResponse response)
+            throws ServletException, UnavailableException, IOException {
+
+        JettyServletHolder.currentServletHolder.set(this);
+        PolicyContext.setHandlerData(ServletHttpRequest.unwrap(request));
+
+        super.handle(request, response);
+    }
+
+    public static class DummyServlet implements Servlet {
+
+        public void init(ServletConfig config) throws ServletException {
+
+        }
+
+        public ServletConfig getServletConfig() {
+            return null;
+        }
+
+        public void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException {
+           //just for fun, copy input into output
+            InputStream in = req.getInputStream();
+            OutputStream out = res.getOutputStream();
+            byte[] buf = new byte[1024];
+            int i;
+            while ((i = in.read(buf)) > 0) {
+                out.write(buf, 0, i);
+            }
+        }
+
+        public String getServletInfo() {
+            return null;
+        }
+
+        public void destroy() {
+
+        }
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(JettyAxisPOJOWebService.class,
NameFactory.SERVLET_WEB_SERVICE_TEMPLATE);
+        //todo replace with interface
+        infoBuilder.addInterface(ServletHolder.class);
+        
+        infoBuilder.addAttribute("servletName", String.class, true);
+        infoBuilder.addAttribute("initParams", Map.class, true);
+        infoBuilder.addAttribute("loadOnStartup", Integer.class, true);
+        infoBuilder.addAttribute("servletMappings", Set.class, true);
+        infoBuilder.addAttribute("webRoleRefPermissions", Map.class, true);
+        infoBuilder.addReference("JettyServletRegistration", JettyServletRegistration.class);
+
+        infoBuilder.setConstructor(new String[] {"servletName",
+                                                 "initParams",
+                                                 "loadOnStartup", 
+                                                 "servletMappings",
+                                                 "webRoleRefPermissions",
+                                                 "JettyServletRegistration"});
+
+        GBEAN_INFO = infoBuilder.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Modified: geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java?view=diff&r1=154622&r2=154623
==============================================================================
--- geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
(original)
+++ geronimo/trunk/modules/jetty/src/java/org/apache/geronimo/jetty/JettyServletHolder.java
Sun Feb 20 20:43:02 2005
@@ -44,7 +44,7 @@
  * @see org.apache.geronimo.jetty.JAASJettyRealm#isUserInRole(java.security.Principal, java.lang.String)
  */
 public class JettyServletHolder extends ServletHolder {
-    private static final ThreadLocal currentServletHolder = new ThreadLocal();
+    static final ThreadLocal currentServletHolder = new ThreadLocal();
 
     //todo consider interface instead of this constructor for endpoint use.
     public JettyServletHolder() {

Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?view=diff&r1=154622&r2=154623
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
(original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Sun Feb 20 20:43:02 2005
@@ -181,8 +181,9 @@
         // webapp to Jetty- or TomcatModuleBuilder based on parentId.
         log.warn("Assigning defaultParentId [" + defaultParentId + "] to webapp [" + configId
+ "]");
         parentId = defaultParentId;
+        Map portMap = null;
 
-        WebModule module = new WebModule(false, configId, parentId, moduleFile, "war", webApp,
jettyWebApp, specDD);
+        WebModule module = new WebModule(false, configId, parentId, moduleFile, "war", webApp,
jettyWebApp, specDD, portMap);
         module.setContextRoot(jettyWebApp.getContextRoot());
 
         return module;



Mime
View raw message