felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1656333 - in /felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker: AbstractTracker.java FilterTracker.java ServletTracker.java
Date Sun, 01 Feb 2015 17:24:04 GMT
Author: cziegeler
Date: Sun Feb  1 17:24:04 2015
New Revision: 1656333

URL: http://svn.apache.org/r1656333
Log:
Only track services for the Felix whiteboard extensions

Modified:
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java?rev=1656333&r1=1656332&r2=1656333&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
Sun Feb  1 17:24:04 2015
@@ -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

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java?rev=1656333&r1=1656332&r2=1656333&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
Sun Feb  1 17:24:04 2015
@@ -18,8 +18,10 @@ package org.apache.felix.http.whiteboard
 
 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 @@ public final class FilterTracker
 {
     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;
     }
 

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java?rev=1656333&r1=1656332&r2=1656333&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
Sun Feb  1 17:24:04 2015
@@ -18,8 +18,10 @@ package org.apache.felix.http.whiteboard
 
 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 @@ public final class ServletTracker
 {
     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;
     }
 



Mime
View raw message