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/01/31 18:34:47 UTC

svn commit: r1656218 - in /felix/trunk/http/base/src: main/java/org/apache/felix/http/base/internal/runtime/ main/java/org/apache/felix/http/base/internal/service/ main/java/org/apache/felix/http/base/internal/whiteboard/ main/java/org/apache/felix/htt...

Author: cziegeler
Date: Sat Jan 31 17:34:47 2015
New Revision: 1656218

URL: http://svn.apache.org/r1656218
Log:
[RFC189] Refactor whiteboard service registration

Added:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java   (with props)
Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/FilterTracker.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java Sat Jan 31 17:34:47 2015
@@ -21,13 +21,9 @@ package org.apache.felix.http.base.inter
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
 
 import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 
 /**
  * Base class for all info objects.
@@ -35,20 +31,12 @@ import org.osgi.service.http.whiteboard.
  */
 public abstract class AbstractInfo<T> implements Comparable<AbstractInfo<T>>
 {
-    /** Service id for services not provided through the service registry. */
-    private static final AtomicLong serviceIdCounter = new AtomicLong(-1);
-
     /** Service ranking. */
     private final int ranking;
 
     /** Service id. */
     private final long serviceId;
 
-    /** The context selection. */
-    private final String contextSelection;
-
-    private final Filter filter;
-
     /** Service reference. */
     private final ServiceReference<T> serviceReference;
 
@@ -65,33 +53,6 @@ public abstract class AbstractInfo<T> im
             this.ranking = 0;
         }
         this.serviceReference = ref;
-        String sel = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT);
-        if ( isEmpty(sel) )
-        {
-            this.contextSelection = "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "="
-                                   + HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME + ")";
-        }
-        else
-        {
-            this.contextSelection = sel;
-        }
-        Filter f = null;
-        try
-        {
-            f = ref.getBundle().getBundleContext().createFilter(this.contextSelection);
-        }
-        catch ( final InvalidSyntaxException ise)
-        {
-            // ignore
-            f = null;
-        }
-        this.filter = f;
-    }
-
-    public AbstractInfo(final int ranking)
-    {
-        this(ranking, serviceIdCounter.getAndDecrement());
-
     }
 
     public AbstractInfo(final int ranking, final long serviceId)
@@ -99,12 +60,11 @@ public abstract class AbstractInfo<T> im
         this.ranking = ranking;
         this.serviceId = serviceId;
         this.serviceReference = null;
-        this.contextSelection = null;
-        this.filter = null;
     }
 
