felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1761522 - in /felix/trunk/http: base/src/main/java/org/apache/felix/http/base/internal/ bridge/src/main/java/org/apache/felix/http/bridge/internal/ jetty/src/main/java/org/apache/felix/http/jetty/internal/
Date Tue, 20 Sep 2016 05:44:35 GMT
Author: cziegeler
Date: Tue Sep 20 05:44:34 2016
New Revision: 1761522

URL: http://svn.apache.org/viewvc?rev=1761522&view=rev
Log:
FELIX-5349 : add ManagedServiceFactory to HTTP service. Cleaning up code

Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/DispatcherServlet.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java
    felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/DispatcherServlet.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/DispatcherServlet.java?rev=1761522&r1=1761521&r2=1761522&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/DispatcherServlet.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/DispatcherServlet.java
Tue Sep 20 05:44:34 2016
@@ -27,10 +27,14 @@ import org.apache.felix.http.base.intern
 
 /**
  * The dispatcher servlet is registered in the container.
- *
+ * It is dispatching requests to the http implementation.
+ * It does not start the http service, this needs to be done
+ * through the {@link HttpServiceController}.
  */
 public class DispatcherServlet extends HttpServlet
 {
+    private static final long serialVersionUID = -7692620012572476116L;
+
     private final Dispatcher controller;
 
     public DispatcherServlet(final Dispatcher controller)

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java?rev=1761522&r1=1761521&r2=1761522&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java
Tue Sep 20 05:44:34 2016
@@ -19,6 +19,7 @@ package org.apache.felix.http.base.inter
 import java.util.Hashtable;
 
 import javax.annotation.Nonnull;
+import javax.servlet.Servlet;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpSessionAttributeListener;
 import javax.servlet.http.HttpSessionEvent;
@@ -37,30 +38,17 @@ public final class HttpServiceController
     private final BundleContext bundleContext;
     private final HandlerRegistry registry;
     private final Dispatcher dispatcher;
-    private final DispatcherServlet dispatcherServlet;
     private final EventDispatcher eventDispatcher;
     private final HttpServiceFactory httpServiceFactory;
     private final WhiteboardManager whiteboardManager;
 
     private volatile HttpSessionListener httpSessionListener;
 
-
-    public DispatcherServlet getDispatcherServlet()
-    {
-        return this.dispatcherServlet;
-    }
-
-    public EventDispatcher getEventDispatcher()
-    {
-        return this.eventDispatcher;
-    }
-
     public HttpServiceController(final BundleContext bundleContext)
     {
         this.bundleContext = bundleContext;
         this.registry = new HandlerRegistry();
         this.dispatcher = new Dispatcher(this.registry);
-        this.dispatcherServlet = new DispatcherServlet(this.dispatcher);
         this.eventDispatcher = new EventDispatcher(this);
         this.httpServiceFactory = new HttpServiceFactory(this.bundleContext, this.registry);
         this.whiteboardManager = new WhiteboardManager(bundleContext, this.httpServiceFactory,
this.registry);
@@ -69,12 +57,20 @@ public final class HttpServiceController
     public void stop()
     {
         this.unregister();
-        this.dispatcherServlet.destroy();
     }
 
-    public Dispatcher getDispatcher()
+    /**
+     * Create a new dispatcher servlet
+     * @return The dispatcher servlet.
+     */
+    public @Nonnull Servlet createDispatcherServlet()
     {
-        return this.dispatcher;
+        return new DispatcherServlet(this.dispatcher);
+    }
+
+    public EventDispatcher getEventDispatcher()
+    {
+        return this.eventDispatcher;
     }
 
     HttpSessionListener getSessionListener()

Modified: felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java?rev=1761522&r1=1761521&r2=1761522&view=diff
==============================================================================
--- felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
(original)
+++ felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
Tue Sep 20 05:44:34 2016
@@ -18,15 +18,18 @@
  */
 package org.apache.felix.http.bridge.internal;
 
+import java.io.IOException;
 import java.util.EventListener;
 import java.util.Hashtable;
 
+import javax.servlet.Servlet;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServlet;
 
 import org.apache.felix.http.base.internal.AbstractHttpActivator;
-import org.apache.felix.http.base.internal.DispatcherServlet;
 import org.apache.felix.http.base.internal.EventDispatcher;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.osgi.framework.Constants;
@@ -54,13 +57,16 @@ public final class BridgeActivator exten
                     getBundleContext().getProperty(FELIX_HTTP_SERVICE_ENDPOINTS));
         }
 
-        final Object servlet = new DispatcherServlet(this.getHttpServiceController().getDispatcher())
+        final Servlet dispatcherServlet = this.getHttpServiceController().createDispatcherServlet();
+        final Object servlet = new HttpServlet()
         {
+            private static final long serialVersionUID = -5229577898597483605L;
 
             @Override
             public void destroy()
             {
                 getHttpServiceController().unregister();
+                dispatcherServlet.destroy();
                 super.destroy();
             }
 
@@ -68,10 +74,17 @@ public final class BridgeActivator exten
             public void init(final ServletConfig config) throws ServletException
             {
                 super.init(config);
+                dispatcherServlet.init(config);
                 getHttpServiceController().register(config.getServletContext(), serviceRegProps);
             }
+
+            @Override
+            public void service(ServletRequest req, ServletResponse res) throws ServletException,
IOException {
+                dispatcherServlet.service(req, res);
+            }
         };
-        // dispatcher servlet
+
+        // register dispatcher servlet
         Hashtable<String, Object> props = new Hashtable<String, Object>();
         props.put(MARKER_PROP, servlet.getClass().getName());
         props.put(Constants.SERVICE_DESCRIPTION, "Apache Felix Http Dispatcher for bridged
request handling");

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1761522&r1=1761521&r2=1761522&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
(original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
Tue Sep 20 05:44:34 2016
@@ -344,7 +344,7 @@ public final class JettyService extends
             this.controller.getEventDispatcher().setActive(true);
             context.addEventListener(controller.getEventDispatcher());
             context.getSessionHandler().addEventListener(controller.getEventDispatcher());
-            final ServletHolder holder = new ServletHolder(this.controller.getDispatcherServlet());
+            final ServletHolder holder = new ServletHolder(this.controller.createDispatcherServlet());
             holder.setAsyncSupported(true);
             context.addServlet(holder, "/*");
             context.setMaxFormContentSize(this.config.getMaxFormSize());



Mime
View raw message