felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1624398 [1/2] - in /felix/sandbox/http-rfc189/whiteboard/src: main/java/org/apache/felix/http/whiteboard/internal/manager/ main/java/org/apache/felix/http/whiteboard/internal/tracker/ test/java/org/apache/felix/http/whiteboard/internal/man...
Date Thu, 11 Sep 2014 21:24:30 GMT
Author: cziegeler
Date: Thu Sep 11 21:24:30 2014
New Revision: 1624398

URL: http://svn.apache.org/r1624398
Log:
FELIX-4547 : Implement the missing resources registration

Added:
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ResourceTracker.java
  (with props)
Modified:
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManager.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ResourceMapping.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpContextTracker.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpServiceTracker.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletContextHelperTracker.java
    felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
    felix/sandbox/http-rfc189/whiteboard/src/test/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManagerTest.java

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/AbstractMapping.java
Thu Sep 11 21:24:30 2014
@@ -18,12 +18,9 @@ package org.apache.felix.http.whiteboard
 
 import java.util.Hashtable;
 
-import javax.servlet.ServletException;
-
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
 
 abstract class AbstractMapping
 {
@@ -32,7 +29,7 @@ abstract class AbstractMapping
     private final Hashtable<String, String> initParams;
     private boolean registered;
 
-    protected AbstractMapping(Bundle bundle)
+    protected AbstractMapping(final Bundle bundle)
     {
         this.bundle = bundle;
         this.context = null;
@@ -70,8 +67,8 @@ abstract class AbstractMapping
         this.registered = registered;
     }
 
-    public abstract void register(HttpService httpService) throws ServletException, NamespaceException;
+    public abstract void register(HttpService httpService);
 
-    public abstract void unregister(HttpService httpService) throws ServletException;
+    public abstract void unregister(HttpService httpService);
 
 }

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManager.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManager.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManager.java
Thu Sep 11 21:24:30 2014
@@ -24,7 +24,6 @@ import java.util.Set;
 import javax.servlet.DispatcherType;
 import javax.servlet.Filter;
 import javax.servlet.Servlet;
-import javax.servlet.ServletException;
 
 import org.apache.felix.http.api.ExtHttpService;
 import org.apache.felix.http.api.FilterInfo;
@@ -36,27 +35,31 @@ import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
 import org.osgi.service.http.context.ServletContextHelper;
+import org.osgi.service.http.runtime.dto.ResourceDTO;
 import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 
 @SuppressWarnings({ "deprecation" })
 public final class ExtenderManager
 {
-    private final HashMap<ServiceReference, AbstractMapping> mapping;
+    static final String TYPE_FILTER = "f";
+    static final String TYPE_SERVLET = "s";
+    static final String TYPE_RESOURCE = "r";
+
+    private final Map<String, AbstractMapping> mapping;
     private final HttpContextManager contextManager;
 
     private volatile HttpService httpService;
 
     public ExtenderManager()
     {
-        this.mapping = new HashMap<ServiceReference, AbstractMapping>();
+        this.mapping = new HashMap<String, AbstractMapping>();
         this.contextManager = new HttpContextManager();
     }
 
     static boolean isEmpty(final String value)
     {
-        return value == null || "".equals(value);
+        return value == null || value.length() == 0;
     }
 
     static boolean isEmpty(final String[] value)
@@ -164,7 +167,7 @@ public final class ExtenderManager
         }
     }
 
-    public void add(HttpContext service, ServiceReference ref) throws ServletException, NamespaceException
+    public void add(HttpContext service, ServiceReference ref)
     {
         String contextId = getStringProperty(ref, org.apache.felix.http.whiteboard.HttpWhiteboardConstants.CONTEXT_ID);
         if (!isEmpty(contextId))
@@ -183,7 +186,7 @@ public final class ExtenderManager
         }
     }
 
-    public void remove(HttpContext service) throws ServletException
+    public void remove(HttpContext service)
     {
         Collection<AbstractMapping> mappings = this.contextManager.removeHttpContext(service);
         if (mappings != null)
@@ -195,7 +198,7 @@ public final class ExtenderManager
         }
     }
 
