Only track services for the Felix whiteboard extensions

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1656333 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
index f849218..607b6ab 100644
--- a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
+++ b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
@@ -17,15 +17,21 @@
 package org.apache.felix.http.whiteboard.internal.tracker;
 
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
 import org.osgi.framework.ServiceReference;
 import org.osgi.util.tracker.ServiceTracker;
 
 public abstract class AbstractTracker<T>
     extends ServiceTracker
 {
-    public AbstractTracker(BundleContext context, Class<T> clz)
+    public AbstractTracker(BundleContext context, Filter filter)
     {
-        super(context, clz.getName(), null);
+        super(context, filter, null);
+    }
+
+    public AbstractTracker(BundleContext context, Class clazz)
+    {
+        super(context, clazz.getName(), null);
     }
 
     @Override
diff --git a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
index 9ce1aec..9ff5c64 100644
--- a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
+++ b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
@@ -18,8 +18,10 @@
 
 import javax.servlet.Filter;
 
+import org.apache.felix.http.whiteboard.HttpWhiteboardConstants;
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 
 public final class FilterTracker
@@ -27,9 +29,24 @@
 {
     private final ExtenderManager manager;
 
+    private static org.osgi.framework.Filter createFilter(final BundleContext btx)
+    {
+        try
+        {
+            return btx.createFilter(String.format("(&(objectClass=%s)(%s=*))",
+                    Filter.class.getName(),
+                    HttpWhiteboardConstants.PATTERN));
+        }
+        catch ( final InvalidSyntaxException ise)
+        {
+            // we can safely ignore it as the above filter is a constant
+        }
+        return null; // we never get here - and if we get an NPE which is fine
+    }
+
     public FilterTracker(BundleContext context, ExtenderManager manager)
     {
-        super(context, Filter.class);
+        super(context, createFilter(context));
         this.manager = manager;
     }
 
diff --git a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
index fe5d6e1..39a25e0 100644
--- a/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
+++ b/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
@@ -18,8 +18,10 @@
 
 import javax.servlet.Servlet;
 
+import org.apache.felix.http.whiteboard.HttpWhiteboardConstants;
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
 
 public final class ServletTracker
@@ -27,9 +29,24 @@
 {
     private final ExtenderManager manager;
 
+    private static org.osgi.framework.Filter createFilter(final BundleContext btx)
+    {
+        try
+        {
+            return btx.createFilter(String.format("(&(objectClass=%s)(%s=*))",
+                    Servlet.class.getName(),
+                    HttpWhiteboardConstants.ALIAS));
+        }
+        catch ( final InvalidSyntaxException ise)
+        {
+            // we can safely ignore it as the above filter is a constant
+        }
+        return null; // we never get here - and if we get an NPE which is fine
+    }
+
     public ServletTracker(BundleContext context, ExtenderManager manager)
     {
-        super(context, Servlet.class);
+        super(context, createFilter(context));
         this.manager = manager;
     }