felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1656203 - in /felix/trunk/http/base: ./ src/main/java/org/apache/felix/http/base/internal/ src/main/java/org/apache/felix/http/base/internal/runtime/ src/main/java/org/apache/felix/http/base/internal/service/ src/main/java/org/apache/felix...
Date Sat, 31 Jan 2015 15:21:10 GMT
Author: cziegeler
Date: Sat Jan 31 15:21:09 2015
New Revision: 1656203

URL: http://svn.apache.org/r1656203
Log:
[RFC189] Refactoring - keep old http service as is and move new whiteboard handling into a new component

Added:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/InternalHttpService.java   (with props)
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java   (with props)
Modified:
    felix/trunk/http/base/pom.xml
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.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/whiteboard/ExtenderManager.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ServletContextHelperManager.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java

Modified: felix/trunk/http/base/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/pom.xml?rev=1656203&r1=1656202&r2=1656203&view=diff
==============================================================================
--- felix/trunk/http/base/pom.xml (original)
+++ felix/trunk/http/base/pom.xml Sat Jan 31 15:21:09 2015
@@ -78,7 +78,12 @@
             <groupId>${project.groupId}</groupId>
             <artifactId>org.apache.felix.http.api</artifactId>
             <version>3.0.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.google.code.findbugs</groupId>
+            <artifactId>jsr305</artifactId>
+            <version>3.0.0</version>
         </dependency>
     </dependencies>
-
 </project>

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java?rev=1656203&r1=1656202&r2=1656203&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/HttpServiceController.java Sat Jan 31 15:21:09 2015
@@ -30,8 +30,8 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.listener.ServletRequestAttributeListenerManager;
 import org.apache.felix.http.base.internal.listener.ServletRequestListenerManager;
 import org.apache.felix.http.base.internal.service.HttpServiceFactory;
-import org.apache.felix.http.base.internal.service.HttpServiceImpl;
 import org.apache.felix.http.base.internal.service.HttpServiceRuntimeImpl;
+import org.apache.felix.http.base.internal.service.InternalHttpService;
 import org.apache.felix.http.base.internal.whiteboard.ExtenderManager;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
@@ -144,7 +144,7 @@ public final class HttpServiceController
         HttpServiceFactory factory = new HttpServiceFactory(servletContext, this.registry, this.contextAttributeListener, this.sharedContextAttributes);
 
         this.serviceReg = this.bundleContext.registerService(ifaces, factory, this.serviceProps);
-        this.manager = new ExtenderManager((HttpServiceImpl)factory.getService(this.bundleContext.getBundle(), this.serviceReg), this.bundleContext);
+        this.manager = new ExtenderManager(new InternalHttpService(this.bundleContext, servletContext, this.registry), this.bundleContext);
 
         this.runtimeReg = this.bundleContext.registerService(HttpServiceRuntime.class, new HttpServiceRuntimeImpl(), null);
     }

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=1656203&r1=1656202&r2=1656203&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 15:21:09 2015
@@ -24,7 +24,6 @@ import javax.servlet.Servlet;
 
 import org.osgi.dto.DTO;
 import org.osgi.framework.ServiceReference;
-import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.runtime.dto.ServletDTO;
 import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 
@@ -72,10 +71,6 @@ public final class ServletInfo extends A
      */
     private final Map<String, String> initParams;
 
-    private final HttpContext context;
-
-    private final Servlet servlet;
-
     public ServletInfo(final ServiceReference<Servlet> ref)
     {
         super(ref);
@@ -84,8 +79,6 @@ public final class ServletInfo extends A
         this.patterns = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN);
         this.asyncSupported = getBooleanProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED);
         this.initParams = getInitParams(ref, SERVLET_INIT_PREFIX);
-        this.context = null;
-        this.servlet = null;
     }
 
     @SuppressWarnings("unchecked")
@@ -97,8 +90,6 @@ public final class ServletInfo extends A
         this.errorPage = null;
         this.asyncSupported = false;
         this.initParams = null;
-        this.context = null;
-        this.servlet = servlet;
     }
 
     private static ServiceReference getRef(final ServiceReference ref)
@@ -112,9 +103,7 @@ public final class ServletInfo extends A
     public ServletInfo(final String name,
             final String pattern,
             final int serviceRanking,
-            final Map<String, String> initParams,
-            final Servlet servlet,
-            final HttpContext context)
+            final Map<String, String> initParams)
     {
         super(serviceRanking);
         this.name = name;
@@ -122,8 +111,6 @@ public final class ServletInfo extends A
         this.initParams = initParams;
         this.asyncSupported = false;
         this.errorPage = null;
-        this.servlet = servlet;
-        this.context = context;
     }
 
     @Override
@@ -156,14 +143,4 @@ public final class ServletInfo extends A
     {
         return initParams;
     }
-
-    public HttpContext getContext()
-    {
-        return this.context;
-    }
-
-    public Servlet getServlet()
-    {
-        return this.servlet;
-    }
 }

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=1656203&r1=1656202&r2=1656203&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 15:21:09 2015
@@ -35,15 +35,11 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.handler.HandlerRegistry;
 import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