-    public void add(ServletContextHelper service, ServiceReference ref) throws ServletException,
NamespaceException
+    public void add(ServletContextHelper service, ServiceReference ref)
     {
         String name = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME);
         String path = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH);
@@ -214,7 +217,42 @@ public final class ExtenderManager
         }
     }
 
-    public void remove(ServletContextHelper service) throws ServletException
+    public void addResource(final ServiceReference ref)
+    {
+        final String[] pattern = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN);
+        final String prefix = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX);
+
+        if (!isEmpty(pattern))
+        {
+            if ( !isEmpty(prefix))
+            {
+                for(final String p : pattern)
+                {
+                    // TODO : check if p is empty - and then log?
+                    final ResourceDTO resourceDTO = new ResourceDTO();
+                    resourceDTO.patterns = new String[] {p};
+                    resourceDTO.prefix = prefix;
+                    final ResourceMapping mapping = new ResourceMapping(ref.getBundle(),
resourceDTO);
+                    this.addMapping(TYPE_RESOURCE, ref, mapping);
+                }
+            }
+            else
+            {
+                SystemLogger.debug("Ignoring Resource Service " + ref + ", " + HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX
+ " is missing or empty");
+            }
+        }
+        else
+        {
+            SystemLogger.debug("Ignoring Resource Service " + ref + ", " + HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN
+ " is missing or empty");
+        }
+    }
+
+    public void removeResource(final ServiceReference ref)
+    {
+        this.removeMapping(TYPE_RESOURCE, ref);
+    }
+
+    public void remove(ServletContextHelper service)
     {
         Collection<AbstractMapping> mappings = this.contextManager.removeContextHelper(service);
         if (mappings != null)
@@ -251,7 +289,7 @@ public final class ExtenderManager
         this.contextManager.ungetHttpContext(bundle, contextId, mapping);
     }
 
-    public void add(Filter service, ServiceReference ref) throws ServletException, NamespaceException
+    public void add(Filter service, ServiceReference ref)
     {
         FilterInfo filterInfo = new FilterInfo();
         filterInfo.name = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME);
@@ -289,10 +327,10 @@ public final class ExtenderManager
         FilterMapping mapping = new FilterMapping(ref.getBundle(), service, filterInfo);
         filterInfo.context = getHttpContext(mapping, ref); // XXX
         addInitParams(ref, mapping);
-        addMapping(ref, mapping);
+        addMapping(TYPE_FILTER, ref, mapping);
     }
 
-    public void add(Servlet service, ServiceReference ref) throws ServletException, NamespaceException
+    public void add(Servlet service, ServiceReference ref)
     {
         ServletInfo servletInfo = new ServletInfo();
         servletInfo.name = getStringProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME);
@@ -330,15 +368,21 @@ public final class ExtenderManager
         ServletMapping mapping = new ServletMapping(ref.getBundle(), service, servletInfo);
         servletInfo.context = getHttpContext(mapping, ref); // XXX
         addInitParams(ref, mapping);
-        addMapping(ref, mapping);
+        addMapping(TYPE_SERVLET, ref, mapping);
+    }
+
+    public void removeFilter(ServiceReference ref)
+    {
+        removeMapping(TYPE_FILTER, ref);
     }
 
-    public void remove(ServiceReference ref) throws ServletException
+    public void removeServlet(ServiceReference ref)
     {
-        removeMapping(ref);
+        removeMapping(TYPE_SERVLET, ref);
     }
 
-    public synchronized void setHttpService(HttpService service) throws ServletException,
NamespaceException
+
+    public synchronized void setHttpService(HttpService service)
     {
         this.httpService = service;
         if (this.httpService instanceof ExtHttpService)
@@ -352,22 +396,23 @@ public final class ExtenderManager
         registerAll();
     }
 
-    public synchronized void unsetHttpService() throws ServletException
+    public synchronized void unsetHttpService()
     {
         unregisterAll();
         this.httpService = null;
     }
 