-    public boolean isValid() {
-        return this.filter != null || this.serviceReference == null;
+    public boolean isValid()
+    {
+        return true;
     }
 
     /**
@@ -238,16 +198,6 @@ public abstract class AbstractInfo<T> im
         return this.serviceReference;
     }
 
-    public String getContextSelection()
-    {
-        return this.contextSelection;
-    }
-
-    public Filter getContextSelectionFilter()
-    {
-        return this.filter;
-    }
-
     @Override
     public int hashCode()
     {

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java Sat Jan 31 17:34:47 2015
@@ -25,7 +25,6 @@ import javax.servlet.Filter;
 
 import org.osgi.dto.DTO;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.runtime.dto.FilterDTO;
 import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 
@@ -37,7 +36,7 @@ import org.osgi.service.http.whiteboard.
  *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public final class FilterInfo extends AbstractInfo<Filter>
+public final class FilterInfo extends WhiteboardServiceInfo<Filter>
 {
     /**
      * Properties starting with this prefix are passed as filter init parameters to the
@@ -95,13 +94,6 @@ public final class FilterInfo extends Ab
      */
     private final Map<String, String> initParams;
 
-    /**
-     * The {@link HttpContext} for the filter.
-     */
-    private final HttpContext context;
-
-    private final Filter filter;
-
     public FilterInfo(final ServiceReference<Filter> ref)
     {
         super(ref);
@@ -125,8 +117,6 @@ public final class FilterInfo extends Ab
         {
             this.dispatcher = new DispatcherType[] {DispatcherType.REQUEST};
         }
-        this.context = null;
-        this.filter = null;
     }
 
     /**
@@ -135,9 +125,7 @@ public final class FilterInfo extends Ab
     public FilterInfo(final String name,
             final String regex,
             final int serviceRanking,
-            final Map<String, String> initParams,
-            final Filter filter,
-            final HttpContext context)
+            final Map<String, String> initParams)
     {
         super(serviceRanking);
         this.name = name;
@@ -147,8 +135,6 @@ public final class FilterInfo extends Ab
         this.initParams = initParams;
         this.asyncSupported = false;
         this.dispatcher = new DispatcherType[] {DispatcherType.REQUEST};
-        this.filter = filter;
-        this.context = context;
     }
 
     @Override
@@ -184,12 +170,4 @@ public final class FilterInfo extends Ab
     public Map<String, String> getInitParams() {
         return initParams;
     }
-
-    public HttpContext getContext() {
-        return context;
-    }
-
-    public Filter getFilter() {
-        return filter;
-    }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ResourceInfo.java Sat Jan 31 17:34:47 2015
@@ -26,7 +26,7 @@ import org.osgi.service.http.whiteboard.
  *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public final class ResourceInfo extends AbstractInfo<Object>
+public final class ResourceInfo extends WhiteboardServiceInfo<Object>
 {
     /**
      * The request mappings for the resource.

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java Sat Jan 31 17:34:47 2015
@@ -35,7 +35,7 @@ import org.osgi.service.http.whiteboard.
  *
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public final class ServletInfo extends AbstractInfo<Servlet>
+public final class ServletInfo extends WhiteboardServiceInfo<Servlet>
 {
     /**
      * Properties starting with this prefix are passed as servlet init parameters to the

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java?rev=1656218&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java Sat Jan 31 17:34:47 2015
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.http.base.internal.runtime;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+
+/**
+ * Base class for all info objects.
+ * Provides support for ranking and ordering of services.
+ */
+public abstract class WhiteboardServiceInfo<T> extends AbstractInfo<T>
+{
+    /** Service id for services not provided through the service registry. */
+    private static final AtomicLong serviceIdCounter = new AtomicLong(-1);
+
+    /** The context selection. */
+    private final String contextSelection;
+
+    private final Filter filter;
+
+    public WhiteboardServiceInfo(final ServiceReference<T> ref)
+    {
+        super(ref);
+        String sel = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT);
+        if ( isEmpty(sel) )
+        {
+            this.contextSelection = "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "="
+                                   + HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME + ")";
+        }
+        else
+        {
+            this.contextSelection = sel;
+        }
+        Filter f = null;
+        try
+        {
+            f = ref.getBundle().getBundleContext().createFilter(this.contextSelection);
+        }
+        catch ( final InvalidSyntaxException ise)
+        {
+            // ignore
+            f = null;
+        }
+        this.filter = f;
+    }
+
+    public WhiteboardServiceInfo(final int ranking)
+    {
+        this(ranking, serviceIdCounter.getAndDecrement());
+
+    }
+
+    public WhiteboardServiceInfo(final int ranking, final long serviceId)
+    {
+        super(ranking, serviceId);
+        this.contextSelection = null;
+        this.filter = null;
+    }
+
+    @Override
+    public boolean isValid()
+    {
+        return super.isValid() && (this.filter != null || this.getServiceReference() == null);
+    }
+
+    public String getContextSelection()
+    {
+        return this.contextSelection;
+    }
+
+    public Filter getContextSelectionFilter()
+    {
+        return this.filter;
+    }
+}

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java Sat Jan 31 17:34:47 2015
@@ -91,7 +91,7 @@ public final class HttpServiceImpl imple
             }
         }
 
-        final FilterInfo filterInfo = new FilterInfo(null, pattern, ranking, paramMap, filter, context);
+        final FilterInfo filterInfo = new FilterInfo(null, pattern, ranking, paramMap);
         if ( !filterInfo.isValid() )
         {
             throw new ServletException("Invalid registration information for filter.");

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java Sat Jan 31 17:34:47 2015
@@ -41,7 +41,6 @@ import javax.servlet.http.HttpServletRes
 
 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.util.MimeTypes;
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.context.ServletContextHelper;
 
@@ -63,33 +62,28 @@ public class ServletContextImpl implemen
         this.attributes = new ConcurrentHashMap<String, Object>();
     }
 
+    /**
+     * @see org.apache.felix.http.base.internal.context.ExtServletContext#handleSecurity(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+     */
     @Override
     public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException
     {
         return delegatee.handleSecurity(request, response);
     }
 
