cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1086570 - in /cxf/trunk/rt: frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/ transports/http/src/main/java/org/apache/cxf/transport/servlet/
Date Tue, 29 Mar 2011 12:53:20 GMT
Author: cschneider
Date: Tue Mar 29 12:53:20 2011
New Revision: 1086570

URL: http://svn.apache.org/viewvc?rev=1086570&view=rev
Log:
CXF-3419 Adding CXFNonSpringServlet to make it possible again to run cxf without spring at
runtime

Added:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=1086570&r1=1086569&r2=1086570&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
Tue Mar 29 12:53:20 2011
@@ -42,9 +42,9 @@ import org.apache.cxf.jaxrs.lifecycle.Si
 import org.apache.cxf.jaxrs.utils.ResourceUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
-import org.apache.cxf.transport.servlet.CXFServlet;
+import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
 
-public class CXFNonSpringJaxrsServlet extends CXFServlet {
+public class CXFNonSpringJaxrsServlet extends CXFNonSpringServlet {
 
     private static final Logger LOG = LogUtils.getL7dLogger(CXFNonSpringJaxrsServlet.class);
     

Added: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java?rev=1086570&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
(added)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
Tue Mar 29 12:53:20 2011
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.cxf.transport.servlet;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusException;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.DestinationFactoryManager;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+import org.apache.cxf.transport.servlet.servicelist.ServiceListGeneratorServlet;
+
+public class CXFNonSpringServlet extends AbstractHTTPServlet {
+
+    private HTTPTransportFactory transportFactory;
+    private Bus bus;
+
+    private ServletController controller;
+    
+    public CXFNonSpringServlet() {
+    }
+
+    @Override
+    public void init(ServletConfig sc) throws ServletException {
+        super.init(sc);
+        if (this.bus == null) {
+            loadBus(sc);
+        }
+
+        ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
+        resourceManager.addResourceResolver(new ServletContextResourceResolver(
+                                               sc.getServletContext()));
+
+        if (transportFactory == null) {
+            DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
+            try {
+                DestinationFactory df = dfm
+                    .getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
+                if (df instanceof HTTPTransportFactory) {
+                    transportFactory = (HTTPTransportFactory)df;
+                }
+            } catch (BusException e) {
+                // why are we throwing a busexception if the DF isn't found?
+            }
+        }
+        this.controller = createServletController(sc);
+    }
+
+    protected void loadBus(ServletConfig sc) {
+        this.bus = BusFactory.newInstance().createBus();
+    }
+
+    private ServletController createServletController(ServletConfig servletConfig) {
+        HttpServlet serviceListGeneratorServlet = 
+            new ServiceListGeneratorServlet(transportFactory.getRegistry(), bus);
+        ServletController newController =
+            new ServletController(transportFactory.getRegistry(),
+                                  servletConfig,
+                                  serviceListGeneratorServlet);        
+        return newController;
+    }
+
+    public Bus getBus() {
+        return bus;
+    }
+
+    public void setBus(Bus bus) {
+        this.bus = bus;
+    }
+
+    @Override
+    protected void invoke(HttpServletRequest request, HttpServletResponse response) throws
ServletException {
+        try {
+            BusFactory.setThreadDefaultBus(bus);
+            controller.invoke(request, response);
+        } finally {
+            BusFactory.setThreadDefaultBus(null);
+        }
+    }
+
+}

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?rev=1086570&r1=1086569&r2=1086570&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Tue Mar 29 12:53:20 2011
@@ -21,19 +21,9 @@ package org.apache.cxf.transport.servlet
 import java.io.InputStream;
 
 import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.BusException;
 import org.apache.cxf.BusFactory;
-import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.transport.DestinationFactory;
-import org.apache.cxf.transport.DestinationFactoryManager;
-import org.apache.cxf.transport.http.HTTPTransportFactory;
-import org.apache.cxf.transport.servlet.servicelist.ServiceListGeneratorServlet;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -41,43 +31,13 @@ import org.springframework.context.suppo
 import org.springframework.core.io.InputStreamResource;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 
-public class CXFServlet extends AbstractHTTPServlet {
+public class CXFServlet extends CXFNonSpringServlet {
 
-    private HTTPTransportFactory transportFactory;
-    private Bus bus;
-
-    private ServletController controller;
-    
     public CXFServlet() {
     }
 
     @Override
-    public void init(ServletConfig sc) throws ServletException {
-        super.init(sc);
-        if (this.bus == null) {
-            loadBus(sc);
-        }
-
-        ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
-        resourceManager.addResourceResolver(new ServletContextResourceResolver(
-                                               sc.getServletContext()));
-
-        if (transportFactory == null) {
-            DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-            try {
-                DestinationFactory df = dfm
-                    .getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
-                if (df instanceof HTTPTransportFactory) {
-                    transportFactory = (HTTPTransportFactory)df;
-                }
-            } catch (BusException e) {
-                // why are we throwing a busexception if the DF isn't found?
-            }
-        }
-        this.controller = createServletController(sc);
-    }
-
-    private void loadBus(ServletConfig sc) {
+    protected void loadBus(ServletConfig sc) {
         ApplicationContext wac = WebApplicationContextUtils.
             getWebApplicationContext(sc.getServletContext());
         String configLocation = sc.getInitParameter("config-location");
@@ -85,9 +45,9 @@ public class CXFServlet extends Abstract
             wac = createSpringContext(sc, configLocation);
         }
         if (wac != null) {
-            this.bus = wac.getBean("cxf", Bus.class);
+            setBus(wac.getBean("cxf", Bus.class));
         } else {
-            this.bus = BusFactory.newInstance().createBus();
+            setBus(BusFactory.newInstance().createBus());
         }
     }
 
@@ -114,32 +74,4 @@ public class CXFServlet extends Abstract
         }
     }
 
-    private ServletController createServletController(ServletConfig servletConfig) {
-        HttpServlet serviceListGeneratorServlet = 
-            new ServiceListGeneratorServlet(transportFactory.getRegistry(), bus);
-        ServletController newController =
-            new ServletController(transportFactory.getRegistry(),
-                                  servletConfig,
-                                  serviceListGeneratorServlet);        
-        return newController;
-    }
-
-    public Bus getBus() {
-        return bus;
-    }
-
-    public void setBus(Bus bus) {
-        this.bus = bus;
-    }
-
-    @Override
-    protected void invoke(HttpServletRequest request, HttpServletResponse response) throws
ServletException {
-        try {
-            BusFactory.setThreadDefaultBus(bus);
-            controller.invoke(request, response);
-        } finally {
-            BusFactory.setThreadDefaultBus(null);
-        }
-    }
-
 }



Mime
View raw message