-    public synchronized void unregisterAll() throws ServletException
+    public synchronized void unregisterAll()
     {
-        Collection<AbstractMapping> mappings = null;
+        AbstractMapping[] mappings = null;
         HttpService service;
         synchronized (this)
         {
             service = this.httpService;
             if (service != null)
             {
-                mappings = this.mapping.values();
+                Collection<AbstractMapping> values = this.mapping.values();
+                mappings = values.toArray(new AbstractMapping[values.size()]);
             }
         }
         if (mappings != null)
@@ -379,16 +424,17 @@ public final class ExtenderManager
         }
     }
 
-    private synchronized void registerAll() throws ServletException, NamespaceException
+    private synchronized void registerAll()
     {
-        Collection<AbstractMapping> mappings = null;
+        AbstractMapping[] mappings = null;
         HttpService service;
         synchronized (this)
         {
             service = this.httpService;
             if (service != null)
             {
-                mappings = this.mapping.values();
+                Collection<AbstractMapping> values = this.mapping.values();
+                mappings = values.toArray(new AbstractMapping[values.size()]);
             }
         }
         if (mappings != null)
@@ -400,15 +446,15 @@ public final class ExtenderManager
         }
     }
 
-    private synchronized void addMapping(ServiceReference ref, AbstractMapping mapping) throws
ServletException, NamespaceException
+    private synchronized void addMapping(final String servType, ServiceReference ref, AbstractMapping
mapping)
     {
-        this.mapping.put(ref, mapping);
-        registerMapping(mapping);
+        this.mapping.put(ref.getProperty(Constants.SERVICE_ID).toString().concat(servType),
mapping);
+        this.registerMapping(mapping);
     }
 
-    private synchronized void removeMapping(ServiceReference ref) throws ServletException
+    private synchronized void removeMapping(final String servType, ServiceReference ref)
     {
-        AbstractMapping mapping = this.mapping.remove(ref);
+        AbstractMapping mapping = this.mapping.remove(ref.getProperty(Constants.SERVICE_ID).toString().concat(servType));
         if (mapping != null)
         {
             ungetHttpContext(mapping, ref);
@@ -416,7 +462,7 @@ public final class ExtenderManager
         }
     }
 
-    private void registerMapping(AbstractMapping mapping) throws ServletException, NamespaceException
+    private void registerMapping(AbstractMapping mapping)
     {
         HttpService httpService = this.httpService;
         if (httpService != null)
@@ -425,7 +471,7 @@ public final class ExtenderManager
         }
     }
 
-    private void unregisterMapping(AbstractMapping mapping) throws ServletException
+    private void unregisterMapping(AbstractMapping mapping)
     {
         HttpService httpService = this.httpService;
         if (httpService != null)

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
Thu Sep 11 21:24:30 2014
@@ -17,10 +17,10 @@
 package org.apache.felix.http.whiteboard.internal.manager;
 
 import javax.servlet.Filter;
-import javax.servlet.ServletException;
 
 import org.apache.felix.http.api.ExtHttpService;
 import org.apache.felix.http.api.FilterInfo;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.HttpService;
 
@@ -37,7 +37,7 @@ public final class FilterMapping extends
     }
 
     @Override