-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.whiteboard.HttpContextBridge;
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.NamespaceException;
-import org.osgi.service.http.context.ServletContextHelper;
 
 public final class HttpServiceImpl implements ExtHttpService
 {
@@ -62,32 +58,6 @@ public final class HttpServiceImpl imple
         this.contextManager = new ServletContextManager(this.bundle, context, servletAttributeListener, sharedContextAttributes);
     }
 
-    static Map<String, String> convertToMap(Dictionary dict)
-    {
-        Map<String, String> result = new HashMap<String, String>();
-        if (dict != null)
-        {
-            Enumeration keyEnum = dict.keys();
-            while (keyEnum.hasMoreElements())
-            {
-                String key = String.valueOf(keyEnum.nextElement());
-                Object value = dict.get(key);
-                result.put(key, value == null ? null : String.valueOf(value));
-            }
-        }
-        return result;
-    }
-
-    static <T> boolean isEmpty(T[] array)
-    {
-        return array == null || array.length < 1;
-    }
-
-    static boolean isEmpty(String str)
-    {
-        return str == null || "".equals(str.trim());
-    }
-
     @Override
     public HttpContext createDefaultHttpContext()
     {
@@ -95,38 +65,6 @@ public final class HttpServiceImpl imple
     }
 
     /**
-     * Register a filter
-     */
-    public void registerFilter(final ServletContextHelper context,
-            final ContextInfo contextInfo,
-            final FilterInfo filterInfo)
-    {
-        final ExtServletContext httpContext;
-        if ( context != null )
-        {
-            httpContext = getServletContext(new HttpContextBridge(context));
-        }
-        else
-        {
-            httpContext = getServletContext(filterInfo.getContext());
-        }
-        Filter filter = filterInfo.getFilter();
-        if ( filter == null )
-        {
-            filter = this.bundle.getBundleContext().getServiceObjects(filterInfo.getServiceReference()).getService();
-            // TODO create failure DTO if null
-        }
-
-        FilterHandler handler = new FilterHandler(contextInfo, httpContext, filter, filterInfo);
-        try {
-            this.handlerRegistry.addFilter(handler);
-        } catch (ServletException e) {
-            // TODO create failure DTO
-        }
-        this.localFilters.add(filter);
-    }
-
-    /**
      * @see org.apache.felix.http.api.ExtHttpService#registerFilter(javax.servlet.Filter, java.lang.String, java.util.Dictionary, int, org.osgi.service.http.HttpContext)
      */
     @Override
@@ -153,12 +91,21 @@ public final class HttpServiceImpl imple
             }
         }
 
-        final FilterInfo info = new FilterInfo(null, pattern, ranking, paramMap, filter, context);
-        if ( !info.isValid() )
+        final FilterInfo filterInfo = new FilterInfo(null, pattern, ranking, paramMap, filter, context);
+        if ( !filterInfo.isValid() )
         {
             throw new ServletException("Invalid registration information for filter.");
         }
-        this.registerFilter(null, null, info);
+
+        final ExtServletContext httpContext = getServletContext(context);
+
+        FilterHandler handler = new FilterHandler(null, httpContext, filter, filterInfo);
+        try {
+            this.handlerRegistry.addFilter(handler);
+        } catch (ServletException e) {
+            // TODO create failure DTO
+        }
+        this.localFilters.add(filter);
     }
 
     @Override
@@ -181,80 +128,6 @@ public final class HttpServiceImpl imple
     }
 
     /**
-     * Register a servlet with a {@link ServletContextHelper}.
-     * The prefix is the path where the servlet context helper is mounted.
-     */
-    public void registerServlet(final ServletContextHelper context,
-    		final ContextInfo contextInfo,
-    		final ServletInfo servletInfo)
-    {
-        if (servletInfo == null)
-        {
-            throw new IllegalArgumentException("ServletInfo cannot be null!");
-        }
-        if (isEmpty(servletInfo.getPatterns()) && isEmpty(servletInfo.getErrorPage()))
-        {
-            throw new IllegalArgumentException("ServletInfo must at least have one pattern or error page!");
-        }
-
-        final ExtServletContext httpContext;
-        if ( context != null )
-        {
-        	httpContext = getServletContext(new HttpContextBridge(context));
-        }
-        else
-        {
-        	httpContext = getServletContext(servletInfo.getContext());
-        }
-        Servlet servlet = servletInfo.getServlet();
-        if ( servlet == null )
-        {
-            servlet = this.bundle.getBundleContext().getServiceObjects(servletInfo.getServiceReference()).getService();
-            // TODO create failure DTO if null
-        }
-
-        final ServletHandler handler = new ServletHandler(contextInfo,
-                httpContext,
-                servletInfo,
-                servlet);
-        try {
-            this.handlerRegistry.addServlet(contextInfo, handler);
-        } catch (ServletException e) {
-            // TODO create failure DTO
-        } catch (NamespaceException e) {
-            // TODO create failure DTO
-        }
-
-        this.localServlets.add(servlet);
-    }
-
-    public void unregisterServlet(final ContextInfo contextInfo, final ServletInfo servletInfo)
-    {
-        if (servletInfo == null)
-        {
-            throw new IllegalArgumentException("ServletInfo cannot be null!");
-        }
-        final Servlet servlet = this.handlerRegistry.removeServlet(contextInfo, servletInfo, true);
-        if ( servlet != null )
-        {
-            this.localServlets.remove(servlet);
-        }
-    }
-
-    public void unregisterFilter(final ContextInfo contextInfo, final FilterInfo filterInfo)
-    {
-        if (filterInfo == null)
-        {
-            throw new IllegalArgumentException("FilterInfo cannot be null!");
-        }
-        final Filter instance = this.handlerRegistry.removeFilter(filterInfo, true);
-        if ( instance != null )
-        {
-            this.localFilters.remove(instance);
-        }
-    }
-
-    /**
      * @see org.osgi.service.http.HttpService#registerServlet(java.lang.String, javax.servlet.Servlet, java.util.Dictionary, org.osgi.service.http.HttpContext)
      */
     @Override
