felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1679975 [1/2] - in /felix/trunk/http/base/src: main/java/org/apache/felix/http/base/internal/dispatch/ main/java/org/apache/felix/http/base/internal/handler/ main/java/org/apache/felix/http/base/internal/handler/holder/ main/java/org/apach...
Date Mon, 18 May 2015 09:46:25 GMT
Author: cziegeler
Date: Mon May 18 09:46:24 2015
New Revision: 1679975

URL: http://svn.apache.org/r1679975
Log:
FELIX-4888 : ServletHandler's are not sorted by longest matching path. Finish error page registry. Start DTO handling (WiP)

Added:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceFilterHandler.java
      - copied, changed from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceFilterHolder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceServletHandler.java
      - copied, changed from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceServletHolder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardFilterHandler.java
      - copied, changed from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/WhiteboardFilterHolder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistration.java
      - copied, changed from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletHandler.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/HttpServiceServletHandlerTest.java
      - copied, changed from r1679892, felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/SimpleServletHandlerTest.java
Removed:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/AbstractHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HandlerMapping.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HandlerRankingMultimap.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ResourceServletHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandlerRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/SimpleServletHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletHandler.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/AbstractHandlerTest.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/HandlerRankingMultimapTest.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/SimpleServletHandlerTest.java
Modified:
    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/dispatch/InvocationChain.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HandlerRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardServletHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerMapping.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletResolution.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RequestInfoDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/PerBundleHttpServiceImpl.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/SharedHttpServiceImpl.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardHttpService.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/registry/ServletRegistryTest.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceHelper.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java

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=1679975&r1=1679974&r2=1679975&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 Mon May 18 09:46:24 2015
@@ -51,10 +51,10 @@ import javax.servlet.http.HttpServletRes
 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.HandlerRegistry;
 import org.apache.felix.http.base.internal.handler.HttpSessionWrapper;
-import org.apache.felix.http.base.internal.handler.holder.FilterHolder;
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.registry.PathResolution;
 import org.apache.felix.http.base.internal.registry.ServletResolution;
 import org.apache.felix.http.base.internal.util.UriUtils;