+    /**
+     * @see javax.servlet.ServletContext#getResource(java.lang.String)
+     */
     @Override
     public URL getResource(String path)
     {
-        return delegatee.getResource(normalizeResourcePath(path));
+        return delegatee.getResource(path);
     }
 
     @Override
     public String getMimeType(String file)
     {
-        String type = delegatee.getMimeType(file);
-        if (type != null)
-        {
-            return type;
-        }
-
-        return MimeTypes.get().getByFile(file);
-    }
-
-    public ServletContextHelper getDelegatee()
-    {
-        return delegatee;
+        return delegatee.getMimeType(file);
     }
 
     @Override
@@ -178,13 +172,13 @@ public class ServletContextImpl implemen
     @Override
     public Object getAttribute(String name)
     {
-        return (this.attributes != null) ? this.attributes.get(name) : this.context.getAttribute(name);
+        return this.attributes.get(name);
     }
 
     @Override
     public Enumeration getAttributeNames()
     {
-        return (this.attributes != null) ? Collections.enumeration(this.attributes.keySet()) : this.context.getAttributeNames();
+        return Collections.enumeration(this.attributes.keySet());
     }
 
     @Override
@@ -196,12 +190,14 @@ public class ServletContextImpl implemen
     @Override
     public ServletContext getContext(String uri)
     {
+        // TODO
         return this.context.getContext(uri);
     }
 
     @Override
     public String getContextPath()
     {
+        // TODO
         return this.context.getContextPath();
     }
 
@@ -278,14 +274,9 @@ public class ServletContextImpl implemen
     }
 
     @Override
-    public String getRealPath(String name)
+    public String getRealPath(String path)
     {
-        URL url = getResource(name);
-        if (url == null)
-        {
-            return null;
-        }
-        return url.toExternalForm();
+        return this.delegatee.getRealPath(path);
     }
 
     @Override
