FELIX-4060 : Implement HTTP Whiteboard Service (RFC-189)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1680858 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java
index e30517a..008f179 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/AbstractInfo.java
@@ -23,9 +23,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceObjects;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 
@@ -88,7 +86,7 @@
             int reverseOrder = ( this.serviceId >= 0 && other.serviceId >= 0 ) ? 1 : -1;
             return reverseOrder * Long.compare(this.serviceId, other.serviceId);
         }
-        
+
         return Integer.compare(other.ranking, this.ranking);
     }
 
@@ -203,31 +201,6 @@
         return this.serviceReference;
     }
 
-    public T getService(final Bundle bundle)
-    {
-        if (this.serviceReference != null)
-        {
-            final ServiceObjects<T> so = bundle.getBundleContext().getServiceObjects(this.serviceReference);
-            if (so != null)
-            {
-                return so.getService();
-            }
-        }
-        return null;
-    }
-
-    public void ungetService(final Bundle bundle, final T service)
-    {
-        if (this.serviceReference != null)
-        {
-            final ServiceObjects<T> so = bundle.getBundleContext().getServiceObjects(this.serviceReference);
-            if (so != null)
-            {
-                so.ungetService(service);
-            }
-        }
-    }
-
     @Override
     public int hashCode()
     {
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ListenerInfo.java b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ListenerInfo.java
index 213e685..33647ab 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ListenerInfo.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ListenerInfo.java
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.http.base.internal.runtime;
 
+import org.osgi.framework.Bundle;
+import org.osgi.framework.ServiceObjects;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 
@@ -42,4 +44,30 @@
     {
         return super.isValid() && "true".equalsIgnoreCase(this.enabled);
     }
+
+
+    public T getService(final Bundle bundle)
+    {
+        if (this.getServiceReference() != null)
+        {
+            final ServiceObjects<T> so = bundle.getBundleContext().getServiceObjects(this.getServiceReference());
+            if (so != null)
+            {
+                return so.getService();
+            }
+        }
+        return null;
+    }
+
+    public void ungetService(final Bundle bundle, final T service)
+    {
+        if (this.getServiceReference() != null)
+        {
+            final ServiceObjects<T> so = bundle.getBundleContext().getServiceObjects(this.getServiceReference());
+            if (so != null)
+            {
+                so.ungetService(service);
+            }
+        }
+    }
 }
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
index 0bb70cf..88a3880 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
@@ -24,7 +24,6 @@
 import javax.servlet.Servlet;
 
 import org.osgi.dto.DTO;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.runtime.dto.ServletDTO;
 import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
@@ -191,31 +190,4 @@
     {
         return prefix;
     }
-
-    @Override
-    public ServiceReference<Servlet> getServiceReference()
-    {
-        // TODO This method returns a ServiceReference<Object> in case of a resource
-        return super.getServiceReference();
-    }
-
-    @Override
-    public Servlet getService(Bundle bundle)
-    {
-        if (isResource)
-        {
-            throw new UnsupportedOperationException();
-        };
-        return super.getService(bundle);
-    }
-
-    @Override
-    public void ungetService(Bundle bundle, Servlet service)
-    {
-        if (isResource)
-        {
-            throw new UnsupportedOperationException();
-        };
-        super.ungetService(bundle, service);
-    }
 }
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java
index a523446..990b8dd 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceInfo.java
@@ -19,6 +19,8 @@
 package org.apache.felix.http.base.internal.runtime;
 
 import org.apache.felix.http.base.internal.util.InternalIdFactory;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Filter;
 import org.osgi.framework.InvalidSyntaxException;
 import org.osgi.framework.ServiceReference;
@@ -51,7 +53,15 @@
         Filter f = null;
         try
         {
-            f = ref.getBundle().getBundleContext().createFilter(this.contextSelection);
+            final Bundle bundle = ref.getBundle();
+            if ( bundle != null )
+            {
+                final BundleContext ctx = bundle.getBundleContext();
+                if ( ctx != null )
+                {
+                    f = ctx.createFilter(this.contextSelection);
+                }
+            }
         }
         catch ( final InvalidSyntaxException ise)
         {