You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2015/07/21 09:52:54 UTC

svn commit: r1692059 - in /felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal: HttpServiceController.java dispatch/Dispatcher.java service/HttpServiceFactory.java util/CollectionUtils.java util/UriUtils.java

Author: cziegeler
Date: Tue Jul 21 07:52:53 2015
New Revision: 1692059

URL: http://svn.apache.org/r1692059
Log:
Clean up code, remove unused code

Removed:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/util/CollectionUtils.java
Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/util/UriUtils.java

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=1692059&r1=1692058&r2=1692059&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 Jul 21 07:52:53 2015
@@ -29,7 +29,6 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.handler.HttpSessionWrapper;
 import org.apache.felix.http.base.internal.registry.HandlerRegistry;
 import org.apache.felix.http.base.internal.service.HttpServiceFactory;
-import org.apache.felix.http.base.internal.service.listener.ServletContextAttributeListenerManager;
 import org.apache.felix.http.base.internal.whiteboard.WhiteboardManager;
 import org.osgi.framework.BundleContext;
 
@@ -57,11 +56,6 @@ public final class HttpServiceController
         return this.dispatcher;
     }
 
-    ServletContextAttributeListenerManager getContextAttributeListener()
-    {
-        return this.httpServiceFactory.getContextAttributeListener();
-    }
-
     HttpSessionListener getSessionListener()
     {
         // we don't need to sync here, if the object gets created several times
@@ -85,6 +79,10 @@ public final class HttpServiceController
         return httpSessionListener;
     }
 
+    /**
+     * TODO : we should try to remove this, it's only needed for
+     *        the proprietary support of the Felix implementation
+     */
     HttpSessionAttributeListener getSessionAttributeListener()
     {
         return httpServiceFactory.getSessionAttributeListener();
@@ -107,6 +105,10 @@ public final class HttpServiceController
         this.whiteboardManager.setProperties(props);
     }
 
+    /**
+     * Start the http and http whiteboard service in the provided context.
+     * @param containerContext The container context.
+     */
     public void register(@Nonnull final ServletContext containerContext)
     {
         this.registry.init();
@@ -117,6 +119,9 @@ public final class HttpServiceController
         this.dispatcher.setWhiteboardManager(this.whiteboardManager);
     }
 
+    /**
+     * Stops the http and http whiteboard service.
+     */
     public void unregister()
     {
         this.dispatcher.setWhiteboardManager(null);

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java?rev=1692059&r1=1692058&r2=1692059&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java Tue Jul 21 07:52:53 2015
@@ -18,7 +18,8 @@ package org.apache.felix.http.base.inter
 
 import java.io.IOException;
 import java.util.Set;
-import javax.servlet.DispatcherType;
+
+import javax.annotation.CheckForNull;
 import javax.servlet.FilterChain;
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletException;
@@ -32,27 +33,28 @@ import javax.servlet.http.HttpSession;
 import org.apache.felix.http.base.internal.context.ExtServletContext;
 import org.apache.felix.http.base.internal.handler.FilterHandler;
 import org.apache.felix.http.base.internal.handler.HttpSessionWrapper;
-import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.apache.felix.http.base.internal.registry.HandlerRegistry;
 import org.apache.felix.http.base.internal.registry.PathResolution;
 import org.apache.felix.http.base.internal.registry.PerContextHandlerRegistry;
-import org.apache.felix.http.base.internal.registry.ServletResolution;
-import org.apache.felix.http.base.internal.util.UriUtils;
 import org.apache.felix.http.base.internal.whiteboard.WhiteboardManager;
 
 public final class Dispatcher
 {
     private final HandlerRegistry handlerRegistry;
 
-    private WhiteboardManager whiteboardManager;
+    private volatile WhiteboardManager whiteboardManager;
 
     public Dispatcher(final HandlerRegistry handlerRegistry)
     {
         this.handlerRegistry = handlerRegistry;
     }
 
-    public void setWhiteboardManager(final WhiteboardManager service)
+    /**
+     * Set or unset the whiteboard manager.
+     * @param service The whiteboard manager or {@code null}
+     */
+    public void setWhiteboardManager(@CheckForNull final WhiteboardManager service)
     {
         this.whiteboardManager = service;
     }
@@ -72,7 +74,11 @@ public final class Dispatcher
         if ( session != null )
         {
             final Set<Long> ids = HttpSessionWrapper.getExpiredSessionContextIds(session);
-            this.whiteboardManager.sessionDestroyed(session, ids);
+            final WhiteboardManager mgr = this.whiteboardManager;
+            if ( mgr != null )
+            {
+                this.whiteboardManager.sessionDestroyed(session, ids);
+            }
         }
 
         // get full path
@@ -100,7 +106,6 @@ public final class Dispatcher
             return;
         }
 
-
         final ExtServletContext servletContext = pr.handler.getContext();
         final RequestInfo requestInfo = new RequestInfo(pr.servletPath, pr.pathInfo, null);
 
@@ -115,7 +120,9 @@ public final class Dispatcher
             {
                 servletContext.getServletRequestListener().requestInitialized(new ServletRequestEvent(servletContext, wrappedRequest));
             }
-            invokeChain(pr.handler, filterHandlers, wrappedRequest, wrappedResponse);
+            final FilterChain filterChain = new InvocationChain(pr.handler, filterHandlers);
+            filterChain.doFilter(wrappedRequest, wrappedResponse);
+
         }
         catch ( final Exception e)
         {
@@ -133,40 +140,4 @@ public final class Dispatcher
             }
         }
     }