@@ -297,7 +288,7 @@ public class ServletContextImpl implemen
     @Override
     public InputStream getResourceAsStream(String path)
     {
-        URL res = getResource(path);
+        final URL res = getResource(path);
         if (res != null)
         {
             try
@@ -313,10 +304,9 @@ public class ServletContextImpl implemen
     }
 
     @Override
-    public Set getResourcePaths(String path)
+    public Set<String> getResourcePaths(final String path)
     {
-        // TODO
-        return null;
+        return this.delegatee.getResourcePaths(path);
     }
 
     @Override
@@ -388,16 +378,7 @@ public class ServletContextImpl implemen
     @Override
     public void removeAttribute(String name)
     {
-        Object oldValue;
-        if (this.attributes != null)
-        {
-            oldValue = this.attributes.remove(name);
-        }
-        else
-        {
-            oldValue = this.context.getAttribute(name);
-            this.context.removeAttribute(name);
-        }
+        Object oldValue = this.attributes.remove(name);
 
         if (oldValue != null)
         {
@@ -414,16 +395,7 @@ public class ServletContextImpl implemen
         }
         else if (name != null)
         {
-            Object oldValue;
-            if (this.attributes != null)
-            {
-                oldValue = this.attributes.put(name, value);
-            }
-            else
-            {
-                oldValue = this.context.getAttribute(name);
-                this.context.setAttribute(name, value);
-            }
+            Object oldValue = this.attributes.put(name, value);
 
             if (oldValue == null)
             {
@@ -447,31 +419,4 @@ public class ServletContextImpl implemen
     {
         this.context.setSessionTrackingModes(modes);
     }
-
-    private String normalizePath(String path)
-    {
-        if (path == null)
-        {
-            return null;
-        }
-
-        String normalizedPath = normalizeResourcePath(path);
-        if (normalizedPath.startsWith("/") && (normalizedPath.length() > 1))
-        {
-            normalizedPath = normalizedPath.substring(1);
-        }
-
-        return normalizedPath;
-    }
-
-    private String normalizeResourcePath(String path)
-    {
-        if ( path == null)
-        {
-            return null;
-        }
-        String normalizedPath = path.trim().replaceAll("/+", "/");
-
-        return normalizedPath;
-    }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java Sat Jan 31 17:34:47 2015
@@ -25,12 +25,13 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.felix.http.base.internal.runtime.AbstractInfo;
 import org.apache.felix.http.base.internal.runtime.ContextInfo;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
 import org.apache.felix.http.base.internal.runtime.ResourceInfo;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
+import org.apache.felix.http.base.internal.runtime.WhiteboardServiceInfo;
 import org.apache.felix.http.base.internal.service.InternalHttpService;
+import org.apache.felix.http.base.internal.util.MimeTypes;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
@@ -45,7 +46,7 @@ public final class ServletContextHelperM
     private final Map<String, List<ContextInfo>> contextMap = new HashMap<String, List<ContextInfo>>();
 
     /** A map with all servlet/filter registrations, mapped by abstract info. */
-    private final Map<AbstractInfo<?>, List<ContextInfo>> servicesMap = new HashMap<AbstractInfo<?>, List<ContextInfo>>();
+    private final Map<WhiteboardServiceInfo<?>, List<ContextInfo>> servicesMap = new HashMap<WhiteboardServiceInfo<?>, List<ContextInfo>>();
 
     private final InternalHttpService httpService;
 
@@ -62,7 +63,7 @@ public final class ServletContextHelperM
         final Dictionary<String, Object> props = new Hashtable<String, Object>();
         props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME, HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME);
         props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/");
-        props.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+        props.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
 
         this.defaultContextRegistration = bundleContext.registerService(ServletContextHelper.class,
                 new ServiceFactory<ServletContextHelper>() {
@@ -72,6 +73,11 @@ public final class ServletContextHelperM
                             final Bundle bundle,
                             final ServiceRegistration<ServletContextHelper> registration) {
                         return new ServletContextHelper(bundle) {
+
+                            @Override
+                            public String getMimeType(final String file) {
+                                return MimeTypes.get().getByFile(file);
+                            }
                         };
                     }
 
@@ -93,49 +99,27 @@ public final class ServletContextHelperM
         this.defaultContextRegistration.unregister();
     }
 
-    private void activate(final ContextInfo holder)
+    private void activate(final ContextInfo contextInfo)
     {
-        for(final Map.Entry<AbstractInfo<?>, List<ContextInfo>> entry : this.servicesMap.entrySet())
+        for(final Map.Entry<WhiteboardServiceInfo<?>, List<ContextInfo>> entry : this.servicesMap.entrySet())
         {
-            if ( entry.getKey().getContextSelectionFilter().match(holder.getServiceReference()) )
+            if ( entry.getKey().getContextSelectionFilter().match(contextInfo.getServiceReference()) )
             {
-                entry.getValue().add(holder);
-                if ( entry.getKey() instanceof ServletInfo )
-                {
-                    this.registerServlet((ServletInfo)entry.getKey(), holder);
-                }
-                else if ( entry.getKey() instanceof FilterInfo )
-                {
-                    this.registerFilter((FilterInfo)entry.getKey(), holder);
-                }
-                else if ( entry.getKey() instanceof ResourceInfo )
-                {
-                    this.registerResource((ResourceInfo)entry.getKey(), holder);
-                }
+                entry.getValue().add(contextInfo);
+                this.registerWhiteboardService(contextInfo, entry.getKey());
             }
         }
     }
 
-    private void deactivate(final ContextInfo holder)
+    private void deactivate(final ContextInfo contextInfo)
     {
-        final Iterator<Map.Entry<AbstractInfo<?>, List<ContextInfo>>> i = this.servicesMap.entrySet().iterator();
+        final Iterator<Map.Entry<WhiteboardServiceInfo<?>, List<ContextInfo>>> i = this.servicesMap.entrySet().iterator();
         while ( i.hasNext() )
         {
-            final Map.Entry<AbstractInfo<?>, List<ContextInfo>> entry = i.next();
-            if ( entry.getValue().remove(holder) )
+            final Map.Entry<WhiteboardServiceInfo<?>, List<ContextInfo>> entry = i.next();
+            if ( entry.getValue().remove(contextInfo) )
             {
-                if ( entry.getKey() instanceof ServletInfo )
-                {
-                    this.unregisterServlet((ServletInfo)entry.getKey(), holder);
-                }
-                else if ( entry.getKey() instanceof FilterInfo )
-                {
-                    this.unregisterFilter((FilterInfo)entry.getKey(), holder);
-                }
-                else if ( entry.getKey() instanceof ResourceInfo )
-                {
-                    this.unregisterResource((ResourceInfo)entry.getKey(), holder);
-                }
+                this.unregisterWhiteboardService(contextInfo, entry.getKey());
                 if ( entry.getValue().isEmpty() ) {
                     i.remove();
                 }
@@ -212,7 +196,7 @@ public final class ServletContextHelperM
         }
     }
 
-    private List<ContextInfo> getMatchingContexts(final AbstractInfo<?> info)
+    private List<ContextInfo> getMatchingContexts(final WhiteboardServiceInfo<?> info)
     {
         final List<ContextInfo> result = new ArrayList<ContextInfo>();
         for(final List<ContextInfo> holders : this.contextMap.values()) {
@@ -225,121 +209,81 @@ public final class ServletContextHelperM
         return result;
     }
 
-    private void registerServlet(final ServletInfo servletInfo, final ContextInfo holder)
-    {
-        this.httpService.registerServlet(holder, servletInfo);
-    }
-
-    private void unregisterServlet(final ServletInfo servletInfo, final ContextInfo holder)
-    {
-        this.httpService.unregisterServlet(holder, servletInfo);
-    }
-
-    private void registerFilter(final FilterInfo filterInfo, final ContextInfo holder)
-    {
-        this.httpService.registerFilter(holder, filterInfo);
-    }
-
-    private void unregisterFilter(final FilterInfo filterInfo, final ContextInfo holder)
-    {
-        this.httpService.unregisterFilter(holder, filterInfo);
-    }
-
-    private void registerResource(final ResourceInfo resourceInfo, final ContextInfo holder)
-    {
-        this.httpService.registerResource(holder, resourceInfo);
-    }
-
-    private void unregisterResource(final ResourceInfo resourceInfo, final ContextInfo holder)
-    {
-        this.httpService.unregisterResource(holder, resourceInfo);
-    }
-
     /**
-     * Add a new servlet.
-     * @param servletInfo The servlet info
+     * Add new whiteboard service to the registry
+     * @param info Whiteboard service info
      */
-    public void addServlet(final ServletInfo servletInfo)
+    public void addWhiteboardService(final WhiteboardServiceInfo<?> info)
     {
         synchronized ( this.contextMap )
         {
-            final List<ContextInfo> holderList = this.getMatchingContexts(servletInfo);
-            this.servicesMap.put(servletInfo, holderList);
+            final List<ContextInfo> holderList = this.getMatchingContexts(info);
+            this.servicesMap.put(info, holderList);
             for(final ContextInfo h : holderList)
             {
-            	this.registerServlet(servletInfo, h);
+                this.registerWhiteboardService(h, info);
             }
         }
     }
 
     /**
-     * Remove a servlet
-     * @param servletInfo The servlet info
+     * Remove whiteboard service from the registry
+     * @param info Whiteboard service info
      */
-    public void removeServlet(final ServletInfo servletInfo)
+    public void removeWhiteboardService(final WhiteboardServiceInfo<?> info)
     {
         synchronized ( this.contextMap )
         {
-            final List<ContextInfo> holderList = this.servicesMap.remove(servletInfo);
+            final List<ContextInfo> holderList = this.servicesMap.remove(info);
             if ( holderList != null )
             {
                 for(final ContextInfo h : holderList)
                 {
-                    this.unregisterServlet(servletInfo, h);
+                    this.unregisterWhiteboardService(h, info);
                 }
             }
         }
     }
 
-    public void addFilter(final FilterInfo info) {
-        synchronized ( this.contextMap )
+    /**
+     * Register whiteboard service in the http service
+     * @param contextInfo Context info
+     * @param info Whiteboard service info
+     */
+    private void registerWhiteboardService(final ContextInfo contextInfo, final WhiteboardServiceInfo<?> info)
+    {
+        if ( info instanceof ServletInfo )
         {
-            final List<ContextInfo> holderList = this.getMatchingContexts(info);
-            this.servicesMap.put(info, holderList);
-            for(final ContextInfo h : holderList)
-            {
-                this.registerFilter(info, h);
-            }
+            this.httpService.registerServlet(contextInfo, (ServletInfo)info);
         }
-    }
-
-    public void removeFilter(final FilterInfo info) {
-        synchronized ( this.contextMap )
+        else if ( info instanceof FilterInfo )
         {
-            final List<ContextInfo> holderList = this.servicesMap.remove(info);
-            if ( holderList != null )
-            {
-                for(final ContextInfo h : holderList)
-                {
-                    this.unregisterFilter(info, h);
-                }
-            }
+            this.httpService.registerFilter(contextInfo, (FilterInfo)info);
         }
-    }
-
-    public void addResource(final ResourceInfo info) {
-        synchronized ( this.contextMap )
+        else if ( info instanceof ResourceInfo )
         {
-            final List<ContextInfo> holderList = this.getMatchingContexts(info);
-            this.servicesMap.put(info, holderList);
-            for(final ContextInfo h : holderList)
-            {
-                this.registerResource(info, h);
-            }
+            this.httpService.registerResource(contextInfo, (ResourceInfo)info);
         }
     }
 
-    public void removeResource(final ResourceInfo info) {
-        synchronized ( this.contextMap )
+    /**
+     * Unregister whiteboard service from the http service
+     * @param contextInfo Context info
+     * @param info Whiteboard service info
+     */
+    private void unregisterWhiteboardService(final ContextInfo contextInfo, final WhiteboardServiceInfo<?> info)
+    {
+        if ( info instanceof ServletInfo )
         {
-            final List<ContextInfo> holderList = this.servicesMap.remove(info);
-            if ( holderList != null )
-            {
-                for(final ContextInfo h : holderList)
-                {
-                    this.unregisterResource(info, h);
-                }
-            }
+            this.httpService.unregisterServlet(contextInfo, (ServletInfo)info);
+        }
+        else if ( info instanceof FilterInfo )
+        {
+            this.httpService.unregisterFilter(contextInfo, (FilterInfo)info);
+        }
+        else if ( info instanceof ResourceInfo )
+        {
+            this.httpService.unregisterResource(contextInfo, (ResourceInfo)info);
         }
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/FilterTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/FilterTracker.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/FilterTracker.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/FilterTracker.java Sat Jan 31 17:34:47 2015
@@ -60,7 +60,7 @@ public final class FilterTracker extends
 
         if ( info.isValid() )
         {
-            this.contextManager.addFilter(info);
+            this.contextManager.addWhiteboardService(info);
         }
         else
         {
@@ -75,7 +75,7 @@ public final class FilterTracker extends
 
         if ( info.isValid() )
         {
-            this.contextManager.removeFilter(info);
+            this.contextManager.removeWhiteboardService(info);
         }
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ResourceTracker.java Sat Jan 31 17:34:47 2015
@@ -57,7 +57,7 @@ public final class ResourceTracker exten
 
         if ( info.isValid() )
         {
-            this.contextManager.addResource(info);
+            this.contextManager.addWhiteboardService(info);
         }
         else
         {
@@ -72,6 +72,6 @@ public final class ResourceTracker exten
 
         if ( info.isValid() )
         {
-            this.contextManager.removeResource(info);
+            this.contextManager.removeWhiteboardService(info);
         }
     }}

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java Sat Jan 31 17:34:47 2015
@@ -58,7 +58,7 @@ public final class ServletTracker extend
 
         if ( info.isValid() )
         {
-            this.contextManager.addServlet(info);
+            this.contextManager.addWhiteboardService(info);
         }
         else
         {
@@ -73,7 +73,7 @@ public final class ServletTracker extend
 
         if ( info.isValid() )
         {
-            this.contextManager.removeServlet(info);
+            this.contextManager.removeWhiteboardService(info);
         }
     }
 }

Modified: felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java?rev=1656218&r1=1656217&r2=1656218&view=diff
==============================================================================
--- felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java (original)
+++ felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/FilterHandlerTest.java Sat Jan 31 17:34:47 2015
@@ -242,7 +242,7 @@ public class FilterHandlerTest extends A
 
     private FilterHandler createHandler(String pattern, int ranking, final Map<String, String> initParams)
     {
-        final FilterInfo info = new FilterInfo(null, pattern, ranking, initParams, this.filter, null);
+        final FilterInfo info = new FilterInfo(null, pattern, ranking, initParams);
         return new FilterHandler(null, this.context, this.filter, info);
     }