@@ -138,14 +138,14 @@ public final class Dispatcher implements
         private final String servletName;
 
         public ServletResponseWrapper(final HttpServletRequest req, final HttpServletResponse res,
-                final ServletHolder servletHolder)
+                final ServletHandler servletHandler)
         {
             super(res);
             this.request = req;
-            if ( servletHolder != null )
+            if ( servletHandler != null )
             {
-                this.serviceId = servletHolder.getContextServiceId();
-                this.servletName = servletHolder.getName();
+                this.serviceId = servletHandler.getContextServiceId();
+                this.servletName = servletHandler.getName();
             }
             else
             {
@@ -201,10 +201,10 @@ public final class Dispatcher implements
 
                             final RequestInfo requestInfo = new RequestInfo(servletPath, pathInfo, queryString);
 
-                            final FilterHolder[] filterHolders = handlerRegistry.getFilters(errorResolution, DispatcherType.ERROR, request.getRequestURI());
+                            final FilterHandler[] filterHandlers = handlerRegistry.getFilters(errorResolution, DispatcherType.ERROR, request.getRequestURI());
 
                             // TODO - is async = false correct?
-                            invokeChain(errorResolution.holder, filterHolders, new ServletRequestWrapper(request, errorResolution.holder.getContext(), requestInfo, this.serviceId, false), this);
+                            invokeChain(errorResolution.holder, filterHandlers, new ServletRequestWrapper(request, errorResolution.holder.getContext(), requestInfo, this.serviceId, false), this);
 
                             invokeSuper = false;
                         }
@@ -607,7 +607,7 @@ public final class Dispatcher implements
         final HttpServletRequest wrappedRequest = new ServletRequestWrapper(req, servletContext, requestInfo,
                 pr.holder.getContextServiceId(),
                 pr.holder.getServletInfo().isAsyncSupported());
-        final FilterHolder[] filterHolders = this.handlerRegistry.getFilters(pr, req.getDispatcherType(), pr.requestURI);
+        final FilterHandler[] filterHandlers = this.handlerRegistry.getFilters(pr, req.getDispatcherType(), pr.requestURI);
 
         try
         {
@@ -615,7 +615,7 @@ public final class Dispatcher implements
             {
                 servletContext.getServletRequestListener().requestInitialized(new ServletRequestEvent(servletContext, wrappedRequest));
             }
-            invokeChain(pr.holder, filterHolders, wrappedRequest, wrappedResponse);
+            invokeChain(pr.holder, filterHandlers, wrappedRequest, wrappedResponse);
         }
         catch ( final Exception e)
         {
@@ -681,9 +681,9 @@ public final class Dispatcher implements
     void forward(final ServletResolution resolution, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
     {
         String requestURI = getRequestURI(request);
-        FilterHolder[] filterHolders = this.handlerRegistry.getFilters(resolution, DispatcherType.FORWARD, requestURI);
+        FilterHandler[] filterHandlers = this.handlerRegistry.getFilters(resolution, DispatcherType.FORWARD, requestURI);
 
-        invokeChain(resolution.holder, filterHolders, request, response);
+        invokeChain(resolution.holder, filterHandlers, request, response);
     }
 
     /**
@@ -694,9 +694,9 @@ public final class Dispatcher implements
     void include(final ServletResolution resolution, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
     {
         String requestURI = getRequestURI(request);
-        FilterHolder[] filterHolders = this.handlerRegistry.getFilters(resolution, DispatcherType.INCLUDE, requestURI);
+        FilterHandler[] filterHandlers = this.handlerRegistry.getFilters(resolution, DispatcherType.INCLUDE, requestURI);
 
-        invokeChain(resolution.holder, filterHolders, request, response);
+        invokeChain(resolution.holder, filterHandlers, request, response);
     }
 
     private String getRequestURI(HttpServletRequest req)
@@ -704,13 +704,13 @@ public final class Dispatcher implements
         return UriUtils.relativePath(req.getContextPath(), req.getRequestURI());
     }
 
-    private void invokeChain(final ServletHolder servletHolder,
-            final FilterHolder[] filterHolders,
+    private void invokeChain(final ServletHandler servletHandler,
+            final FilterHandler[] filterHandlers,
             final HttpServletRequest request,
             final HttpServletResponse response)
     throws IOException, ServletException
     {
-        final FilterChain filterChain = new InvocationChain(servletHolder, filterHolders);
+        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/dispatch/InvocationChain.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/InvocationChain.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/InvocationChain.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/InvocationChain.java Mon May 18 09:46:24 2015
@@ -29,20 +29,20 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.felix.http.base.internal.handler.holder.FilterHolder;
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.FilterHandler;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 
 public class InvocationChain implements FilterChain
 {
-    private final ServletHolder servletHolder;
-    private final FilterHolder[] filterHolders;
+    private final ServletHandler servletHandler;
+    private final FilterHandler[] filterHandlers;
 
     private int index = -1;
 
-    public InvocationChain(@Nonnull final ServletHolder servletHolder, @Nonnull final FilterHolder[] filterHolders)
+    public InvocationChain(@Nonnull final ServletHandler servletHandler, @Nonnull final FilterHandler[] filterHandlers)
     {
-        this.filterHolders = filterHolders;
-        this.servletHolder = servletHolder;
+        this.filterHandlers = filterHandlers;
+        this.servletHandler = servletHandler;
     }
 
     @Override
@@ -54,7 +54,7 @@ public class InvocationChain implements
             final HttpServletResponse hRes = (HttpServletResponse) res;
 
             // invoke security
-            if ( !servletHolder.getContext().handleSecurity(hReq, hRes))
+            if ( !servletHandler.getContext().handleSecurity(hReq, hRes))
             {
                 // FELIX-3988: If the response is not yet committed and still has the default
                 // status, we're going to override this and send an error instead.
@@ -69,14 +69,14 @@ public class InvocationChain implements
         }
         this.index++;
 
-        if (this.index < this.filterHolders.length)
+        if (this.index < this.filterHandlers.length)
         {
-            this.filterHolders[this.index].handle(req, res, this);
+            this.filterHandlers[this.index].handle(req, res, this);
         }
         else
         {
             // Last entry in the chain...
-            this.servletHolder.handle(req, res);
+            this.servletHandler.handle(req, res);
         }
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java Mon May 18 09:46:24 2015
@@ -21,6 +21,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.regex.Pattern;
 
+import javax.annotation.Nonnull;
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.ServletException;
@@ -28,23 +29,35 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
 import org.apache.felix.http.base.internal.context.ExtServletContext;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
-import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
 import org.apache.felix.http.base.internal.runtime.dto.FilterRuntime;
 import org.apache.felix.http.base.internal.util.PatternUtil;
+import org.osgi.service.http.runtime.dto.DTOConstants;
 
-public final class FilterHandler extends AbstractHandler<FilterHandler> implements FilterRuntime
+/**
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class FilterHandler implements Comparable<FilterHandler>, FilterRuntime
 {
-    private final Filter filter;
+    private final long contextServiceId;
+
     private final FilterInfo filterInfo;
-    private final Pattern[] patterns;
 
-    private final long contextServiceId;
+    private final ExtServletContext context;
+
+    private volatile Filter filter;
 
-    public FilterHandler(final ServletContextHelperInfo contextInfo, ExtServletContext context, Filter filter, FilterInfo filterInfo)
+    protected volatile int useCount;
+
+    private final Pattern[] patterns;
+
+    public FilterHandler(final long contextServiceId,
+            final ExtServletContext context,
+            final FilterInfo filterInfo)
     {
-        super(context, filterInfo.getInitParameters(), filterInfo.getName());
-        this.filter = filter;
+        this.contextServiceId = contextServiceId;
+        this.context = context;
         this.filterInfo = filterInfo;
         // Compose a single array of all patterns & regexs the filter must represent...
         String[] patterns = getFilterPatterns(filterInfo);
@@ -54,31 +67,57 @@ public final class FilterHandler extends
         {
             this.patterns[i] = Pattern.compile(patterns[i]);
         }
-        if ( contextInfo != null )
+    }
+
+    private static String[] getFilterPatterns(FilterInfo filterInfo)
+    {
+        List<String> result = new ArrayList<String>();
+        if (filterInfo.getPatterns() != null)
         {
-            this.contextServiceId = contextInfo.getServiceId();
+            for (int i = 0; i < filterInfo.getPatterns().length; i++)
+            {
+                result.add(PatternUtil.convertToRegEx(filterInfo.getPatterns()[i]));
+            }
         }
-        else
+        if (filterInfo.getRegexs() != null)
         {
-            this.contextServiceId = 0;
+            for (int i = 0; i < filterInfo.getRegexs().length; i++)
+            {
+                result.add(filterInfo.getRegexs()[i]);
+            }
         }
+        return result.toArray(new String[result.size()]);
+    }
+
+    public Pattern[] getPatterns() {
+        return this.patterns;
     }
 
     @Override
-    public int compareTo(FilterHandler other)
+    public int compareTo(final FilterHandler other)
     {
         return this.filterInfo.compareTo(other.filterInfo);
     }
 
     @Override
-    public void destroy()
+    public long getContextServiceId()
+    {
+        return this.contextServiceId;
+    }
+
+    public ExtServletContext getContext()
     {
-        this.filter.destroy();
+        return this.context;
     }
 
     public Filter getFilter()
     {
-        return this.filter;
+        return filter;
+    }
+
+    protected void setFilter(final Filter f)
+    {
+        this.filter = f;
     }
 
     @Override
@@ -87,62 +126,87 @@ public final class FilterHandler extends
         return this.filterInfo;
     }
 
-    public int getRanking()
+    public String getName()
     {
-        return filterInfo.getRanking();
+        String name = this.filterInfo.getName();
+        if (name == null)
+        {
+            name = filter.getClass().getName();
+        }
+        return name;
     }
 
-    public void handle(ServletRequest req, ServletResponse res, FilterChain chain) throws ServletException, IOException
+    /**
+     * Initialize the object
+     * @return {code -1} on success, a failure reason according to {@link DTOConstants} otherwise.
+     */
+    public int init()
     {
-        this.filter.doFilter(req, res, chain);
-    }
+        if ( this.useCount > 0 )
+        {
+            this.useCount++;
+            return -1;
+        }
 
-    @Override
-    public void init() throws ServletException
-    {
-        this.filter.init(new FilterConfigImpl(getName(), getContext(), getInitParams()));
+        if (this.filter == null)
+        {
+            return DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE;
+        }
+
+        try
+        {
+            filter.init(new FilterConfigImpl(getName(), getContext(), getFilterInfo().getInitParameters()));
+        }
+        catch (final ServletException e)
+        {
+            SystemLogger.error(this.getFilterInfo().getServiceReference(),
+                    "Error during calling init() on filter " + this.filter,
+                    e);
+            return DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT;
+        }
+        this.useCount++;
+        return -1;
     }
 
-    @Override
-    protected Object getSubject()
+    public void handle(@Nonnull final ServletRequest req,
+            @Nonnull final ServletResponse res,
+            @Nonnull final FilterChain chain) throws ServletException, IOException
     {
-        return this.filter;
+        this.filter.doFilter(req, res, chain);
     }
 
-    private static String[] getFilterPatterns(FilterInfo filterInfo)
+    public boolean destroy()
     {
-        List<String> result = new ArrayList<String>();
-        if (filterInfo.getPatterns() != null)
+        if (this.filter == null)
         {
-            for (int i = 0; i < filterInfo.getPatterns().length; i++)
-            {
-                result.add(PatternUtil.convertToRegEx(filterInfo.getPatterns()[i]));
-            }
+            return false;
         }
-        if (filterInfo.getRegexs() != null)
+
+        this.useCount--;
+        if ( this.useCount == 0 )
         {
-            for (int i = 0; i < filterInfo.getRegexs().length; i++)
+            try
             {
-                result.add(filterInfo.getRegexs()[i]);
+                filter.destroy();
+            }
+            catch ( final Exception ignore )
+            {
+                // we ignore this
+                SystemLogger.error(this.getFilterInfo().getServiceReference(),
+                        "Error during calling destroy() on filter " + this.filter,
+                        ignore);
             }
-        }
-        return result.toArray(new String[result.size()]);
-    }
-
-    @Override
-    public Pattern[] getPatterns() {
-        return this.patterns;
-    }
 
-    @Override
-    public long getContextServiceId()
-    {
-        return this.contextServiceId;
+            filter = null;
+            return true;
+        }
+        return false;
     }
 
-    @Override
-    protected long getServiceId()
+    public boolean dispose()
     {
-        return this.filterInfo.getServiceId();
+        // fully destroy the filter
+        this.useCount = 1;
+        return this.destroy();
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HandlerRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HandlerRegistry.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HandlerRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HandlerRegistry.java Mon May 18 09:46:24 2015
@@ -24,8 +24,6 @@ import java.util.List;
 import javax.annotation.Nonnull;
 import javax.servlet.DispatcherType;
 
-import org.apache.felix.http.base.internal.handler.holder.FilterHolder;
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
 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;
@@ -44,20 +42,17 @@ import org.apache.felix.http.base.intern
  */
 public final class HandlerRegistry
 {
-    private static FilterHolder[] EMPTY_FILTER_HOLDER = new FilterHolder[0];
+    private static FilterHandler[] EMPTY_FILTER_HOLDER = new FilterHandler[0];
 
     /** Current list of context registrations. */
     private volatile List<PerContextHandlerRegistry> registrations = Collections.emptyList();
 
-    private final ServletHandlerRegistry servletRegistry = new ServletHandlerRegistry();
-
     /**
      * Register default context registry for Http Service
      */
     public void init()
     {
         this.add(new PerContextHandlerRegistry());
-        servletRegistry.init();
     }
 
     /**
@@ -74,7 +69,6 @@ public final class HandlerRegistry
 
         }
 
-        servletRegistry.shutdown();
         for(final PerContextHandlerRegistry r : list)
         {
             r.removeAll();
@@ -90,7 +84,6 @@ public final class HandlerRegistry
         synchronized ( this )
         {
             this.add(new PerContextHandlerRegistry(info));
-            this.servletRegistry.add(info);
         }
     }
 
@@ -102,7 +95,6 @@ public final class HandlerRegistry
     {
         synchronized ( this )
         {
-            this.servletRegistry.remove(info);
             final List<PerContextHandlerRegistry> updatedList = new ArrayList<PerContextHandlerRegistry>(this.registrations);
             final Iterator<PerContextHandlerRegistry> i = updatedList.iterator();
             while ( i.hasNext() )
@@ -134,7 +126,7 @@ public final class HandlerRegistry
         }
     }
 
-    public void addFilter(@Nonnull final FilterHolder holder)
+    public void addFilter(@Nonnull final FilterHandler holder)
     {
         final PerContextHandlerRegistry reg = this.getRegistry(holder.getContextServiceId());
         // TODO - check whether we need to handle the null case as well
@@ -194,7 +186,7 @@ public final class HandlerRegistry
         }
         if ( reg != null )
         {
-            final ServletHolder holder = reg.getErrorHandler(code, exception);
+            final ServletHandler holder = reg.getErrorHandler(code, exception);
             if ( holder != null )
             {
                 final ServletResolution res = new ServletResolution();
@@ -207,18 +199,18 @@ public final class HandlerRegistry
         return null;
     }
 
-    public FilterHolder[] getFilters(@Nonnull final ServletResolution pr,
+    public FilterHandler[] getFilters(@Nonnull final ServletResolution pr,
             final DispatcherType dispatcherType,
             @Nonnull String requestURI)
     {
         if ( pr != null && pr.handlerRegistry != null )
         {
-            return pr.handlerRegistry.getFilterHolders(pr.holder, dispatcherType, requestURI);
+            return pr.handlerRegistry.getFilterHandlers(pr.holder, dispatcherType, requestURI);
         }
         return EMPTY_FILTER_HOLDER;
     }
 
-    public void addServlet(final ServletHolder holder)
+    public void addServlet(final ServletHandler holder)
     {
         final PerContextHandlerRegistry reg = this.getRegistry(holder.getContextServiceId());
         // TODO - check whether we need to handle the null case as well
@@ -274,7 +266,7 @@ public final class HandlerRegistry
         final PerContextHandlerRegistry reg = (contextId == null ? null : this.getRegistry(contextId));
         if ( reg != null )
         {
-            final ServletHolder holder = reg.resolveServletByName(name);
+            final ServletHandler holder = reg.resolveServletByName(name);
             if ( holder != null )
             {
                 final ServletResolution resolution = new ServletResolution();

Copied: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceFilterHandler.java (from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceFilterHolder.java)
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceFilterHandler.java?p2=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceFilterHandler.java&p1=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceFilterHolder.java&r1=1679892&r2=1679975&rev=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceFilterHolder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceFilterHandler.java Mon May 18 09:46:24 2015
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.http.base.internal.handler.holder;
+package org.apache.felix.http.base.internal.handler;
 
 import javax.servlet.Filter;
 
@@ -24,9 +24,9 @@ import org.apache.felix.http.base.intern
 /**
  * Servlet holder for filters registered through the ext http service.
  */
-public final class HttpServiceFilterHolder extends FilterHolder
+public final class HttpServiceFilterHandler extends FilterHandler
 {
-    public HttpServiceFilterHolder(final long contextServiceId,
+    public HttpServiceFilterHandler(final long contextServiceId,
             final ExtServletContext context,
             final FilterInfo filterInfo,
             final Filter filter)

Copied: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceServletHandler.java (from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceServletHolder.java)
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceServletHandler.java?p2=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceServletHandler.java&p1=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceServletHolder.java&r1=1679892&r2=1679975&rev=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/HttpServiceServletHolder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/HttpServiceServletHandler.java Mon May 18 09:46:24 2015
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.http.base.internal.handler.holder;
+package org.apache.felix.http.base.internal.handler;
 
 import javax.servlet.Servlet;
 
@@ -22,11 +22,11 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 
 /**
- * Servlet holder for servlets registered through the http service.
+ * Servlet handler for servlets registered through the http service.
  */
-public final class HttpServiceServletHolder extends ServletHolder
+public final class HttpServiceServletHandler extends ServletHandler
 {
-    public HttpServiceServletHolder(final long contextServiceId,
+    public HttpServiceServletHandler(final long contextServiceId,
             final ExtServletContext context,
             final ServletInfo servletInfo,
             final Servlet servlet)

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java Mon May 18 09:46:24 2015
@@ -17,47 +17,40 @@
 package org.apache.felix.http.base.internal.handler;
 
 import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
+import javax.servlet.Servlet;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
 import org.apache.felix.http.base.internal.context.ExtServletContext;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.apache.felix.http.base.internal.runtime.dto.ServletRuntime;
-import org.apache.felix.http.base.internal.util.PatternUtil;
+import org.osgi.service.http.runtime.dto.DTOConstants;
 
 /**
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public abstract class ServletHandler extends AbstractHandler<ServletHandler> implements ServletRuntime
+public abstract class ServletHandler implements Comparable<ServletHandler>, ServletRuntime
 {
-    private final ServletInfo servletInfo;
-    private final Pattern[] patterns;
     private final long contextServiceId;
 
-    public ServletHandler(final long contextServiceId,
-            final ExtServletContext context,
-            final ServletInfo servletInfo)
-    {
-        super(context, servletInfo.getInitParameters(), servletInfo.getName());
+    private final ServletInfo servletInfo;
 
-        this.servletInfo = servletInfo;
+    private final ExtServletContext context;
 
-        // Can be null in case of error-handling servlets...
-        String[] patterns = this.servletInfo.getPatterns();
-        final int length = patterns == null ? 0 : patterns.length;
+    private volatile Servlet servlet;
 
-        this.patterns = new Pattern[length];
-        for (int i = 0; i < length; i++)
-        {
-            final String pattern = patterns[i];
-            this.patterns[i] = Pattern.compile(PatternUtil.convertToRegEx(pattern));
-        }
+    protected volatile int useCount;
 
+    public ServletHandler(final long contextServiceId,
+            final ExtServletContext context,
+            final ServletInfo servletInfo)
+    {
         this.contextServiceId = contextServiceId;
+        this.context = context;
+        this.servletInfo = servletInfo;
     }
 
     @Override
@@ -66,35 +59,32 @@ public abstract class ServletHandler ext
         return this.servletInfo.compareTo(other.servletInfo);
     }
 
-    public void handle(ServletRequest req, ServletResponse res) throws ServletException, IOException
+    @Override
+    public long getContextServiceId()
     {
-        getServlet().service(req, res);
+        return this.contextServiceId;
     }
 
-    public String determineServletPath(String uri)
+    public ExtServletContext getContext()
     {
-        if (uri == null)
-        {
-            uri = "/";
-        }
+        return this.context;
+    }
 
-        // Patterns are sorted on length in descending order, so we should get the longest match first...
-        for (int i = 0; i < this.patterns.length; i++)
-        {
-            Matcher matcher = this.patterns[i].matcher(uri);
-            if (matcher.find(0))
-            {
-                return matcher.groupCount() > 0 ? matcher.group(1) : matcher.group();
-            }
-        }
+    @Override
+    public Servlet getServlet()
+    {
+        return servlet;
+    }
 
-        return null;
+    protected void setServlet(final Servlet s)
+    {
+        this.servlet = s;
     }
 
-    @Override
-    public Pattern[] getPatterns()
+    public void handle(final ServletRequest req, final ServletResponse res)
+            throws ServletException, IOException
     {
-        return this.patterns;
+        this.servlet.service(req, res);
     }
 
     @Override
@@ -103,31 +93,81 @@ public abstract class ServletHandler ext
         return this.servletInfo;
     }
 
-    @Override
-    public long getContextServiceId()
+    public String getName()
     {
-        return this.contextServiceId;
+        String name = this.servletInfo.getName();
+        if (name == null)
+        {
+            name = servlet.getClass().getName();
+        }
+        return name;
     }
 
-    @Override
-    protected long getServiceId()
+    /**
+     * Initialize the object
+     * @return {code -1} on success, a failure reason according to {@link DTOConstants} otherwise.
+     */
+    public int init()
     {
-        return this.servletInfo.getServiceId();
-    }
+        if ( this.useCount > 0 )
+        {
+            this.useCount++;
+            return -1;
+        }
 
-    @Override
-    protected Object getSubject()
-    {
-        return getServlet();
+        if (this.servlet == null)
+        {
+            return DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE;
+        }
+
+        try
+        {
+            servlet.init(new ServletConfigImpl(getName(), getContext(), getServletInfo().getInitParameters()));
+        }
+        catch (final ServletException e)
+        {
+            SystemLogger.error(this.getServletInfo().getServiceReference(),
+                    "Error during calling init() on servlet " + this.servlet,
+                    e);
+            return DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT;
+        }
+        this.useCount++;
+        return -1;
     }
 
-    protected static ServletInfo checkIsResource(ServletInfo servletInfo, boolean checkTrue)
+
+    public boolean destroy()
     {
-        if (checkTrue != servletInfo.isResource())
+        if (this.servlet == null)
         {
-            String message = "ServletInfo must " + (checkTrue ? "" : "not") + " represent a resource";
-            throw new IllegalArgumentException(message);
+            return false;
+        }
+
+        this.useCount--;
+        if ( this.useCount == 0 )
+        {
+            try
+            {
+                servlet.destroy();
+            }
+            catch ( final Exception ignore )
+            {
+                // we ignore this
+                SystemLogger.error(this.getServletInfo().getServiceReference(),
+                        "Error during calling destroy() on servlet " + this.servlet,
+                        ignore);
+            }
+
+            servlet = null;
+            return true;
         }
-        return servletInfo;
+        return false;
+    }
+
+    public boolean dispose()
+    {
+        // fully destroy the servlet
+        this.useCount = 1;
+        return this.destroy();
     }
 }

Copied: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardFilterHandler.java (from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/WhiteboardFilterHolder.java)
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardFilterHandler.java?p2=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardFilterHandler.java&p1=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/WhiteboardFilterHolder.java&r1=1679892&r2=1679975&rev=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/holder/WhiteboardFilterHolder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardFilterHandler.java Mon May 18 09:46:24 2015
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.felix.http.base.internal.handler.holder;
+package org.apache.felix.http.base.internal.handler;
 
 import javax.servlet.Filter;
 
@@ -27,11 +27,11 @@ import org.osgi.framework.ServiceReferen
 /**
  * Filter holder for filters registered through the http whiteboard.
  */
-public final class WhiteboardFilterHolder extends FilterHolder
+public final class WhiteboardFilterHandler extends FilterHandler
 {
     private final BundleContext bundleContext;
 
-    public WhiteboardFilterHolder(final long contextServiceId,
+    public WhiteboardFilterHandler(final long contextServiceId,
             final ExtServletContext context,
             final FilterInfo filterInfo,
             final BundleContext bundleContext)

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardServletHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardServletHandler.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardServletHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/WhiteboardServletHandler.java Mon May 18 09:46:24 2015
@@ -17,85 +17,69 @@
 package org.apache.felix.http.base.internal.handler;
 
 import javax.servlet.Servlet;
-import javax.servlet.ServletException;
 
 import org.apache.felix.http.base.internal.context.ExtServletContext;
-import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceObjects;
 import org.osgi.framework.ServiceReference;
 
+/**
+ * Servlet handler for servlets registered through the http whiteboard.
+ */
 public final class WhiteboardServletHandler extends ServletHandler
 {
     private final BundleContext bundleContext;
 
-    private Servlet servlet;
-
-    public WhiteboardServletHandler(ServletContextHelperInfo contextInfo,
-            ExtServletContext context,
-            ServletInfo servletInfo,
-            BundleContext bundleContext)
+    public WhiteboardServletHandler(final long contextServiceId,
+            final ExtServletContext context,
+            final ServletInfo servletInfo,
+            final BundleContext bundleContext)
     {
-        super(contextInfo.getServiceId(), context, checkIsResource(servletInfo, false));
+        super(contextServiceId, context, servletInfo);
         this.bundleContext = bundleContext;
     }
 
     @Override
-    public Servlet getServlet()
-    {
-        return servlet;
-    }
-
-    @Override
-    protected Object getSubject()
-    {
-        return getServlet();
-    }
-
-    @Override
-    public void init() throws ServletException
+    public int init()
     {
-        if (servlet != null)
+        if ( this.useCount > 0 )
         {
-            return;
+            this.useCount++;
+            return -1;
         }
 
-        ServiceReference<Servlet> serviceReference = getServletInfo().getServiceReference();
-        ServiceObjects<Servlet> so = this.bundleContext.getServiceObjects(serviceReference);
+        final ServiceReference<Servlet> serviceReference = getServletInfo().getServiceReference();
+        final ServiceObjects<Servlet> so = this.bundleContext.getServiceObjects(serviceReference);
 
-        servlet = so.getService();
+        this.setServlet((so == null ? null : so.getService()));
 
-        if (servlet == null)
+        final int reason = super.init();
+        if ( reason != -1 )
         {
-            // TODO throw Exception - service ungettable ?
-            return;
-        }
-
-        try {
-            servlet.init(new ServletConfigImpl(getName(), getContext(), getInitParams()));
-        } catch (ServletException e) {
-            so.ungetService(servlet);
-            throw e;
+            so.ungetService(this.getServlet());
+            this.setServlet(null);
         }
+        return reason;
     }
 
     @Override
-    public void destroy()
+    public boolean destroy()
     {
-        if (servlet == null)
+        final Servlet s = this.getServlet();
+        if ( s != null )
         {
-            return;
-        }
-
-        servlet.destroy();
+            if ( super.destroy() )
+            {
 
-        ServiceObjects<Servlet> so = this.bundleContext.getServiceObjects(getServletInfo().getServiceReference());
-        // TODO check if this is needed
-        if (so != null)
-        {
-            so.ungetService(servlet);
+                final ServiceObjects<Servlet> so = this.bundleContext.getServiceObjects(getServletInfo().getServiceReference());
+                if (so != null)
+                {
+                    so.ungetService(s);
+                }
+                return true;
+            }
         }
-        servlet = null;
+        return false;
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java Mon May 18 09:46:24 2015
@@ -30,7 +30,7 @@ import java.util.regex.Pattern;
 
 import javax.annotation.Nonnull;
 
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.apache.felix.http.base.internal.runtime.dto.ErrorPageRuntime;
 import org.apache.felix.http.base.internal.runtime.dto.ServletRuntime;
@@ -76,8 +76,8 @@ public final class ErrorPageRegistry
         return null;
     }
 
-    private final Map<Long, List<ServletHolder>> errorCodesMap = new ConcurrentHashMap<Long, List<ServletHolder>>();
-    private final Map<String, List<ServletHolder>> exceptionsMap = new ConcurrentHashMap<String, List<ServletHolder>>();
+    private final Map<Long, List<ServletHandler>> errorCodesMap = new ConcurrentHashMap<Long, List<ServletHandler>>();
+    private final Map<String, List<ServletHandler>> exceptionsMap = new ConcurrentHashMap<String, List<ServletHandler>>();
 
     private final Map<ServletInfo, ErrorRegistrationStatus> statusMapping = new ConcurrentHashMap<ServletInfo, ErrorRegistrationStatus>();
 
@@ -87,7 +87,7 @@ public final class ErrorPageRegistry
     }
 
     private static final class ErrorRegistrationStatus {
-        ServletHolder holder;
+        ServletHandler holder;
         final Map<Long, Integer> errorCodeMapping = new ConcurrentHashMap<Long, Integer>();
         final Map<String, Integer> exceptionMapping = new ConcurrentHashMap<String, Integer>();
     }
@@ -114,7 +114,7 @@ public final class ErrorPageRegistry
      * Add the servlet for error handling
      * @param holder The servlet holder.
      */
-    public void addServlet(@Nonnull final ServletHolder holder)
+    public void addServlet(@Nonnull final ServletHandler holder)
     {
         final ErrorRegistration reg = getErrorRegistration(holder.getServletInfo());
         if ( reg != null )
@@ -123,20 +123,20 @@ public final class ErrorPageRegistry
             status.holder = holder;
             for(final long code : reg.errorCodes)
             {
-                List<ServletHolder> list = errorCodesMap.get(code);
+                List<ServletHandler> list = errorCodesMap.get(code);
                 if ( list == null )
                 {
                     // activate
                     if ( tryToActivate(code, holder, status) )
                     {
-                        final List<ServletHolder> newList = new ArrayList<ServletHolder>(1);
+                        final List<ServletHandler> newList = new ArrayList<ServletHandler>(1);
                         newList.add(holder);
                         errorCodesMap.put(code, newList);
                     }
                 }
                 else
                 {
-                    final List<ServletHolder> newList = new ArrayList<ServletHolder>(list);
+                    final List<ServletHandler> newList = new ArrayList<ServletHandler>(list);
                     newList.add(holder);
                     Collections.sort(newList);
 
@@ -145,7 +145,7 @@ public final class ErrorPageRegistry
                         // activate and reactive
                         if ( tryToActivate(code, holder, status) )
                         {
-                            final ServletHolder old = list.get(0);
+                            final ServletHandler old = list.get(0);
                             old.destroy();
                             errorCodesMap.put(code, newList);
                         }
@@ -160,20 +160,20 @@ public final class ErrorPageRegistry
             }
             for(final String exception : reg.exceptions)
             {
-                List<ServletHolder> list = exceptionsMap.get(exception);
+                List<ServletHandler> list = exceptionsMap.get(exception);
                 if ( list == null )
                 {
                     // activate
                     if ( tryToActivate(exception, holder, status) )
                     {
-                        final List<ServletHolder> newList = new ArrayList<ServletHolder>(1);
+                        final List<ServletHandler> newList = new ArrayList<ServletHandler>(1);
                         newList.add(holder);
                         exceptionsMap.put(exception, newList);
                     }
                 }
                 else
                 {
-                    final List<ServletHolder> newList = new ArrayList<ServletHolder>(list);
+                    final List<ServletHandler> newList = new ArrayList<ServletHandler>(list);
                     newList.add(holder);
                     Collections.sort(newList);
 
@@ -182,7 +182,7 @@ public final class ErrorPageRegistry
                         // activate and reactive
                         if ( tryToActivate(exception, holder, status) )
                         {
-                            final ServletHolder old = list.get(0);
+                            final ServletHandler old = list.get(0);
                             old.destroy();
                             exceptionsMap.put(exception, newList);
                         }
@@ -211,19 +211,19 @@ public final class ErrorPageRegistry
             this.statusMapping.remove(info);
             for(final long code : reg.errorCodes)
             {
-                final List<ServletHolder> list = errorCodesMap.get(code);
+                final List<ServletHandler> list = errorCodesMap.get(code);
                 if ( list != null )
                 {
                     int index = 0;
-                    final Iterator<ServletHolder> i = list.iterator();
+                    final Iterator<ServletHandler> i = list.iterator();
                     while ( i.hasNext() )
                     {
-                        final ServletHolder holder = i.next();
+                        final ServletHandler holder = i.next();
                         if ( holder.getServletInfo().equals(info) )
                         {
                             holder.destroy();
 
-                            final List<ServletHolder> newList = new ArrayList<ServletHolder>(list);
+                            final List<ServletHandler> newList = new ArrayList<ServletHandler>(list);
                             newList.remove(holder);
 
                             if ( index == 0 )
@@ -231,7 +231,7 @@ public final class ErrorPageRegistry
                                 index++;
                                 while ( index < list.size() )
                                 {
-                                    final ServletHolder next = list.get(index);
+                                    final ServletHandler next = list.get(index);
                                     if ( tryToActivate(code, next, statusMapping.get(next.getServletInfo())) )
                                     {
                                         break;
@@ -259,19 +259,19 @@ public final class ErrorPageRegistry
             }
             for(final String exception : reg.exceptions)
             {
-                final List<ServletHolder> list = exceptionsMap.get(exception);
+                final List<ServletHandler> list = exceptionsMap.get(exception);
                 if ( list != null )
                 {
                     int index = 0;
-                    final Iterator<ServletHolder> i = list.iterator();
+                    final Iterator<ServletHandler> i = list.iterator();
                     while ( i.hasNext() )
                     {
-                        final ServletHolder holder = i.next();
+                        final ServletHandler holder = i.next();
                         if ( holder.getServletInfo().equals(info) )
                         {
                             holder.destroy();
 
-                            final List<ServletHolder> newList = new ArrayList<ServletHolder>(list);
+                            final List<ServletHandler> newList = new ArrayList<ServletHandler>(list);
                             newList.remove(holder);
 
                             if ( index == 0 )
@@ -279,7 +279,7 @@ public final class ErrorPageRegistry
                                 index++;
                                 while ( index < list.size() )
                                 {
-                                    final ServletHolder next = list.get(index);
+                                    final ServletHandler next = list.get(index);
                                     if ( tryToActivate(exception, next, statusMapping.get(next.getServletInfo())) )
                                     {
                                         break;
@@ -314,9 +314,9 @@ public final class ErrorPageRegistry
      * @param errorCode Error code
      * @return The servlet handling the error or {@code null}
      */
-    public ServletHolder get(final Throwable exception, final int errorCode)
+    public ServletHandler get(final Throwable exception, final int errorCode)
     {
-        ServletHolder errorHandler = this.get(exception);
+        ServletHandler errorHandler = this.get(exception);
         if (errorHandler != null)
         {
             return errorHandler;
@@ -325,9 +325,9 @@ public final class ErrorPageRegistry
         return get(errorCode);
     }
 
-    private ServletHolder get(final int errorCode)
+    private ServletHandler get(final int errorCode)
     {
-        final List<ServletHolder> list = this.errorCodesMap.get(errorCode);
+        final List<ServletHandler> list = this.errorCodesMap.get(errorCode);
         if ( list != null )
         {
             return list.get(0);
@@ -335,18 +335,18 @@ public final class ErrorPageRegistry
         return null;
     }
 
-    private ServletHolder get(final Throwable exception)
+    private ServletHandler get(final Throwable exception)
     {
         if (exception == null)
         {
             return null;
         }
 
-        ServletHolder servletHandler = null;
+        ServletHandler servletHandler = null;
         Class<?> throwableClass = exception.getClass();
         while ( servletHandler == null && throwableClass != null )
         {
-            final List<ServletHolder> list = this.errorCodesMap.get(throwableClass.getName());
+            final List<ServletHandler> list = this.errorCodesMap.get(throwableClass.getName());
             if ( list != null )
             {
                 servletHandler = list.get(0);
@@ -364,7 +364,7 @@ public final class ErrorPageRegistry
         return servletHandler;
     }
 
-    private boolean tryToActivate(final Long code, final ServletHolder holder, final ErrorRegistrationStatus status)
+    private boolean tryToActivate(final Long code, final ServletHandler holder, final ErrorRegistrationStatus status)
     {
         // add to active
         final int result = holder.init();
@@ -373,7 +373,7 @@ public final class ErrorPageRegistry
         return result == -1;
     }
 
-    private boolean tryToActivate(final String exception, final ServletHolder holder, final ErrorRegistrationStatus status)
+    private boolean tryToActivate(final String exception, final ServletHandler holder, final ErrorRegistrationStatus status)
     {
         // add to active
         final int result = holder.init();

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java Mon May 18 09:46:24 2015
@@ -29,8 +29,8 @@ import javax.annotation.CheckForNull;
 import javax.annotation.Nonnull;
 import javax.servlet.DispatcherType;
 
-import org.apache.felix.http.base.internal.handler.holder.FilterHolder;
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.FilterHandler;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
 import org.apache.felix.http.base.internal.runtime.dto.FailureRuntime;
 import org.apache.felix.http.base.internal.runtime.dto.FilterRuntime;
@@ -44,10 +44,10 @@ public final class FilterRegistry
     private static final class FilterRegistrationStatus
     {
         public int result;
-        public FilterHolder holder;
+        public FilterHandler holder;
     }
 
-    public void addFilter(@Nonnull final FilterHolder holder)
+    public void addFilter(@Nonnull final FilterHandler holder)
     {
         final int result = holder.init();
         if ( result == -1 )
@@ -77,16 +77,16 @@ public final class FilterRegistry
         }
     }
 
-    public FilterHolder[] getFilterHolders(@CheckForNull final ServletHolder holder,
+    public FilterHandler[] getFilterHandlers(@CheckForNull final ServletHandler holder,
             @CheckForNull DispatcherType dispatcherType,
             @Nonnull String requestURI)
     {
         // See Servlet 3.0 specification, section 6.2.4...
-        final List<FilterHolder> result = new ArrayList<FilterHolder>();
+        final List<FilterHandler> result = new ArrayList<FilterHandler>();
         result.addAll(this.filterMapping.getAllMatches(requestURI));
 
         // TODO this is not the most efficient/fastest way of doing this...
-        Iterator<FilterHolder> iter = result.iterator();
+        Iterator<FilterHandler> iter = result.iterator();
         while (iter.hasNext())
         {
             if (!referencesDispatcherType(iter.next(), dispatcherType))
@@ -97,7 +97,7 @@ public final class FilterRegistry
 
         final String servletName = (holder != null) ? holder.getName() : null;
         // TODO this is not the most efficient/fastest way of doing this...
-        for (FilterHolder filterHandler : this.filterMapping.values())
+        for (FilterHandler filterHandler : this.filterMapping.values())
         {
             if (referencesServletByName(filterHandler, servletName))
             {
@@ -105,10 +105,10 @@ public final class FilterRegistry
             }
         }
 
-        return result.toArray(new FilterHolder[result.size()]);
+        return result.toArray(new FilterHandler[result.size()]);
     }
 
-    private boolean referencesDispatcherType(FilterHolder holder, DispatcherType dispatcherType)
+    private boolean referencesDispatcherType(FilterHandler holder, DispatcherType dispatcherType)
     {
         if (dispatcherType == null)
         {
@@ -117,7 +117,7 @@ public final class FilterRegistry
         return Arrays.asList(holder.getFilterInfo().getDispatcher()).contains(dispatcherType);
     }
 
-    private boolean referencesServletByName(FilterHolder handler, String servletName)
+    private boolean referencesServletByName(FilterHandler handler, String servletName)
     {
         if (servletName == null)
         {

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerMapping.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerMapping.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerMapping.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerMapping.java Mon May 18 09:46:24 2015
@@ -35,7 +35,7 @@ import java.util.regex.Pattern;
 
 import javax.annotation.Nonnull;
 
-import org.apache.felix.http.base.internal.handler.holder.FilterHolder;
+import org.apache.felix.http.base.internal.handler.FilterHandler;
 import org.apache.felix.http.base.internal.util.PatternUtil;
 import org.apache.felix.http.base.internal.util.PatternUtil.PatternComparator;
 
@@ -50,16 +50,16 @@ import org.apache.felix.http.base.intern
  */
 public final class HandlerMapping
 {
-    private final SortedMap<Pattern, Set<FilterHolder>> exactMap;
-    private final SortedMap<Pattern, Set<FilterHolder>> wildcardMap;
-    private final Set<FilterHolder> mappedHandlers;
+    private final SortedMap<Pattern, Set<FilterHandler>> exactMap;
+    private final SortedMap<Pattern, Set<FilterHandler>> wildcardMap;
+    private final Set<FilterHandler> mappedHandlers;
 
     /**
      * Creates a new, empty, {@link HandlerMapping} instance.
      */
     public HandlerMapping()
     {
-        this(Collections.<Pattern, Collection<FilterHolder>>emptyMap());
+        this(Collections.<Pattern, Collection<FilterHandler>>emptyMap());
     }
 
     /**
@@ -67,35 +67,35 @@ public final class HandlerMapping
      *
      * @param mappings the elements to map.
      */
-    private HandlerMapping(@Nonnull final Map<Pattern, Collection<FilterHolder>> mappings)
+    private HandlerMapping(@Nonnull final Map<Pattern, Collection<FilterHandler>> mappings)
     {
-        this.exactMap = new TreeMap<Pattern, Set<FilterHolder>>(PatternComparator.INSTANCE);
-        this.wildcardMap = new TreeMap<Pattern, Set<FilterHolder>>(PatternComparator.INSTANCE);
-        this.mappedHandlers = new TreeSet<FilterHolder>();
+        this.exactMap = new TreeMap<Pattern, Set<FilterHandler>>(PatternComparator.INSTANCE);
+        this.wildcardMap = new TreeMap<Pattern, Set<FilterHandler>>(PatternComparator.INSTANCE);
+        this.mappedHandlers = new TreeSet<FilterHandler>();
 
-        for (Map.Entry<Pattern, Collection<FilterHolder>> mapping : mappings.entrySet())
+        for (Map.Entry<Pattern, Collection<FilterHandler>> mapping : mappings.entrySet())
         {
             Pattern pattern = mapping.getKey();
-            Collection<FilterHolder> handlers = mapping.getValue();
+            Collection<FilterHandler> handlers = mapping.getValue();
 
             mappedHandlers.addAll(handlers);
 
             if (PatternUtil.isWildcardPattern(pattern))
             {
-                Set<FilterHolder> vs = this.wildcardMap.get(pattern);
+                Set<FilterHandler> vs = this.wildcardMap.get(pattern);
                 if (vs == null)
                 {
-                    vs = new TreeSet<FilterHolder>();
+                    vs = new TreeSet<FilterHandler>();
                     this.wildcardMap.put(pattern, vs);
                 }
                 vs.addAll(handlers);
             }
             else
             {
-                Set<FilterHolder> vs = this.exactMap.get(pattern);
+                Set<FilterHandler> vs = this.exactMap.get(pattern);
                 if (vs == null)
                 {
-                    vs = new TreeSet<FilterHolder>();
+                    vs = new TreeSet<FilterHandler>();
                     this.exactMap.put(pattern, vs);
                 }
                 vs.addAll(handlers);
@@ -111,9 +111,9 @@ public final class HandlerMapping
      * @return a new {@link HandlerMapping} instance with a mapping for the
      *         given handler.
      */
-    public HandlerMapping add(@Nonnull final FilterHolder handler)
+    public HandlerMapping add(@Nonnull final FilterHandler handler)
     {
-        final Map<Pattern, FilterHolder> mappings = new TreeMap<Pattern, FilterHolder>(PatternComparator.INSTANCE);
+        final Map<Pattern, FilterHandler> mappings = new TreeMap<Pattern, FilterHandler>(PatternComparator.INSTANCE);
         for (final Pattern pattern : handler.getPatterns())
         {
             mappings.put(pattern, handler);
@@ -121,9 +121,9 @@ public final class HandlerMapping
         return add(mappings);
     }
 
-    HandlerMapping add(@Nonnull final Map<Pattern, FilterHolder> mappings)
+    HandlerMapping add(@Nonnull final Map<Pattern, FilterHandler> mappings)
     {
-        final Map<Pattern, Collection<FilterHolder>> newMappings = getAllMappings();
+        final Map<Pattern, Collection<FilterHandler>> newMappings = getAllMappings();
         addMappings(mappings, newMappings);
         return new HandlerMapping(newMappings);
     }
@@ -136,9 +136,9 @@ public final class HandlerMapping
      * @return a new {@link HandlerMapping} instance without a mapping for the
      *         given handler.
      */
-    public HandlerMapping remove(FilterHolder handler)
+    public HandlerMapping remove(FilterHandler handler)
     {
-        Map<Pattern, FilterHolder> mappings = new TreeMap<Pattern, FilterHolder>(PatternComparator.INSTANCE);
+        Map<Pattern, FilterHandler> mappings = new TreeMap<Pattern, FilterHandler>(PatternComparator.INSTANCE);
         for (Pattern pattern : handler.getPatterns())
         {
             mappings.put(pattern, handler);
@@ -146,38 +146,38 @@ public final class HandlerMapping
         return remove(mappings);
     }
 
-    HandlerMapping remove(Map<Pattern, FilterHolder> mappings)
+    HandlerMapping remove(Map<Pattern, FilterHandler> mappings)
     {
-        Map<Pattern, Collection<FilterHolder>> newMappings = getAllMappings();
+        Map<Pattern, Collection<FilterHandler>> newMappings = getAllMappings();
         removeMappings(mappings, newMappings);
         return new HandlerMapping(newMappings);
     }
 
-    HandlerMapping update(Map<Pattern, FilterHolder> add, Map<Pattern, FilterHolder> remove)
+    HandlerMapping update(Map<Pattern, FilterHandler> add, Map<Pattern, FilterHandler> remove)
     {
-        Map<Pattern, Collection<FilterHolder>> newMappings = getAllMappings();
+        Map<Pattern, Collection<FilterHandler>> newMappings = getAllMappings();
         removeMappings(remove, newMappings);
         addMappings(add, newMappings);
         return new HandlerMapping(newMappings);
     }
 
-    private void addMappings(Map<Pattern, FilterHolder> mappings, Map<Pattern, Collection<FilterHolder>> target)
+    private void addMappings(Map<Pattern, FilterHandler> mappings, Map<Pattern, Collection<FilterHandler>> target)
     {
-        for (Map.Entry<Pattern, FilterHolder> mapping : mappings.entrySet())
+        for (Map.Entry<Pattern, FilterHandler> mapping : mappings.entrySet())
         {
             if (!target.containsKey(mapping.getKey()))
             {
-                target.put(mapping.getKey(), new TreeSet<FilterHolder>());
+                target.put(mapping.getKey(), new TreeSet<FilterHandler>());
             }
             target.get(mapping.getKey()).add(mapping.getValue());
         }
     }
 
-    private void removeMappings(Map<Pattern, FilterHolder> mappings, Map<Pattern, Collection<FilterHolder>> target)
+    private void removeMappings(Map<Pattern, FilterHandler> mappings, Map<Pattern, Collection<FilterHandler>> target)
     {
-        for (Map.Entry<Pattern, FilterHolder> mapping : mappings.entrySet())
+        for (Map.Entry<Pattern, FilterHandler> mapping : mappings.entrySet())
         {
-            Collection<FilterHolder> mappedHandlers = target.get(mapping.getKey());
+            Collection<FilterHandler> mappedHandlers = target.get(mapping.getKey());
             if (mappedHandlers == null)
             {
                 continue;
@@ -190,9 +190,9 @@ public final class HandlerMapping
         }
     }
 
-    private Map<Pattern, Collection<FilterHolder>> getAllMappings()
+    private Map<Pattern, Collection<FilterHandler>> getAllMappings()
     {
-        Map<Pattern, Collection<FilterHolder>> newMappings = new TreeMap<Pattern, Collection<FilterHolder>>(PatternComparator.INSTANCE);
+        Map<Pattern, Collection<FilterHandler>> newMappings = new TreeMap<Pattern, Collection<FilterHandler>>(PatternComparator.INSTANCE);
         newMappings.putAll(exactMap);
         newMappings.putAll(wildcardMap);
         return newMappings;
@@ -205,7 +205,7 @@ public final class HandlerMapping
      *         <code>Collection</code> is unmodifiable and never
      *         <code>null</code>.
      */
-    public Collection<FilterHolder> values()
+    public Collection<FilterHandler> values()
     {
         return unmodifiableCollection(mappedHandlers);
     }
@@ -216,7 +216,7 @@ public final class HandlerMapping
      * @return <code>true</code> if the handlers contains the specified handler,
      *         <code>false</code> otherwise
      */
-    public boolean contains(FilterHolder handler)
+    public boolean contains(FilterHandler handler)
     {
         return mappedHandlers.contains(handler);
     }
@@ -227,7 +227,7 @@ public final class HandlerMapping
      * @param path the path that should match, cannot be <code>null</code>.
      * @return a {@link Collection} of all matching handlers, never <code>null</code>.
      */
-    public List<FilterHolder> getAllMatches(String path)
+    public List<FilterHandler> getAllMatches(String path)
     {
         return getAllMatches(path, false /* firstOnly */);
     }
@@ -245,9 +245,9 @@ public final class HandlerMapping
      * @param path the path that should match, cannot be <code>null</code>.
      * @return the best matching handler for the given path, or <code>null</code> in case no handler matched.
      */
-    FilterHolder getBestMatch(String path)
+    FilterHandler getBestMatch(String path)
     {
-        List<FilterHolder> allMatches = getAllMatches(path, true /* firstOnly */);
+        List<FilterHandler> allMatches = getAllMatches(path, true /* firstOnly */);
         return allMatches.isEmpty() ? null : allMatches.get(0);
     }
 
@@ -257,14 +257,14 @@ public final class HandlerMapping
      * @param name the name of the handler to return, can be <code>null</code> in which case this method will return <code>null</code>.
      * @return the element with the given name, or <code>null</code> if not found, or the given argument was <code>null</code>.
      */
-    FilterHolder getByName(String name)
+    FilterHandler getByName(String name)
     {
         if (name == null)
         {
             return null;
         }
 
-        for (FilterHolder element : this.mappedHandlers)
+        for (FilterHandler element : this.mappedHandlers)
         {
             if (name.equals(element.getName()))
             {
@@ -294,38 +294,38 @@ public final class HandlerMapping
      *        <code>false</code> if all matching patterns should be returned.
      * @return a list with matching elements, never <code>null</code>.
      */
-    private List<FilterHolder> getAllMatches(String path, boolean firstOnly)
+    private List<FilterHandler> getAllMatches(String path, boolean firstOnly)
     {
         path = (path == null) ? "" : path.trim();
 
-        Set<FilterHolder> result = new TreeSet<FilterHolder>();
+        Set<FilterHandler> result = new TreeSet<FilterHandler>();
         // Look for exact matches only, that is, those patterns without wildcards...
-        for (Entry<Pattern, Set<FilterHolder>> entry : this.exactMap.entrySet())
+        for (Entry<Pattern, Set<FilterHandler>> entry : this.exactMap.entrySet())
         {
             Matcher matcher = entry.getKey().matcher(path);
             // !!! we should always match the *entire* pattern, instead of the longest prefix...
             if (matcher.matches())
             {
-                Set<FilterHolder> vs = entry.getValue();
-                for (FilterHolder v : vs)
+                Set<FilterHandler> vs = entry.getValue();
+                for (FilterHandler v : vs)
                 {
                     result.add(v);
                     if (firstOnly)
                     {
-                        return new ArrayList<FilterHolder>(result);
+                        return new ArrayList<FilterHandler>(result);
                     }
                 }
             }
         }
 
         // Try to apply the wildcard patterns...
-        for (Entry<Pattern, Set<FilterHolder>> entry : this.wildcardMap.entrySet())
+        for (Entry<Pattern, Set<FilterHandler>> entry : this.wildcardMap.entrySet())
         {
             Matcher matcher = entry.getKey().matcher(path);
             if (matcher.find(0))
             {
-                Set<FilterHolder> vs = entry.getValue();
-                for (FilterHolder v : vs)
+                Set<FilterHandler> vs = entry.getValue();
+                for (FilterHandler v : vs)
                 {
                     result.add(v);
 
@@ -337,6 +337,6 @@ public final class HandlerMapping
             }
         }
 
-        return new ArrayList<FilterHolder>(result);
+        return new ArrayList<FilterHandler>(result);
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java Mon May 18 09:46:24 2015
@@ -19,8 +19,8 @@ package org.apache.felix.http.base.inter
 import javax.annotation.Nonnull;
 import javax.servlet.DispatcherType;
 
-import org.apache.felix.http.base.internal.handler.holder.FilterHolder;
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.FilterHandler;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
 import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
@@ -138,7 +138,7 @@ public final class PerContextHandlerRegi
         return this.servletRegistry.resolve(relativeRequestURI);
     }
 
-    public ServletHolder resolveServletByName(final String name)
+    public ServletHandler resolveServletByName(final String name)
     {
         return this.servletRegistry.resolveByName(name);
     }
@@ -148,7 +148,7 @@ public final class PerContextHandlerRegi
      * @param holder The servlet holder
      * @param info The servlet info
      */
-    public void addServlet(@Nonnull final ServletHolder holder)
+    public void addServlet(@Nonnull final ServletHandler holder)
     {
         this.servletRegistry.addServlet(holder);
         this.errorPageRegistry.addServlet(holder);
@@ -164,7 +164,7 @@ public final class PerContextHandlerRegi
         this.errorPageRegistry.removeServlet(info, destroy);
     }
 
-    public void addFilter(@Nonnull final FilterHolder holder)
+    public void addFilter(@Nonnull final FilterHandler holder)
     {
         this.filterRegistry.addFilter(holder);
     }
@@ -174,13 +174,13 @@ public final class PerContextHandlerRegi
         this.filterRegistry.removeFilter(info, destroy);
     }
 
-    public FilterHolder[] getFilterHolders(final ServletHolder servletHolder,
+    public FilterHandler[] getFilterHandlers(final ServletHandler servletHandler,
             DispatcherType dispatcherType, String requestURI)
     {
-        return this.filterRegistry.getFilterHolders(servletHolder, dispatcherType, requestURI);
+        return this.filterRegistry.getFilterHandlers(servletHandler, dispatcherType, requestURI);
     }
 
-    public ServletHolder getErrorHandler(int code, Throwable exception)
+    public ServletHandler getErrorHandler(int code, Throwable exception)
     {
         return this.errorPageRegistry.get(exception, code);
     }

Copied: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistration.java (from r1679892, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletHandler.java)
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistration.java?p2=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistration.java&p1=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletHandler.java&r1=1679892&r2=1679975&rev=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistration.java Mon May 18 09:46:24 2015
@@ -21,26 +21,26 @@ import java.util.regex.Pattern;
 
 import javax.annotation.Nonnull;
 
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.util.UriUtils;
 
 /**
  * Servlet handler is registered with a pattern and a servlet holder
  */
-public class ServletHandler
+public class ServletRegistration
 {
-    private final ServletHolder holder;
+    private final ServletHandler handler;
     private final Pattern pattern;
 
-    public ServletHandler(@Nonnull final ServletHolder holder, @Nonnull final Pattern pattern)
+    public ServletRegistration(@Nonnull final ServletHandler handler, @Nonnull final Pattern pattern)
     {
-        this.holder = holder;
+        this.handler = handler;
         this.pattern = pattern;
     }
 
-    public ServletHolder getServletHolder()
+    public ServletHandler getServletHandler()
     {
-        return this.holder;
+        return this.handler;
     }
 
     public PathResolution resolve(@Nonnull final String requestURI)
@@ -51,7 +51,7 @@ public class ServletHandler
             final PathResolution pr = new PathResolution();
             pr.servletPath = matcher.groupCount() > 0 ? matcher.group(1) : matcher.group();
             pr.pathInfo = UriUtils.compactPath(UriUtils.relativePath(pr.servletPath, requestURI));
-            pr.holder = this.holder;
+            pr.holder = this.handler;
 
             return pr;
         }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java Mon May 18 09:46:24 2015
@@ -27,7 +27,7 @@ import java.util.regex.Pattern;
 
 import javax.annotation.Nonnull;
 
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.apache.felix.http.base.internal.util.PatternUtil;
 import org.osgi.service.http.runtime.dto.DTOConstants;
@@ -42,9 +42,9 @@ import org.osgi.service.http.runtime.dto
  */
 public final class ServletRegistry
 {
-    private final Map<String, ServletHandler> activeServletMappings = new ConcurrentHashMap<String, ServletHandler>();
+    private final Map<String, ServletRegistration> activeServletMappings = new ConcurrentHashMap<String, ServletRegistration>();
 
-    private final Map<String, List<ServletHolder>> inactiveServletMappings = new HashMap<String, List<ServletHolder>>();
+    private final Map<String, List<ServletHandler>> inactiveServletMappings = new HashMap<String, List<ServletHandler>>();
 
     private final Map<ServletInfo, ServletRegistrationStatus> statusMapping = new ConcurrentHashMap<ServletInfo, ServletRegistry.ServletRegistrationStatus>();
 
@@ -53,9 +53,9 @@ public final class ServletRegistry
     private static final class ServletNameStatus implements Comparable<ServletNameStatus>
     {
         public volatile boolean isActive = false;
-        public final ServletHolder holder;
+        public final ServletHandler holder;
 
-        public ServletNameStatus(final ServletHolder h)
+        public ServletNameStatus(final ServletHandler h)
         {
             this.holder = h;
         }
@@ -76,7 +76,7 @@ public final class ServletRegistry
     {
         int len = -1;
         PathResolution candidate = null;
-        for(final Map.Entry<String, ServletHandler> entry : this.activeServletMappings.entrySet())
+        for(final Map.Entry<String, ServletRegistration> entry : this.activeServletMappings.entrySet())
         {
             final PathResolution pr = entry.getValue().resolve(relativeRequestURI);
             if ( pr != null && entry.getKey().length() > len )
@@ -93,7 +93,7 @@ public final class ServletRegistry
      *
      * @param holder The servlet holder
      */
-    public void addServlet(@Nonnull final ServletHolder holder)
+    public void addServlet(@Nonnull final ServletHandler holder)
     {
         // we have to check for every pattern in the info
         // Can be null in case of error-handling servlets...
@@ -103,18 +103,18 @@ public final class ServletRegistry
 
             for(final String pattern : holder.getServletInfo().getPatterns())
             {
-                final ServletHandler regHandler = this.activeServletMappings.get(pattern);
+                final ServletRegistration regHandler = this.activeServletMappings.get(pattern);
                 if ( regHandler != null )
                 {
-                    if ( regHandler.getServletHolder().getServletInfo().getServiceReference().compareTo(holder.getServletInfo().getServiceReference()) < 0 )
+                    if ( regHandler.getServletHandler().getServletInfo().getServiceReference().compareTo(holder.getServletInfo().getServiceReference()) < 0 )
                     {
                         // replace if no error with new servlet
                         if ( this.tryToActivate(pattern, holder, status) )
                         {
 //                            nameStatus.isActive = true;
-                            regHandler.getServletHolder().destroy();
+                            regHandler.getServletHandler().destroy();
 
-                            this.addToInactiveList(pattern, regHandler.getServletHolder(), this.statusMapping.get(regHandler.getServletHolder().getServletInfo()));
+                            this.addToInactiveList(pattern, regHandler.getServletHandler(), this.statusMapping.get(regHandler.getServletHandler().getServletInfo()));
                         }
                     }
                     else
@@ -145,16 +145,16 @@ public final class ServletRegistry
         if ( info.getPatterns() != null )
         {
             this.statusMapping.remove(info);
-            ServletHolder cleanupHolder = null;
+            ServletHandler cleanupHolder = null;
 
             for(final String pattern : info.getPatterns())
             {
 
-                final ServletHandler regHandler = this.activeServletMappings.get(pattern);
-                if ( regHandler != null && regHandler.getServletHolder().getServletInfo().equals(info) )
+                final ServletRegistration regHandler = this.activeServletMappings.get(pattern);
+                if ( regHandler != null && regHandler.getServletHandler().getServletInfo().equals(info) )
                 {
-                    cleanupHolder = regHandler.getServletHolder();
-                    final List<ServletHolder> inactiveList = this.inactiveServletMappings.get(pattern);
+                    cleanupHolder = regHandler.getServletHandler();
+                    final List<ServletHandler> inactiveList = this.inactiveServletMappings.get(pattern);
                     if ( inactiveList == null )
                     {
                         this.activeServletMappings.remove(pattern);
@@ -164,7 +164,7 @@ public final class ServletRegistry
                         boolean done = false;
                         while ( !done )
                         {
-                            final ServletHolder h = inactiveList.remove(0);
+                            final ServletHandler h = inactiveList.remove(0);
                             done = this.tryToActivate(pattern, h, this.statusMapping.get(h.getServletInfo()));
                             if ( !done )
                             {
@@ -179,13 +179,13 @@ public final class ServletRegistry
                 }
                 else
                 {
-                    final List<ServletHolder> inactiveList = this.inactiveServletMappings.get(pattern);
+                    final List<ServletHandler> inactiveList = this.inactiveServletMappings.get(pattern);
                     if ( inactiveList != null )
                     {
-                        final Iterator<ServletHolder> i = inactiveList.iterator();
+                        final Iterator<ServletHandler> i = inactiveList.iterator();
                         while ( i.hasNext() )
                         {
-                            final ServletHolder h = i.next();
+                            final ServletHandler h = i.next();
                             if ( h.getServletInfo().equals(info) )
                             {
                                 i.remove();
@@ -208,12 +208,12 @@ public final class ServletRegistry
         }
     }
 
-    private void addToInactiveList(final String pattern, final ServletHolder holder, final ServletRegistrationStatus status)
+    private void addToInactiveList(final String pattern, final ServletHandler holder, final ServletRegistrationStatus status)
     {
-        List<ServletHolder> inactiveList = this.inactiveServletMappings.get(pattern);
+        List<ServletHandler> inactiveList = this.inactiveServletMappings.get(pattern);
         if ( inactiveList == null )
         {
-            inactiveList = new ArrayList<ServletHolder>();
+            inactiveList = new ArrayList<ServletHandler>();
             this.inactiveServletMappings.put(pattern, inactiveList);
         }
         inactiveList.add(holder);
@@ -221,14 +221,14 @@ public final class ServletRegistry
         status.pathToStatus.put(pattern, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
     }
 
-    private boolean tryToActivate(final String pattern, final ServletHolder holder, final ServletRegistrationStatus status)
+    private boolean tryToActivate(final String pattern, final ServletHandler holder, final ServletRegistrationStatus status)
     {
         // add to active
         final int result = holder.init();
         if ( result == -1 )
         {
             final Pattern p = Pattern.compile(PatternUtil.convertToRegEx(pattern));
-            final ServletHandler handler = new ServletHandler(holder, p);
+            final ServletRegistration handler = new ServletRegistration(holder, p);
             this.activeServletMappings.put(pattern, handler);
 
             // add ok
@@ -248,7 +248,7 @@ public final class ServletRegistry
         return this.statusMapping;
     }
 
-    public ServletHolder resolveByName(@Nonnull String name)
+    public ServletHandler resolveByName(@Nonnull String name)
     {
         final List<ServletNameStatus> holderList = this.servletsByName.get(name);
         if ( holderList != null )

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletResolution.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletResolution.java?rev=1679975&r1=1679974&r2=1679975&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletResolution.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletResolution.java Mon May 18 09:46:24 2015
@@ -16,11 +16,11 @@
  */
 package org.apache.felix.http.base.internal.registry;
 
-import org.apache.felix.http.base.internal.handler.holder.ServletHolder;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
 
 public class ServletResolution {
 
-    public ServletHolder holder;
+    public ServletHandler holder;
 
     public PerContextHandlerRegistry handlerRegistry;
 }



Mime
View raw message