@@ -286,11 +159,28 @@ public final class HttpServiceImpl imple
             }
         }
 
-        final ServletInfo info = new ServletInfo(null, alias, 0, paramMap, servlet, context);
+        final ServletInfo servletInfo = new ServletInfo(null, alias, 0, paramMap);
 
-        this.registerServlet(null, null, info);
+        final ExtServletContext httpContext = getServletContext(context);
+
+        final ServletHandler handler = new ServletHandler(null,
+                httpContext,
+                servletInfo,
+                servlet);
+        try {
+            this.handlerRegistry.addServlet(null, handler);
+        } catch (ServletException e) {
+            // TODO create failure DTO
+        } catch (NamespaceException e) {
+            // TODO create failure DTO
+        }
+
+        this.localServlets.add(servlet);
     }
 
+    /**
+     * @see org.osgi.service.http.HttpService#unregister(java.lang.String)
+     */
     @Override
     public void unregister(String alias)
     {
@@ -310,32 +200,6 @@ public final class HttpServiceImpl imple
         unregisterServlet(servlet);
     }
 
-    /**
-     * Register a resource with a {@link ServletContextHelper}.
-     */
-    public void registerResource(final ServletContextHelper context,
-            final ContextInfo contextInfo,
-            final ResourceInfo resourceInfo)
-    {
-        if (resourceInfo == null)
-        {
-            throw new IllegalArgumentException("ResourceInfo cannot be null!");
-        }
-        final ServletInfo servletInfo = new ServletInfo(resourceInfo, new ResourceServlet(resourceInfo.getPrefix()));
-
-        this.registerServlet(context, contextInfo, servletInfo);
-    }
-
-    public void unregisterResource(final ContextInfo contextInfo, final ResourceInfo resourceInfo)
-    {
-        if (resourceInfo == null)
-        {
-            throw new IllegalArgumentException("ResourceInfo cannot be null!");
-        }
-        final ServletInfo servletInfo = new ServletInfo(resourceInfo, null);
-        this.unregisterServlet(contextInfo, servletInfo);
-    }
-
     public void unregisterAll()
     {
         HashSet<Servlet> servlets = new HashSet<Servlet>(this.localServlets);

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/InternalHttpService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/InternalHttpService.java?rev=1656203&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/InternalHttpService.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/InternalHttpService.java Sat Jan 31 15:21:09 2015
@@ -0,0 +1,211 @@
+/*
+ * 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.service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.felix.http.base.internal.context.ExtServletContext;
+import org.apache.felix.http.base.internal.handler.FilterHandler;
+import org.apache.felix.http.base.internal.handler.HandlerRegistry;
+import org.apache.felix.http.base.internal.handler.ServletHandler;
+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.osgi.framework.BundleContext;
+import org.osgi.service.http.NamespaceException;
+import org.osgi.service.http.context.ServletContextHelper;
+
+public final class InternalHttpService
+{
+
+    private final HandlerRegistry handlerRegistry;
+
+    private final BundleContext bundleContext;
+
+    private final ServletContext webContext;
+
+    private static final class ContextHolder
+    {
+        public long counter;
+        public ExtServletContext servletContext;
+        public ServletContextHelper servletContextHelper;
+    }
+
+    private final Map<Long, ContextHolder> contextMap = new HashMap<Long, ContextHolder>();
+
+    public InternalHttpService(final BundleContext bundleContext,
+            final ServletContext context,
+            final HandlerRegistry handlerRegistry)
+    {
+        this.handlerRegistry = handlerRegistry;
+        this.bundleContext = bundleContext;
+        this.webContext = context;
+    }
+
+    private ExtServletContext getServletContext(@Nonnull final ContextInfo contextInfo,
+            @Nonnull final AbstractInfo<?> serviceInfo)
+    {
+        final Long key = contextInfo.getServiceId();
+        synchronized ( this.contextMap )
+        {
+            ContextHolder holder = this.contextMap.get(key);
+            if ( holder == null )
+            {
+                holder = new ContextHolder();
+                // TODO check for null
+                holder.servletContextHelper = serviceInfo.getServiceReference().getBundle().getBundleContext()
+                        .getServiceObjects(contextInfo.getServiceReference()).getService();
+                holder.servletContext = new ServletContextImpl(serviceInfo.getServiceReference().getBundle(),
+                        this.webContext,
+                        holder.servletContextHelper);
+            }
+            holder.counter++;
+
+            return holder.servletContext;
+        }
+    }
+
+    private void ungetServletContext(@Nonnull final ContextInfo contextInfo)
+    {
+        final Long key = contextInfo.getServiceId();
+        synchronized ( this.contextMap )
+        {
+            ContextHolder holder = this.contextMap.get(key);
+            if ( holder != null )
+            {
+                holder.counter--;
+                if ( holder.counter <= 0 )
+                {
+                    this.contextMap.remove(key);
+                }
+            }
+        }
+    }
+
+    /**
+     * Register a servlet.
+     * @param contextInfo The servlet context helper info
+     * @param servletInfo The servlet info
+     */
+    public void registerServlet(@Nonnull final ContextInfo contextInfo,
+            @Nonnull final ServletInfo servletInfo)
+    {
+        final Servlet servlet = this.bundleContext.getServiceObjects(servletInfo.getServiceReference()).getService();
+        // TODO create failure DTO if null
+        if ( servlet != null )
+        {
+            final ServletHandler handler = new ServletHandler(contextInfo,
+                    getServletContext(contextInfo, servletInfo),
+                    servletInfo,
+                    servlet);
+            try {
+                this.handlerRegistry.addServlet(contextInfo, handler);
+            } catch (ServletException e) {
+                // TODO create failure DTO
+            } catch (NamespaceException e) {
+                // TODO create failure DTO
+            }
+        }
+    }
+
+    /**
+     * Unregister a servlet
+     * @param contextInfo The servlet context helper info
+     * @param servletInfo The servlet info
+     */
+    public void unregisterServlet(@Nonnull final ContextInfo contextInfo, @Nonnull final ServletInfo servletInfo)
+    {
+        final Servlet instance = this.handlerRegistry.removeServlet(contextInfo, servletInfo, true);
+        if ( instance != null )
+        {
+            this.bundleContext.getServiceObjects(servletInfo.getServiceReference()).ungetService(instance);
+            this.ungetServletContext(contextInfo);
+        }
+    }
+
+    /**
+     * Register a filter
+     * @param contextInfo The servlet context helper info
+     * @param filterInfo The filter info
+     */
+    public void registerFilter(@Nonnull  final ContextInfo contextInfo,
+            @Nonnull final FilterInfo filterInfo)
+    {
+        final Filter filter = this.bundleContext.getServiceObjects(filterInfo.getServiceReference()).getService();
+        // TODO create failure DTO if null
+        if ( filter != null )
+        {
+            final FilterHandler handler = new FilterHandler(contextInfo,
+                    getServletContext(contextInfo, filterInfo),
+                    filter,
+                    filterInfo);
+            try {
+                this.handlerRegistry.addFilter(handler);
+            } catch (final ServletException e) {
+                // TODO create failure DTO
+            }
+        }
+    }
+
+    /**
+     * Unregister a filter
+     * @param contextInfo The servlet context helper info
+     * @param filterInfo The filter info
+     */
+    public void unregisterFilter(@Nonnull final ContextInfo contextInfo, @Nonnull final FilterInfo filterInfo)
+    {
+        final Filter instance = this.handlerRegistry.removeFilter(filterInfo, true);
+        if ( instance != null )
+        {
+            this.bundleContext.getServiceObjects(filterInfo.getServiceReference()).ungetService(instance);
+            this.ungetServletContext(contextInfo);
+        }
+    }
+
+    /**
+     * Register a resource.
+     * @param contextInfo The servlet context helper info
+     * @param resourceInfo The resource info
+     */
+    public void registerResource(@Nonnull final ContextInfo contextInfo,
+            @Nonnull final ResourceInfo resourceInfo)
+    {
+        final ServletInfo servletInfo = new ServletInfo(resourceInfo, new ResourceServlet(resourceInfo.getPrefix()));
+
+        this.registerServlet(contextInfo, servletInfo);
+    }
+
+    /**
+     * Unregister a resource.
+     * @param contextInfo The servlet context helper info
+     * @param resourceInfo The resource info
+     */
+    public void unregisterResource(@Nonnull final ContextInfo contextInfo, @Nonnull final ResourceInfo resourceInfo)
+    {
+        final ServletInfo servletInfo = new ServletInfo(resourceInfo, null);
+        this.unregisterServlet(contextInfo, servletInfo);
+    }
+}

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

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