-
-    /**
-     * @param servletHandler the servlet that should handle the forward request;
-     * @param request the {@link HttpServletRequest};
-     * @param response the {@link HttpServletResponse};
-     */
-    public void forward(final ServletResolution resolution, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-    {
-        final String requestURI = UriUtils.relativePath(request.getContextPath(), request.getRequestURI());
-        final FilterHandler[] filterHandlers = this.handlerRegistry.getFilters(resolution, DispatcherType.FORWARD, requestURI);
-
-        invokeChain(resolution.handler, filterHandlers, request, response);
-    }
-
-    /**
-     * @param servletHandler the servlet that should handle the include request;
-     * @param request the {@link HttpServletRequest};
-     * @param response the {@link HttpServletResponse};
-     */
-    public void include(final ServletResolution resolution, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
-    {
-        final String requestURI = UriUtils.relativePath(request.getContextPath(), request.getRequestURI());
-        final FilterHandler[] filterHandlers = this.handlerRegistry.getFilters(resolution, DispatcherType.INCLUDE, requestURI);
-
-        invokeChain(resolution.handler, filterHandlers, request, response);
-    }
-
-    private void invokeChain(final ServletHandler servletHandler,
-            final FilterHandler[] filterHandlers,
-            final HttpServletRequest request,
-            final HttpServletResponse response)
-    throws IOException, ServletException
-    {
-        final FilterChain filterChain = new InvocationChain(servletHandler, filterHandlers);
-        filterChain.doFilter(request, response);
-    }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java?rev=1692059&r1=1692058&r2=1692059&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java Tue Jul 21 07:52:53 2015
@@ -65,7 +65,7 @@ public final class HttpServiceFactory
      */
     private static final String FELIX_HTTP_SHARED_SERVLET_CONTEXT_ATTRIBUTES = "org.apache.felix.http.shared_servlet_context_attributes";
 
-    /** Compatiblity property for previous versions. */
+    /** Compatibility property with previous versions. */
     private static final String OBSOLETE_REG_PROPERTY_ENDPOINTS = "osgi.http.service.endpoints";
 
     private final BundleContext bundleContext;

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/util/UriUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/util/UriUtils.java?rev=1692059&r1=1692058&r2=1692059&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/util/UriUtils.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/util/UriUtils.java Tue Jul 21 07:52:53 2015
@@ -421,109 +421,6 @@ public abstract class UriUtils
         return value == null || "".equals(value.trim());
     }
 
-    public static String statusToString(final int statusCode)
-    {
-        switch (statusCode)
-        {
-            case 100:
-                return "Continue";
-            case 101:
-                return "Switching Protocols";
-            case 102:
-                return "Processing (WebDAV)";
-            case 200:
-                return "OK";
-            case 201:
-                return "Created";
-            case 202:
-                return "Accepted";
-            case 203:
-                return "Non-Authoritative Information";
-            case 204:
-                return "No Content";
-            case 205:
-                return "Reset Content";
-            case 206:
-                return "Partial Content";
-            case 207:
-                return "Multi-Status (WebDAV)";
-            case 300:
-                return "Multiple Choices";
-            case 301:
-                return "Moved Permanently";
-            case 302:
-                return "Found";
-            case 303:
-                return "See Other";
-            case 304:
-                return "Not Modified";
-            case 305:
-                return "Use Proxy";
-            case 307:
-                return "Temporary Redirect";
-            case 400:
-                return "Bad Request";
-            case 401:
-                return "Unauthorized";
-            case 402:
-                return "Payment Required";
-            case 403:
-                return "Forbidden";
-            case 404:
-                return "Not Found";
-            case 405:
-                return "Method Not Allowed";
-            case 406:
-                return "Not Acceptable";
-            case 407:
-                return "Proxy Authentication Required";
-            case 408:
-                return "Request Time-out";
-            case 409:
-                return "Conflict";
-            case 410:
-                return "Gone";
-            case 411:
-                return "Length Required";
-            case 412:
-                return "Precondition Failed";
-            case 413:
-                return "Request Entity Too Large";
-            case 414:
-                return "Request-URI Too Large";
-            case 415:
-                return "Unsupported Media Type";
-            case 416:
-                return "Requested range not satisfiable";
-            case 417:
-                return "Expectation Failed";
-            case 422:
-                return "Unprocessable Entity (WebDAV)";
-            case 423:
-                return "Locked (WebDAV)";
-            case 424:
-                return "Failed Dependency (WebDAV)";
-            case 500:
-                return "Internal Server Error";
-            case 501:
-                return "Not Implemented";
-            case 502:
-                return "Bad Gateway";
-            case 503:
-                return "Service Unavailable";
-            case 504:
-                return "Gateway Time-out";
-            case 505:
-                return "HTTP Version not supported";
-            case 507:
-                return "Insufficient Storage (WebDAV)";
-            case 510:
-                return "Not Extended";
-            default:
-                return String.valueOf(statusCode);
-        }
-    }
-
     /**
      * Creates a new {@link UriUtils} instance.
      */