-    public void register(HttpService httpService) throws ServletException
+    public void register(HttpService httpService)
     {
         if (!isRegistered() && (httpService instanceof ExtHttpService) &&
getContext() != null)
         {
@@ -46,7 +46,7 @@ public final class FilterMapping extends
     }
 
     @Override
-    public void unregister(HttpService httpService) throws ServletException
+    public void unregister(HttpService httpService)
     {
         if (isRegistered() && (httpService instanceof ExtHttpService))
         {
@@ -59,11 +59,18 @@ public final class FilterMapping extends
         return filter;
     }
 
-    private void register(ExtHttpService httpService) throws ServletException
+    private void register(ExtHttpService httpService)
     {
         this.filterInfo.context = getContext(); // XXX
-        httpService.registerFilter(this.filter, this.filterInfo);
-        setRegistered(true);
+        try
+        {
+            httpService.registerFilter(this.filter, this.filterInfo);
+            setRegistered(true);
+        }
+        catch (Exception e)
+        {
+            SystemLogger.error("Failed to register filter", e);
+        }
     }
 
     private void unregister(ExtHttpService httpService)

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ResourceMapping.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ResourceMapping.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ResourceMapping.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ResourceMapping.java
Thu Sep 11 21:24:30 2014
@@ -18,24 +18,42 @@ package org.apache.felix.http.whiteboard
 
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+import org.osgi.service.http.runtime.dto.ResourceDTO;
 
 public final class ResourceMapping extends AbstractMapping
 {
-    public ResourceMapping(Bundle bundle)
+    private final ResourceDTO dto;
+
+    public ResourceMapping(final Bundle bundle, final ResourceDTO resourceDTO)
     {
         super(bundle);
+        this.dto = resourceDTO;
     }
 
     @Override
-    public void register(HttpService httpService)
+    public void register(final HttpService httpService)
     {
-        // TODO Auto-generated method stub
+        if (!isRegistered() && getContext() != null)
+        {
+            try {
+                httpService.registerResources(this.dto.patterns[0], this.dto.prefix, this.getContext());
+                this.setRegistered(true);
+            }
+            catch (final NamespaceException e)
+            {
+                // TODO Handle exception
+                e.printStackTrace();
+            }
+        }
     }
 
     @Override
-    public void unregister(HttpService httpService)
+    public void unregister(final HttpService httpService)
     {
-        // TODO Auto-generated method stub
+        if (isRegistered())
+        {
+            httpService.unregister(this.dto.patterns[0]);
+        }
     }
-
 }

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java
Thu Sep 11 21:24:30 2014
@@ -17,13 +17,12 @@
 package org.apache.felix.http.whiteboard.internal.manager;
 
 import javax.servlet.Servlet;
-import javax.servlet.ServletException;
 
 import org.apache.felix.http.api.ExtHttpService;
 import org.apache.felix.http.api.ServletInfo;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
 
 public final class ServletMapping extends AbstractMapping
 {
@@ -38,12 +37,20 @@ public final class ServletMapping extend
     }
 
     @Override
-    public void register(HttpService httpService) throws ServletException, NamespaceException
+    public void register(HttpService httpService)
     {
         if (!isRegistered() && (httpService instanceof ExtHttpService) &&
getContext() != null)
         {
             this.servletInfo.context = getContext(); // XXX
-            ((ExtHttpService) httpService).registerServlet(this.servlet, this.servletInfo);
+            try
+            {
+                ((ExtHttpService) httpService).registerServlet(this.servlet, this.servletInfo);
+                this.setRegistered(true);
+            }
+            catch (Exception e)
+            {
+                SystemLogger.error("Failed to register servlet", e);
+            }
             setRegistered(true);
         }
     }

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/AbstractTracker.java
Thu Sep 11 21:24:30 2014
@@ -16,70 +16,50 @@
  */
 package org.apache.felix.http.whiteboard.internal.tracker;
 
-import javax.servlet.ServletException;
-
-import org.apache.felix.http.base.internal.logger.SystemLogger;
-import org.osgi.service.http.NamespaceException;
-import org.osgi.util.tracker.ServiceTracker;
 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(final BundleContext context, final Class<T> clz)
     {
         super(context, clz.getName(), null);
     }
 
+    public AbstractTracker(final BundleContext context, final Filter filter)
+    {
+        super(context, filter, null);
+    }
+
     @Override
     @SuppressWarnings("unchecked")
-    public final Object addingService(ServiceReference ref)
+    public final Object addingService(final ServiceReference ref)
     {
-        try
-        {
-            T service = (T) super.addingService(ref);
-            added(service, ref);
-            return service;
-        }
-        catch (Exception e)
-        {
-            SystemLogger.warning("Failed to add service!", e); // XXX log more information!
-        }
-        return null;
+        T service = (T) super.addingService(ref);
+        added(service, ref);
+        return service;
     }
 
     @Override
     @SuppressWarnings("unchecked")
-    public final void modifiedService(ServiceReference ref, Object service)
+    public final void modifiedService(final ServiceReference ref, final Object service)
     {
-        try
-        {
-            modified( (T)service, ref);
-        }
-        catch (Exception e)
-        {
-            SystemLogger.warning("Failed to modify service", e); // XXX log more information!
-        }
+        modified( (T)service, ref);
     }
 
     @Override
     @SuppressWarnings("unchecked")
-    public final void removedService(ServiceReference ref, Object service)
+    public final void removedService(final ServiceReference ref, final Object service)
     {
-        try
-        {
-            super.removedService(ref, service);
-            removed((T) service, ref);
-        }
-        catch (Exception e)
-        {
-            SystemLogger.warning("Failed to remove service!", e); // XXX log more information!
-        }
+        super.removedService(ref, service);
+        removed((T) service, ref);
     }
 
-    protected abstract void modified(T service, ServiceReference ref) throws ServletException,
NamespaceException;
+    protected abstract void modified(T service, ServiceReference ref);
 
-    protected abstract void added(T service, ServiceReference ref) throws ServletException,
NamespaceException;
+    protected abstract void added(T service, ServiceReference ref);
 
-    protected abstract void removed(T service, ServiceReference ref) throws ServletException;
+    protected abstract void removed(T service, ServiceReference ref);
 }

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/FilterTracker.java
Thu Sep 11 21:24:30 2014
@@ -17,12 +17,10 @@
 package org.apache.felix.http.whiteboard.internal.tracker;
 
 import javax.servlet.Filter;
-import javax.servlet.ServletException;
 
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.NamespaceException;
 
 public final class FilterTracker extends AbstractTracker<Filter>
 {
@@ -34,19 +32,22 @@ public final class FilterTracker extends
         this.manager = manager;
     }
 
-    protected void added(Filter service, ServiceReference ref) throws ServletException, NamespaceException
+    @Override
+    protected void added(Filter service, ServiceReference ref)
     {
         this.manager.add(service, ref);
     }
 
-    protected void modified(Filter service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void modified(Filter service, ServiceReference ref)
     {
         removed(service, ref);
         added(service, ref);
     }
 
-    protected void removed(Filter service, ServiceReference ref) throws ServletException
+    @Override
+    protected void removed(Filter service, ServiceReference ref)
     {
-        this.manager.remove(ref);
+        this.manager.removeFilter(ref);
     }
 }

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpContextTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpContextTracker.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpContextTracker.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpContextTracker.java
Thu Sep 11 21:24:30 2014
@@ -16,13 +16,10 @@
  */
 package org.apache.felix.http.whiteboard.internal.tracker;
 
-import javax.servlet.ServletException;
-
+import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.HttpContext;
-import org.osgi.service.http.NamespaceException;
-import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 
 public final class HttpContextTracker extends AbstractTracker<HttpContext>
 {
@@ -34,18 +31,21 @@ public final class HttpContextTracker ex
         this.manager = manager;
     }
 
-    protected void added(HttpContext service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void added(HttpContext service, ServiceReference ref)
     {
         this.manager.add(service, ref);
     }
 
-    protected void modified(HttpContext service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void modified(HttpContext service, ServiceReference ref)
     {
         removed(service, ref);
         added(service, ref);
     }
 
-    protected void removed(HttpContext service, ServiceReference ref) throws ServletException
+    @Override
+    protected void removed(HttpContext service, ServiceReference ref)
     {
         this.manager.remove(service);
     }

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpServiceTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpServiceTracker.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpServiceTracker.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/HttpServiceTracker.java
Thu Sep 11 21:24:30 2014
@@ -16,13 +16,10 @@
  */
 package org.apache.felix.http.whiteboard.internal.tracker;
 
-import javax.servlet.ServletException;
-
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
 
 public final class HttpServiceTracker extends AbstractTracker<HttpService>
 {
@@ -34,17 +31,20 @@ public final class HttpServiceTracker ex
         this.manager = manager;
     }
 
-    protected void added(HttpService service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void added(HttpService service, ServiceReference ref)
     {
         this.manager.setHttpService(service);
     }
 
-    protected void modified(HttpService service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void modified(HttpService service, ServiceReference ref)
     {
         // Do nothing
     }
 
-    protected void removed(HttpService service, ServiceReference ref) throws ServletException
+    @Override
+    protected void removed(HttpService service, ServiceReference ref)
     {
         this.manager.unsetHttpService();
     }

Added: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ResourceTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ResourceTracker.java?rev=1624398&view=auto
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ResourceTracker.java
(added)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ResourceTracker.java
Thu Sep 11 21:24:30 2014
@@ -0,0 +1,69 @@
+/*
+ * 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.whiteboard.internal.tracker;
+
+import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+
+public final class ResourceTracker extends AbstractTracker<Object>
+{
+    private final ExtenderManager manager;
+
+    private static Filter createFilter(final BundleContext btx)
+    {
+        try
+        {
+            return btx.createFilter(String.format("(&(%s=*)(%s=*))",
+                    HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PATTERN,
+                    HttpWhiteboardConstants.HTTP_WHITEBOARD_RESOURCE_PREFIX));
+        }
+        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 ResourceTracker(final BundleContext context, final ExtenderManager manager)
+    {
+        super(context, createFilter(context));
+        this.manager = manager;
+    }
+
+    @Override
+    protected void added(final Object service, final ServiceReference ref)
+    {
+        this.manager.addResource(ref);
+    }
+
+    @Override
+    protected void modified(final Object service, final ServiceReference ref)
+    {
+        removed(service, ref);
+        added(service, ref);
+    }
+
+    @Override
+    protected void removed(final Object service, final ServiceReference ref)
+    {
+        this.manager.removeResource(ref);
+    }
+}

Propchange: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ResourceTracker.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ResourceTracker.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletContextHelperTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletContextHelperTracker.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletContextHelperTracker.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletContextHelperTracker.java
Thu Sep 11 21:24:30 2014
@@ -19,12 +19,8 @@ package org.apache.felix.http.whiteboard
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.NamespaceException;
 import org.osgi.service.http.context.ServletContextHelper;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-
 public final class ServletContextHelperTracker extends AbstractTracker<ServletContextHelper>
 {
     private final ExtenderManager manager;
@@ -35,18 +31,21 @@ public final class ServletContextHelperT
         this.manager = manager;
     }
 
-    protected void added(ServletContextHelper service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void added(ServletContextHelper service, ServiceReference ref)
     {
         this.manager.add(service, ref);
     }
 
-    protected void modified(ServletContextHelper service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void modified(ServletContextHelper service, ServiceReference ref)
     {
         removed(service, ref);
         added(service, ref);
     }
 
-    protected void removed(ServletContextHelper service, ServiceReference ref) throws ServletException
+    @Override
+    protected void removed(ServletContextHelper service, ServiceReference ref)
     {
         this.manager.remove(service);
     }

Modified: felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
URL: http://svn.apache.org/viewvc/felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java?rev=1624398&r1=1624397&r2=1624398&view=diff
==============================================================================
--- felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
(original)
+++ felix/sandbox/http-rfc189/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/tracker/ServletTracker.java
Thu Sep 11 21:24:30 2014
@@ -16,13 +16,11 @@
  */
 package org.apache.felix.http.whiteboard.internal.tracker;
 
+import javax.servlet.Servlet;
+
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.NamespaceException;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
 
 public final class ServletTracker extends AbstractTracker<Servlet>
 {
@@ -34,19 +32,22 @@ public final class ServletTracker extend
         this.manager = manager;
     }
 
-    protected void added(Servlet service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void added(Servlet service, ServiceReference ref)
     {
         this.manager.add(service, ref);
     }
 
-    protected void modified(Servlet service, ServiceReference ref) throws ServletException,
NamespaceException
+    @Override
+    protected void modified(Servlet service, ServiceReference ref)
     {
         removed(service, ref);
         added(service, ref);
     }
 
-    protected void removed(Servlet service, ServiceReference ref) throws ServletException
+    @Override
+    protected void removed(Servlet service, ServiceReference ref)
     {
-        this.manager.remove(ref);
+        this.manager.removeServlet(ref);
     }
 }



Mime
View raw message