Added: 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=1656203&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/ServletContextImpl.java Sat Jan 31 15:21:09 2015
@@ -0,0 +1,477 @@
+/*
+ * 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.service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterRegistration;
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+import javax.servlet.SessionCookieConfig;
+import javax.servlet.SessionTrackingMode;
+import javax.servlet.descriptor.JspConfigDescriptor;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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;
+
+public class ServletContextImpl implements ExtServletContext {
+
+    private final ServletContextHelper delegatee;
+
+    private final Bundle bundle;
+    private final ServletContext context;
+    private final Map<String, Object> attributes;
+
+    public ServletContextImpl(final Bundle bundle,
+            final ServletContext context,
+            final ServletContextHelper delegatee)
+    {
+        this.bundle = bundle;
+        this.context = context;
+        this.delegatee = delegatee;
+        this.attributes = new ConcurrentHashMap<String, Object>();
+    }
+
+    @Override
+    public boolean handleSecurity(HttpServletRequest request, HttpServletResponse response) throws IOException
+    {
+        return delegatee.handleSecurity(request, response);
+    }
+
+    @Override
+    public URL getResource(String path)
+    {
+        return delegatee.getResource(normalizeResourcePath(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;
+    }
+
+    @Override
+    public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> type)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public FilterRegistration.Dynamic addFilter(String filterName, String className)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void addListener(Class<? extends EventListener> type)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void addListener(String className)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T extends EventListener> void addListener(T listener)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> type)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public ServletRegistration.Dynamic addServlet(String servletName, String className)
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T extends Filter> T createFilter(Class<T> type) throws ServletException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T extends EventListener> T createListener(Class<T> type) throws ServletException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public <T extends Servlet> T createServlet(Class<T> type) throws ServletException
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void declareRoles(String... roleNames)
+    {
+        this.context.declareRoles(roleNames);
+    }
+
+    @Override
+    public String getVirtualServerName() {
+        return context.getVirtualServerName();
+    }
+
+    @Override
+    public Object getAttribute(String name)
+    {
+        return (this.attributes != null) ? this.attributes.get(name) : this.context.getAttribute(name);
+    }
+
+    @Override
+    public Enumeration getAttributeNames()
+    {
+        return (this.attributes != null) ? Collections.enumeration(this.attributes.keySet()) : this.context.getAttributeNames();
+    }
+
+    @Override
+    public ClassLoader getClassLoader()
+    {
+        return bundle.getClass().getClassLoader();
+    }
+
+    @Override
+    public ServletContext getContext(String uri)
+    {
+        return this.context.getContext(uri);
+    }
+
+    @Override
+    public String getContextPath()
+    {
+        return this.context.getContextPath();
+    }
+
+    @Override
+    public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
+    {
+        return this.context.getDefaultSessionTrackingModes();
+    }
+
+    @Override
+    public int getEffectiveMajorVersion()
+    {
+        return this.context.getEffectiveMajorVersion();
+    }
+
+    @Override
+    public int getEffectiveMinorVersion()
+    {
+        return this.context.getEffectiveMinorVersion();
+    }
+
+    @Override
+    public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
+    {
+        return this.context.getEffectiveSessionTrackingModes();
+    }
+
+    @Override
+    public FilterRegistration getFilterRegistration(String filterName)
+    {
+        return this.context.getFilterRegistration(filterName);
+    }
+
+    @Override
+    public Map<String, ? extends FilterRegistration> getFilterRegistrations()
+    {
+        return this.context.getFilterRegistrations();
+    }
+
+    @Override
+    public String getInitParameter(String name)
+    {
+        return this.context.getInitParameter(name);
+    }
+
+    @Override
+    public Enumeration getInitParameterNames()
+    {
+        return this.context.getInitParameterNames();
+    }
+
+    @Override
+    public JspConfigDescriptor getJspConfigDescriptor()
+    {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public int getMajorVersion()
+    {
+        return this.context.getMajorVersion();
+    }
+
+    @Override
+    public int getMinorVersion()
+    {
+        return this.context.getMinorVersion();
+    }
+
+    @Override
+    public RequestDispatcher getNamedDispatcher(String name)
+    {
+        return this.context.getNamedDispatcher(name);
+    }
+
+    @Override
+    public String getRealPath(String name)
+    {
+        URL url = getResource(name);
+        if (url == null)
+        {
+            return null;
+        }
+        return url.toExternalForm();
+    }
+
+    @Override
+    public RequestDispatcher getRequestDispatcher(String uri)
+    {
+        return this.context.getRequestDispatcher(uri);
+    }
+
+    @Override
+    public InputStream getResourceAsStream(String path)
+    {
+        URL res = getResource(path);
+        if (res != null)
+        {
+            try
+            {
+                return res.openStream();
+            }
+            catch (IOException e)
+            {
+                // Do nothing
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public Set getResourcePaths(String path)
+    {
+        // TODO
+        return null;
+    }
+
+    @Override
+    public String getServerInfo()
+    {
+        return this.context.getServerInfo();
+    }
+
+    @Override
+    public Servlet getServlet(String name) throws ServletException
+    {
+        return this.context.getServlet(name);
+    }
+
+    @Override
+    public String getServletContextName()
+    {
+        return this.context.getServletContextName();
+    }
+
+    @Override
+    public Enumeration getServletNames()
+    {
+        return this.context.getServletNames();
+    }
+
+    @Override
+    public ServletRegistration getServletRegistration(String servletName)
+    {
+        return this.context.getServletRegistration(servletName);
+    }
+
+    @Override
+    public Map<String, ? extends ServletRegistration> getServletRegistrations()
+    {
+        return this.context.getServletRegistrations();
+    }
+
+    @Override
+    public Enumeration getServlets()
+    {
+        return this.context.getServlets();
+    }
+
+    @Override
+    public SessionCookieConfig getSessionCookieConfig()
+    {
+        return this.context.getSessionCookieConfig();
+    }
+
+    @Override
+    public void log(Exception cause, String message)
+    {
+        SystemLogger.error(message, cause);
+    }
+
+    @Override
+    public void log(String message)
+    {
+        SystemLogger.info(message);
+    }
+
+    @Override
+    public void log(String message, Throwable cause)
+    {
+        SystemLogger.error(message, cause);
+    }
+
+    @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);
+        }
+
+        if (oldValue != null)
+        {
+            //this.attributeListener.attributeRemoved(new ServletContextAttributeEvent(this, name, oldValue));
+        }
+    }
+
+    @Override
+    public void setAttribute(String name, Object value)
+    {
+        if (value == null)
+        {
+            this.removeAttribute(name);
+        }
+        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);
+            }
+
+            if (oldValue == null)
+            {
+                //this.attributeListener.attributeAdded(new ServletContextAttributeEvent(this, name, value));
+            }
+            else
+            {
+                //this.attributeListener.attributeReplaced(new ServletContextAttributeEvent(this, name, oldValue));
+            }
+        }
+    }
+
+    @Override
+    public boolean setInitParameter(String name, String value)
+    {
+        return this.context.setInitParameter(name, value);
+    }
+
+    @Override
+    public void setSessionTrackingModes(Set<SessionTrackingMode> modes)
+    {
+        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;
+    }
+}

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

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

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ExtenderManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ExtenderManager.java?rev=1656203&r1=1656202&r2=1656203&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ExtenderManager.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ExtenderManager.java Sat Jan 31 15:21:09 2015
@@ -18,7 +18,7 @@ package org.apache.felix.http.base.inter
 
 import java.util.ArrayList;
 
-import org.apache.felix.http.base.internal.service.HttpServiceImpl;
+import org.apache.felix.http.base.internal.service.InternalHttpService;
 import org.apache.felix.http.base.internal.whiteboard.tracker.FilterTracker;
 import org.apache.felix.http.base.internal.whiteboard.tracker.ResourceTracker;
 import org.apache.felix.http.base.internal.whiteboard.tracker.ServletContextHelperTracker;
@@ -35,7 +35,7 @@ public final class ExtenderManager
 
     private final ArrayList<ServiceTracker<?, ?>> trackers = new ArrayList<ServiceTracker<?, ?>>();
 
-    public ExtenderManager(final HttpServiceImpl httpService, final BundleContext bundleContext)
+    public ExtenderManager(final InternalHttpService httpService, final BundleContext bundleContext)
     {
         this.contextManager = new ServletContextHelperManager(bundleContext, httpService);
         addTracker(new FilterTracker(bundleContext, contextManager));

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=1656203&r1=1656202&r2=1656203&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 15:21:09 2015
@@ -30,9 +30,10 @@ import org.apache.felix.http.base.intern
 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.service.HttpServiceImpl;
+import org.apache.felix.http.base.internal.service.InternalHttpService;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceFactory;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.http.context.ServletContextHelper;
@@ -41,12 +42,12 @@ import org.osgi.service.http.whiteboard.
 public final class ServletContextHelperManager
 {
     /** A map containing all servlet context registrations. Mapped by context name */
-    private final Map<String, List<ContextHolder>> contextMap = new HashMap<String, List<ContextHolder>>();
+    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<ContextHolder>> servicesMap = new HashMap<AbstractInfo<?>, List<ContextHolder>>();
+    private final Map<AbstractInfo<?>, List<ContextInfo>> servicesMap = new HashMap<AbstractInfo<?>, List<ContextInfo>>();
 
-    private final HttpServiceImpl httpService;
+    private final InternalHttpService httpService;
 
     private final ServiceRegistration<ServletContextHelper> defaultContextRegistration;
 
@@ -54,13 +55,14 @@ public final class ServletContextHelperM
      * Create a new servlet context helper manager
      * and the default context
      */
-    public ServletContextHelperManager(final BundleContext bundleContext, final HttpServiceImpl httpService)
+    public ServletContextHelperManager(final BundleContext bundleContext, final InternalHttpService httpService)
     {
         this.httpService = httpService;
 
         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);
 
         this.defaultContextRegistration = bundleContext.registerService(ServletContextHelper.class,
                 new ServiceFactory<ServletContextHelper>() {
@@ -91,11 +93,11 @@ public final class ServletContextHelperM
         this.defaultContextRegistration.unregister();
     }
 
-    private void activate(final ContextHolder holder)
+    private void activate(final ContextInfo holder)
     {
-        for(final Map.Entry<AbstractInfo<?>, List<ContextHolder>> entry : this.servicesMap.entrySet())
+        for(final Map.Entry<AbstractInfo<?>, List<ContextInfo>> entry : this.servicesMap.entrySet())
         {
-            if ( entry.getKey().getContextSelectionFilter().match(holder.getInfo().getServiceReference()) )
+            if ( entry.getKey().getContextSelectionFilter().match(holder.getServiceReference()) )
             {
                 entry.getValue().add(holder);
                 if ( entry.getKey() instanceof ServletInfo )
@@ -114,12 +116,12 @@ public final class ServletContextHelperM
         }
     }
 
-    private void deactivate(final ContextHolder holder)
+    private void deactivate(final ContextInfo holder)
     {
-        final Iterator<Map.Entry<AbstractInfo<?>, List<ContextHolder>>> i = this.servicesMap.entrySet().iterator();
+        final Iterator<Map.Entry<AbstractInfo<?>, List<ContextInfo>>> i = this.servicesMap.entrySet().iterator();
         while ( i.hasNext() )
         {
-            final Map.Entry<AbstractInfo<?>, List<ContextHolder>> entry = i.next();
+            final Map.Entry<AbstractInfo<?>, List<ContextInfo>> entry = i.next();
             if ( entry.getValue().remove(holder) )
             {
                 if ( entry.getKey() instanceof ServletInfo )
@@ -146,26 +148,25 @@ public final class ServletContextHelperM
      */
     public void addContextHelper(final ContextInfo info)
     {
-        final ContextHolder holder = new ContextHolder(info);
         synchronized ( this.contextMap )
         {
-            List<ContextHolder> holderList = this.contextMap.get(info.getName());
+            List<ContextInfo> holderList = this.contextMap.get(info.getName());
             if ( holderList == null )
             {
-                holderList = new ArrayList<ContextHolder>();
+                holderList = new ArrayList<ContextInfo>();
                 this.contextMap.put(info.getName(), holderList);
             }
-            holderList.add(holder);
+            holderList.add(info);
             Collections.sort(holderList);
             // check for activate/deactivate
-            if ( holderList.get(0) == holder )
+            if ( holderList.get(0) == info )
             {
                 // check for deactivate
                 if ( holderList.size() > 1 )
                 {
                     this.deactivate(holderList.get(1));
                 }
-                this.activate(holder);
+                this.activate(info);
             }
         }
     }
@@ -177,16 +178,16 @@ public final class ServletContextHelperM
     {
         synchronized ( this.contextMap )
         {
-            final List<ContextHolder> holderList = this.contextMap.get(info.getName());
+            final List<ContextInfo> holderList = this.contextMap.get(info.getName());
             if ( holderList != null )
             {
-                final Iterator<ContextHolder> i = holderList.iterator();
+                final Iterator<ContextInfo> i = holderList.iterator();
                 boolean first = true;
                 boolean activateNext = false;
                 while ( i.hasNext() )
                 {
-                    final ContextHolder holder = i.next();
-                    if ( holder.getInfo().compareTo(info) == 0 )
+                    final ContextInfo holder = i.next();
+                    if ( holder.compareTo(info) == 0 )
                     {
                         i.remove();
                         // check for deactivate
@@ -211,12 +212,12 @@ public final class ServletContextHelperM
         }
     }
 
-    private List<ContextHolder> getMatchingContexts(final AbstractInfo<?> info)
+    private List<ContextInfo> getMatchingContexts(final AbstractInfo<?> info)
     {
-        final List<ContextHolder> result = new ArrayList<ContextHolder>();
-        for(final List<ContextHolder> holders : this.contextMap.values()) {
-            final ContextHolder h = holders.get(0);
-            if ( info.getContextSelectionFilter().match(h.getInfo().getServiceReference()) )
+        final List<ContextInfo> result = new ArrayList<ContextInfo>();
+        for(final List<ContextInfo> holders : this.contextMap.values()) {
+            final ContextInfo h = holders.get(0);
+            if ( info.getContextSelectionFilter().match(h.getServiceReference()) )
             {
                 result.add(h);
             }
@@ -224,37 +225,34 @@ public final class ServletContextHelperM
         return result;
     }
 
-    private void registerServlet(final ServletInfo servletInfo, final ContextHolder holder)
+    private void registerServlet(final ServletInfo servletInfo, final ContextInfo holder)
     {
-    	final ServletContextHelper helper = holder.getContext(servletInfo.getServiceReference().getBundle());
-        this.httpService.registerServlet(helper, holder.getInfo(), servletInfo);
+        this.httpService.registerServlet(holder, servletInfo);
     }
 
-    private void unregisterServlet(final ServletInfo servletInfo, final ContextHolder holder)
+    private void unregisterServlet(final ServletInfo servletInfo, final ContextInfo holder)
     {
-        this.httpService.unregisterServlet(holder.getInfo(), servletInfo);
+        this.httpService.unregisterServlet(holder, servletInfo);
     }
 
-    private void registerFilter(final FilterInfo filterInfo, final ContextHolder holder)
+    private void registerFilter(final FilterInfo filterInfo, final ContextInfo holder)
     {
-        final ServletContextHelper helper = holder.getContext(filterInfo.getServiceReference().getBundle());
-        this.httpService.registerFilter(helper, holder.getInfo(), filterInfo);
+        this.httpService.registerFilter(holder, filterInfo);
     }
 
-    private void unregisterFilter(final FilterInfo filterInfo, final ContextHolder holder)
+    private void unregisterFilter(final FilterInfo filterInfo, final ContextInfo holder)
     {
-        this.httpService.unregisterFilter(holder.getInfo(), filterInfo);
+        this.httpService.unregisterFilter(holder, filterInfo);
     }
 
-    private void registerResource(final ResourceInfo resourceInfo, final ContextHolder holder)
+    private void registerResource(final ResourceInfo resourceInfo, final ContextInfo holder)
     {
-        final ServletContextHelper helper = holder.getContext(resourceInfo.getServiceReference().getBundle());
-        this.httpService.registerResource(helper, holder.getInfo(), resourceInfo);
+        this.httpService.registerResource(holder, resourceInfo);
     }
 
-    private void unregisterResource(final ResourceInfo resourceInfo, final ContextHolder holder)
+    private void unregisterResource(final ResourceInfo resourceInfo, final ContextInfo holder)
     {
-        this.httpService.unregisterResource(holder.getInfo(), resourceInfo);
+        this.httpService.unregisterResource(holder, resourceInfo);
     }
 
     /**
@@ -265,9 +263,9 @@ public final class ServletContextHelperM
     {
         synchronized ( this.contextMap )
         {
-            final List<ContextHolder> holderList = this.getMatchingContexts(servletInfo);
+            final List<ContextInfo> holderList = this.getMatchingContexts(servletInfo);
             this.servicesMap.put(servletInfo, holderList);
-            for(final ContextHolder h : holderList)
+            for(final ContextInfo h : holderList)
             {
             	this.registerServlet(servletInfo, h);
             }
@@ -282,10 +280,10 @@ public final class ServletContextHelperM
     {
         synchronized ( this.contextMap )
         {
-            final List<ContextHolder> holderList = this.servicesMap.remove(servletInfo);
+            final List<ContextInfo> holderList = this.servicesMap.remove(servletInfo);
             if ( holderList != null )
             {
-                for(final ContextHolder h : holderList)
+                for(final ContextInfo h : holderList)
                 {
                     this.unregisterServlet(servletInfo, h);
                 }
@@ -293,42 +291,12 @@ public final class ServletContextHelperM
         }
     }
 
-    /**
-     * Hold information about a context.
-     */
-    private final static class ContextHolder implements Comparable<ContextHolder>
-    {
-        private final ContextInfo info;
-
-        public ContextHolder(final ContextInfo info)
-        {
-            this.info = info;
-        }
-
-        public ContextInfo getInfo()
-        {
-            return this.info;
-        }
-
-        @Override
-        public int compareTo(final ContextHolder o)
-        {
-            return this.info.compareTo(o.info);
-        }
-
-        public ServletContextHelper getContext(final Bundle b)
-        {
-        	// TODO - we should somehow keep track of these objects to later on dispose them
-        	return b.getBundleContext().getServiceObjects(this.info.getServiceReference()).getService();
-        }
-    }
-
     public void addFilter(final FilterInfo info) {
         synchronized ( this.contextMap )
         {
-            final List<ContextHolder> holderList = this.getMatchingContexts(info);
+            final List<ContextInfo> holderList = this.getMatchingContexts(info);
             this.servicesMap.put(info, holderList);
-            for(final ContextHolder h : holderList)
+            for(final ContextInfo h : holderList)
             {
                 this.registerFilter(info, h);
             }
@@ -338,10 +306,10 @@ public final class ServletContextHelperM
     public void removeFilter(final FilterInfo info) {
         synchronized ( this.contextMap )
         {
-            final List<ContextHolder> holderList = this.servicesMap.remove(info);
+            final List<ContextInfo> holderList = this.servicesMap.remove(info);
             if ( holderList != null )
             {
-                for(final ContextHolder h : holderList)
+                for(final ContextInfo h : holderList)
                 {
                     this.unregisterFilter(info, h);
                 }
@@ -352,9 +320,9 @@ public final class ServletContextHelperM
     public void addResource(final ResourceInfo info) {
         synchronized ( this.contextMap )
         {
-            final List<ContextHolder> holderList = this.getMatchingContexts(info);
+            final List<ContextInfo> holderList = this.getMatchingContexts(info);
             this.servicesMap.put(info, holderList);
-            for(final ContextHolder h : holderList)
+            for(final ContextInfo h : holderList)
             {
                 this.registerResource(info, h);
             }
@@ -364,10 +332,10 @@ public final class ServletContextHelperM
     public void removeResource(final ResourceInfo info) {
         synchronized ( this.contextMap )
         {
-            final List<ContextHolder> holderList = this.servicesMap.remove(info);
+            final List<ContextInfo> holderList = this.servicesMap.remove(info);
             if ( holderList != null )
             {
-                for(final ContextHolder h : holderList)
+                for(final ContextInfo h : holderList)
                 {
                     this.unregisterResource(info, h);
                 }

Modified: felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java?rev=1656203&r1=1656202&r2=1656203&view=diff
==============================================================================
--- felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java (original)
+++ felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/handler/ServletHandlerTest.java Sat Jan 31 15:21:09 2015
@@ -219,7 +219,7 @@ public class ServletHandlerTest extends
 
     private ServletHandler createHandler(String alias, Map<String, String> map)
     {
-        final ServletInfo info = new ServletInfo(null, alias, 0, map, this.servlet, null);
-        return new ServletHandler(null, this.context, info, info.getServlet());
+        final ServletInfo info = new ServletInfo(null, alias, 0, map);
+        return new ServletHandler(null, this.context, info, this.servlet);
     }
 }



Mime
View raw message