felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1777088 [3/3] - in /felix/trunk/http: api/ api/src/main/appended-resources/META-INF/ api/src/main/java/org/apache/felix/http/api/ api/src/main/java/org/osgi/ api/src/main/java/org/osgi/service/ api/src/main/java/org/osgi/service/http/ api/...
Date Tue, 03 Jan 2017 08:12:45 GMT
Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
Tue Jan  3 08:12:45 2017
@@ -21,6 +21,7 @@ import static org.osgi.service.http.runt
 import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_UNKNOWN;
 import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_VALIDATION_FAILED;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -31,11 +32,18 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.annotation.Nonnull;
+import javax.servlet.FilterChain;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.HttpSessionEvent;
 
@@ -45,6 +53,7 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.handler.HttpServiceServletHandler;
 import org.apache.felix.http.base.internal.handler.HttpSessionWrapper;
 import org.apache.felix.http.base.internal.handler.ListenerHandler;
+import org.apache.felix.http.base.internal.handler.PreprocessorHandler;
 import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.handler.WhiteboardFilterHandler;
 import org.apache.felix.http.base.internal.handler.WhiteboardListenerHandler;
@@ -55,11 +64,13 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.runtime.AbstractInfo;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
 import org.apache.felix.http.base.internal.runtime.ListenerInfo;
+import org.apache.felix.http.base.internal.runtime.PreprocessorInfo;
 import org.apache.felix.http.base.internal.runtime.ResourceInfo;
 import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.apache.felix.http.base.internal.runtime.WhiteboardServiceInfo;
 import org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder;
+import org.apache.felix.http.base.internal.runtime.dto.PreprocessorDTOBuilder;
 import org.apache.felix.http.base.internal.runtime.dto.RegistryRuntime;
 import org.apache.felix.http.base.internal.runtime.dto.ServletContextDTOBuilder;
 import org.apache.felix.http.base.internal.service.HttpServiceFactory;
@@ -82,6 +93,7 @@ import org.osgi.service.http.context.Ser
 import org.osgi.service.http.runtime.HttpServiceRuntime;
 import org.osgi.service.http.runtime.HttpServiceRuntimeConstants;
 import org.osgi.service.http.runtime.dto.DTOConstants;
+import org.osgi.service.http.runtime.dto.PreprocessorDTO;
 import org.osgi.service.http.runtime.dto.ServletContextDTO;
 import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
 import org.osgi.util.tracker.ServiceTracker;
@@ -106,6 +118,8 @@ public final class WhiteboardManager
     /** A map with all servlet/filter registrations, mapped by abstract info. */
     private final Map<WhiteboardServiceInfo<?>, List<WhiteboardContextHandler>>
servicesMap = new HashMap<WhiteboardServiceInfo<?>, List<WhiteboardContextHandler>>();
 
+    private volatile List<PreprocessorHandler> preprocessorHandlers = Collections.emptyList();
+
     private final HandlerRegistry registry;
 
     private final FailureStateHandler failureStateHandler = new FailureStateHandler();
@@ -154,6 +168,7 @@ public final class WhiteboardManager
 
         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_SERVICE_CONTEXT_PROPERTY, HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME);
         props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_PATH, "/");
         props.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
 
@@ -224,6 +239,7 @@ public final class WhiteboardManager
 
         this.serviceRuntime.setServiceReference(null);
 
+        this.preprocessorHandlers = Collections.emptyList();
         this.contextMap.clear();
         this.servicesMap.clear();
         this.failureStateHandler.clear();
@@ -291,22 +307,28 @@ public final class WhiteboardManager
         final List<WhiteboardServiceInfo<?>> services = new ArrayList<WhiteboardServiceInfo<?>>();
         for(final Map.Entry<WhiteboardServiceInfo<?>, List<WhiteboardContextHandler>>
entry : this.servicesMap.entrySet())
         {
-            if ( entry.getKey().getContextSelectionFilter().match(handler.getContextInfo().getServiceReference())
)
+            final WhiteboardServiceInfo<?> info = entry.getKey();
+
+            if ( info.getContextSelectionFilter().match(handler.getContextInfo().getServiceReference())
)
             {
-                entry.getValue().add(handler);
-                if ( entry.getValue().size() == 1 )
+                final int reason = checkForServletRegistrationInHttpServiceContext(handler,
info);
+                if ( reason == -1 )
                 {
-                    this.failureStateHandler.remove(entry.getKey());
-                }
-                if ( entry.getKey() instanceof ListenerInfo && ((ListenerInfo)entry.getKey()).isListenerType(ServletContextListener.class.getName())
)
-                {
-                    // servlet context listeners will be registered directly
-                    this.registerWhiteboardService(handler, entry.getKey());
-                }
-                else
-                {
-                    // registration of other services will be delayed
-                    services.add(entry.getKey());
+                    entry.getValue().add(handler);
+                    if ( entry.getValue().size() == 1 )
+                    {
+                        this.failureStateHandler.remove(info);
+                    }
+                    if ( info instanceof ListenerInfo && ((ListenerInfo)info).isListenerType(ServletContextListener.class.getName())
)
+                    {
+                        // servlet context listeners will be registered directly
+                        this.registerWhiteboardService(handler, info);
+                    }
+                    else
+                    {
+                        // registration of other services will be delayed
+                        services.add(info);
+                    }
                 }
             }
         }
@@ -350,9 +372,7 @@ public final class WhiteboardManager
                 }
                 if ( entry.getValue().isEmpty() )
                 {
-                    final String type = entry.getKey().getClass().getSimpleName().substring(0,
entry.getKey().getClass().getSimpleName().length() - 4);
-                    SystemLogger.debug("Ignoring unmatching " + type + " service " + entry.getKey().getServiceReference());
-                    this.failureStateHandler.add(entry.getKey(), FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING);
+                    this.failureStateHandler.addFailure(entry.getKey(), FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING);
                 }
             }
         }
@@ -407,16 +427,12 @@ public final class WhiteboardManager
                                 final WhiteboardContextHandler oldHead = handlerList.get(1);
                                 this.deactivate(oldHead);
 
-                                final String type = info.getClass().getSimpleName().substring(0,
info.getClass().getSimpleName().length() - 4);
-                                SystemLogger.debug("Ignoring shadowed " + type + " service
" + info.getServiceReference());
-                                this.failureStateHandler.add(oldHead.getContextInfo(), FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
+                                this.failureStateHandler.addFailure(oldHead.getContextInfo(),
FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
                             }
                         }
                         else
                         {
-                            final String type = info.getClass().getSimpleName().substring(0,
info.getClass().getSimpleName().length() - 4);
-                            SystemLogger.error("Ignoring ungettable " + type + " service
" + info.getServiceReference(), null);
-                            this.failureStateHandler.add(handler.getContextInfo(), DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE);
+                            this.failureStateHandler.addFailure(handler.getContextInfo(),
DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE);
                         }
                     }
                     else
@@ -425,17 +441,13 @@ public final class WhiteboardManager
                         Collections.sort(handlerList);
                         this.contextMap.put(info.getName(), handlerList);
 
-                        final String type = info.getClass().getSimpleName().substring(0,
info.getClass().getSimpleName().length() - 4);
-                        SystemLogger.debug("Ignoring shadowed " + type + " service " + info.getServiceReference());
-                        this.failureStateHandler.add(handler.getContextInfo(), FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
+                        this.failureStateHandler.addFailure(handler.getContextInfo(), FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
                     }
                 }
             }
             else
             {
-                final String type = info.getClass().getSimpleName().substring(0, info.getClass().getSimpleName().length()
- 4);
-                SystemLogger.debug("Ignoring invalid " + type + " service " + info.getServiceReference());
-                this.failureStateHandler.add(info, FAILURE_REASON_VALIDATION_FAILED);
+                this.failureStateHandler.addFailure(info, FAILURE_REASON_VALIDATION_FAILED);
             }
             return true;
         }
@@ -496,9 +508,7 @@ public final class WhiteboardManager
                             {
                                 handlerList.remove(0);
 
-                                final String type = info.getClass().getSimpleName().substring(0,
info.getClass().getSimpleName().length() - 4);
-                                SystemLogger.error("Ignoring ungettable " + type + " service
" + info.getServiceReference(), null);
-                                this.failureStateHandler.add(newHead.getContextInfo(), DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE);
+                                this.failureStateHandler.addFailure(newHead.getContextInfo(),
DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE);
                             }
                         }
                     }
@@ -573,30 +583,53 @@ public final class WhiteboardManager
         {
             if ( info.isValid() )
             {
+                if ( info instanceof PreprocessorInfo )
+                {
+                    final PreprocessorHandler handler = new PreprocessorHandler(this.httpBundleContext,
+                            this.webContext, ((PreprocessorInfo)info));
+                    final int result = handler.init();
+                    if ( result == -1 )
+                    {
+                        synchronized ( this.preprocessorHandlers )
+                        {
+                            final List<PreprocessorHandler> newList = new ArrayList<PreprocessorHandler>(this.preprocessorHandlers);
+                            newList.add(handler);
+                            Collections.sort(newList);
+                            this.preprocessorHandlers = newList;
+                        }
+                    }
+                    else
+                    {
+                        this.failureStateHandler.addFailure(info, FAILURE_REASON_VALIDATION_FAILED);
+                    }
+                    return true;
+                }
                 synchronized ( this.contextMap )
                 {
                     final List<WhiteboardContextHandler> handlerList = this.getMatchingContexts(info);
                     this.servicesMap.put(info, handlerList);
                     if (handlerList.isEmpty())
                     {
-                        final String type = info.getClass().getSimpleName().substring(0,
info.getClass().getSimpleName().length() - 4);
-                        SystemLogger.debug("Ignoring unmatched " + type + " service " + info.getServiceReference());
-                        this.failureStateHandler.add(info, FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING);
+                        this.failureStateHandler.addFailure(info, FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING);
                     }
                     else
                     {
                         for(final WhiteboardContextHandler h : handlerList)
                         {
-                            this.registerWhiteboardService(h, info);
-                            if ( info instanceof ListenerInfo && ((ListenerInfo)info).isListenerType(ServletContextListener.class.getName())
)
+                            final int result = this.checkForServletRegistrationInHttpServiceContext(h,
info);
+                            if ( result == -1)
                             {
-                                final ListenerHandler handler = h.getRegistry().getEventListenerRegistry().getServletContextListener((ListenerInfo)info);
-                                if ( handler != null )
+                                this.registerWhiteboardService(h, info);
+                                if ( info instanceof ListenerInfo && ((ListenerInfo)info).isListenerType(ServletContextListener.class.getName())
)
                                 {
-                                    final ServletContextListener listener = (ServletContextListener)handler.getListener();
-                                    if ( listener != null )
+                                    final ListenerHandler handler = h.getRegistry().getEventListenerRegistry().getServletContextListener((ListenerInfo)info);
+                                    if ( handler != null )
                                     {
-                                        EventListenerRegistry.contextInitialized(handler.getListenerInfo(),
listener, new ServletContextEvent(handler.getContext()));
+                                        final ServletContextListener listener = (ServletContextListener)handler.getListener();
+                                        if ( listener != null )
+                                        {
+                                            EventListenerRegistry.contextInitialized(handler.getListenerInfo(),
listener, new ServletContextEvent(handler.getContext()));
+                                        }
                                     }
                                 }
                             }
@@ -606,9 +639,7 @@ public final class WhiteboardManager
             }
             else
             {
-                final String type = info.getClass().getSimpleName().substring(0, info.getClass().getSimpleName().length()
- 4);
-                SystemLogger.debug("Ignoring invalid " + type + " service " + info.getServiceReference());
-                this.failureStateHandler.add(info, FAILURE_REASON_VALIDATION_FAILED);
+                this.failureStateHandler.addFailure(info, FAILURE_REASON_VALIDATION_FAILED);
             }
             return true;
         }
@@ -616,6 +647,29 @@ public final class WhiteboardManager
     }
 
     /**
+     * Check if a registration for a servlet or resource is tried against the http context
+     * of the http service
+     * @param h The handler
+     * @param info The info
+     * @return {@code -1} if everything is ok, error code otherwise
+     */
+    private int checkForServletRegistrationInHttpServiceContext(final WhiteboardContextHandler
h,
+            final WhiteboardServiceInfo<?> info)
+    {
+        if ( info instanceof ServletInfo || info instanceof ResourceInfo )
+        {
+            if ( h.getContextInfo().getServiceId() == HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID
)
+            {
+                this.failureStateHandler.addFailure(info, h.getContextInfo().getServiceId(),
DTOConstants.FAILURE_REASON_VALIDATION_FAILED);
+
+                return DTOConstants.FAILURE_REASON_VALIDATION_FAILED;
+            }
+        }
+
+        return -1;
+    }
+
+    /**
      * Remove whiteboard service from the registry.
      *
      * @param info The service id of the whiteboard service
@@ -626,6 +680,26 @@ public final class WhiteboardManager
         {
             if ( !failureStateHandler.remove(info) )
             {
+                if ( info instanceof PreprocessorInfo )
+                {
+                    synchronized ( this.preprocessorHandlers )
+                    {
+                        final List<PreprocessorHandler> newList = new ArrayList<PreprocessorHandler>(this.preprocessorHandlers);
+                        final Iterator<PreprocessorHandler> iter = newList.iterator();
+                        while ( iter.hasNext() )
+                        {
+                            final PreprocessorHandler handler = iter.next();
+                            if ( handler.getPreprocessorInfo().compareTo((PreprocessorInfo)info)
== 0 )
+                            {
+                                iter.remove();
+                                this.preprocessorHandlers = newList;
+                                return;
+                            }
+                        }
+                        // not found, nothing to do
+                    }
+                    return;
+                }
                 final List<WhiteboardContextHandler> handlerList = this.servicesMap.remove(info);
                 if ( handlerList != null )
                 {
@@ -741,15 +815,12 @@ public final class WhiteboardManager
             }
             if ( failureCode != -1 )
             {
-                final String type = info.getClass().getSimpleName().substring(0,info.getClass().getSimpleName().length()
- 4);
-                SystemLogger.debug("Ignoring " + type + " service " + info.getServiceReference());
-                this.failureStateHandler.add(info, handler.getContextInfo().getServiceId(),
failureCode);
+                this.failureStateHandler.addFailure(info, handler.getContextInfo().getServiceId(),
failureCode);
             }
         }
         catch (final Exception e)
         {
-            this.failureStateHandler.add(info, handler.getContextInfo().getServiceId(), FAILURE_REASON_UNKNOWN);
-            SystemLogger.error("Exception while registering whiteboard service " + info.getServiceReference(),
e);
+            this.failureStateHandler.addFailure(info, handler.getContextInfo().getServiceId(),
FAILURE_REASON_UNKNOWN, e);
         }
     }
 
@@ -836,17 +907,7 @@ public final class WhiteboardManager
         final FailedDTOHolder failedDTOHolder = new FailedDTOHolder();
 
         final Collection<ServletContextDTO> contextDTOs = new ArrayList<ServletContextDTO>();
-/*
-        // add the context for the http service
-        final ServletContextHelperInfo info = new ServletContextHelperInfo(Integer.MAX_VALUE,
-                HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID,
-                HttpServiceFactory.HTTP_SERVICE_CONTEXT_NAME, "/", null);
-        final ServletContextDTO dto = ServletContextDTOBuilder.build(info, webContext, -1);
-        if ( registry.getRuntimeInfo(dto, failedDTOHolder) )
-        {
-            contextDTOs.add(dto);
-        }
-*/
+
         // get sort list of context handlers
         final List<WhiteboardContextHandler> contextHandlerList = new ArrayList<WhiteboardContextHandler>();
         synchronized ( this.contextMap )
@@ -872,6 +933,51 @@ public final class WhiteboardManager
             }
         }
 
-        return new RegistryRuntime(failedDTOHolder, contextDTOs);
+        final List<PreprocessorDTO> preprocessorDTOs = new ArrayList<PreprocessorDTO>();
+        final List<PreprocessorHandler> localHandlers = this.preprocessorHandlers;
+        for(final PreprocessorHandler handler : localHandlers)
+        {
+            preprocessorDTOs.add(PreprocessorDTOBuilder.build(handler.getPreprocessorInfo(),
-1));
+        }
+
+        return new RegistryRuntime(failedDTOHolder, contextDTOs, preprocessorDTOs);
+    }
+
+    /**
+     * Invoke all preprocessors
+     *
+     * @param req The request
+     * @param res The response
+     * @return {@code true} to continue with dispatching, {@code false} to terminate the
request.
+     * @throws IOException
+     * @throws ServletException
+     */
+    public boolean invokePreprocessors(final HttpServletRequest req, final HttpServletResponse
res)
+    throws ServletException, IOException
+    {
+        final List<PreprocessorHandler> localHandlers = this.preprocessorHandlers;
+        if ( localHandlers.isEmpty() )
+        {
+            return true;
+        }
+        final AtomicBoolean result = new AtomicBoolean(true);
+        final FilterChain chain = new FilterChain() {
+
+            @Override
+            public void doFilter(final ServletRequest request, final ServletResponse response)
+            throws IOException, ServletException {
+                result.set(true);
+            }
+        };
+        for(final PreprocessorHandler handler : localHandlers)
+        {
+            result.set(false);
+            handler.handle(req, res, chain);
+            if ( !result.get() )
+            {
+                break;
+            }
+        }
+        return result.get();
     }
 }

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/PreprocessorTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/PreprocessorTracker.java?rev=1777088&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/PreprocessorTracker.java
(added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/PreprocessorTracker.java
Tue Jan  3 08:12:45 2017
@@ -0,0 +1,46 @@
+/*
+ * 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.whiteboard.tracker;
+
+import org.apache.felix.http.base.internal.runtime.PreprocessorInfo;
+import org.apache.felix.http.base.internal.runtime.WhiteboardServiceInfo;
+import org.apache.felix.http.base.internal.whiteboard.WhiteboardManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.whiteboard.Preprocessor;
+
+public final class PreprocessorTracker extends WhiteboardServiceTracker<Preprocessor>
+{
+
+   /**
+     * Create a new tracker
+     * @param contextManager The context manager
+     * @param bundleContext The bundle context.
+     * @param filterExpr The filter expression for the services to track
+     */
+    public PreprocessorTracker(final WhiteboardManager contextManager,
+            final BundleContext bundleContext, final String filterExpr)
+    {
+        super(contextManager, bundleContext, String.format("(objectClass=%s)",
+                Preprocessor.class.getName()));
+    }
+
+    @Override
+    protected WhiteboardServiceInfo<Preprocessor> getServiceInfo(final ServiceReference<Preprocessor>
ref) {
+        return new PreprocessorInfo(ref);
+    }
+}

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

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

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/ServletTracker.java
Tue Jan  3 08:12:45 2017
@@ -29,8 +29,9 @@ public final class ServletTracker extend
 {
     public ServletTracker(final BundleContext context, final WhiteboardManager manager)
     {
-        super(manager, context, String.format("(&(objectClass=%s)(|(%s=*)(%s=*)))",
+        super(manager, context, String.format("(&(objectClass=%s)(|(%s=*)(%s=*)(%s=*)))",
                 Servlet.class.getName(),
+                HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME,
                 HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN,
                 HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE));
     }

Modified: felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandlerTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandlerTest.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandlerTest.java
(original)
+++ felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandlerTest.java
Tue Jan  3 08:12:45 2017
@@ -51,7 +51,7 @@ public class FailureStateHandlerTest {
         final ServletInfo info = new ServletInfo("test", "/test", Collections.<String,
String> emptyMap());
 
         final FailureStateHandler handler = new FailureStateHandler();
-        handler.add(info, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
+        handler.addFailure(info, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
 
         final FailedDTOHolder holder = new FailedDTOHolder();
         handler.getRuntimeInfo(holder);
@@ -73,8 +73,8 @@ public class FailureStateHandlerTest {
         final ServletInfo info2 = new ServletInfo("test", "/test", Collections.<String,
String> emptyMap());
 
         final FailureStateHandler handler = new FailureStateHandler();
-        handler.add(info1, 1L, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
-        handler.add(info2, 2L, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
+        handler.addFailure(info1, 1L, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
+        handler.addFailure(info2, 2L, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
 
         final FailedDTOHolder holder = new FailedDTOHolder();
         handler.getRuntimeInfo(holder);

Modified: felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java
(original)
+++ felix/trunk/http/itest/src/test/java/org/apache/felix/http/itest/HttpServiceRuntimeTest.java
Tue Jan  3 08:12:45 2017
@@ -614,9 +614,10 @@ public class HttpServiceRuntimeTest exte
         ServletContextDTO defaultContextDTO = runtimeDTO.servletContextDTOs[2];
         long contextServiceId = defaultContextDTO.serviceId;
 
-        assertEquals(1, defaultContextDTO.servletDTOs.length);
-        assertEquals("default servlet", defaultContextDTO.servletDTOs[0].name);
-        assertEquals(contextServiceId, defaultContextDTO.servletDTOs[0].servletContextId);
+        assertEquals(Arrays.toString(defaultContextDTO.servletDTOs), 2, defaultContextDTO.servletDTOs.length);
+        assertServlet(defaultContextDTO.servletDTOs, "default servlet", contextServiceId);
+        assertServlet(defaultContextDTO.servletDTOs, "default error page", contextServiceId);
+
         assertEquals(1, defaultContextDTO.filterDTOs.length);
         assertEquals("default filter", defaultContextDTO.filterDTOs[0].name);
         assertEquals(contextServiceId, defaultContextDTO.filterDTOs[0].servletContextId);
@@ -630,9 +631,10 @@ public class HttpServiceRuntimeTest exte
         ServletContextDTO testContextDTO = runtimeDTO.servletContextDTOs[1];
         contextServiceId = testContextDTO.serviceId;
 
-        assertEquals(1, testContextDTO.servletDTOs.length);
-        assertEquals("context servlet", testContextDTO.servletDTOs[0].name);
-        assertEquals(contextServiceId, testContextDTO.servletDTOs[0].servletContextId);
+        assertEquals(2, testContextDTO.servletDTOs.length);
+        assertServlet(testContextDTO.servletDTOs, "context servlet", contextServiceId);
+        assertServlet(testContextDTO.servletDTOs, "context error page", contextServiceId);
+
         assertEquals(1, testContextDTO.filterDTOs.length);
         assertEquals("context filter", testContextDTO.filterDTOs[0].name);
         assertEquals(contextServiceId, testContextDTO.filterDTOs[0].servletContextId);
@@ -644,7 +646,22 @@ public class HttpServiceRuntimeTest exte
         assertEquals(contextServiceId, testContextDTO.listenerDTOs[0].servletContextId);
     }
 
-    @Test
+    private void assertServlet(final ServletDTO[] servletDTOs, 
+    		final String name, 
+    		final long contextServiceId) 
+    {
+    	assertNotNull(servletDTOs);
+    	for(final ServletDTO dto : servletDTOs) 
+    	{
+    		if ( name.equals(dto.name) && contextServiceId == dto.servletContextId )
+    		{
+    			return;
+    		}
+    	}
+    	fail("Servlet with name " + name + " and context id " + contextServiceId + " not found
in " + Arrays.toString(servletDTOs));
+	}
+
+	@Test
     public void exceptionInServletInitAppearsAsFailure() throws ServletException, InterruptedException
     {
         Dictionary<String, ?> properties = createDictionary(

Modified: felix/trunk/http/jetty/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/pom.xml?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/jetty/pom.xml (original)
+++ felix/trunk/http/jetty/pom.xml Tue Jan  3 08:12:45 2017
@@ -47,6 +47,7 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
+                <version>3.2.0</version>
                 <configuration>
                     <instructions>
                     	<X-Jetty-Version>
@@ -81,20 +82,18 @@
                         	org.osgi.service.log;version="[1.3,2)",
                         	org.osgi.service.metatype;version="[1.1,2)";resolution:=optional,
                         	org.osgi.service.useradmin;resolution:=optional,
-                        <!-- Maven bundle plugin version 2.5.3 has a problem
-                             with correctly calculating the import ranges -->
                             org.apache.felix.http.api;version="[2.0,2.1)",
-                            org.osgi.service.http;version="[1.2,1.3)",
+                            org.osgi.service.http;version="[1.2.1,1.3)",
                             org.osgi.service.http.context;version="[1.0,1.1)",
                             org.osgi.service.http.runtime;version="[1.0,1.1)",
-                            org.osgi.service.http.runtime.dto;version="[1.0,1.1)",
+                            org.osgi.service.http.runtime.dto;version="[1.1,1.2)",
                             *
                         </Import-Package>
                         <DynamicImport-Package>
                             org.osgi.service.metatype;version="[1.1,2)"
                         </DynamicImport-Package>
                         <Provide-Capability>
-                            osgi.implementation;osgi.implementation="osgi.http";version:Version="1.0";
+                            osgi.implementation;osgi.implementation="osgi.http";version:Version="1.1";
                             uses:="javax.servlet,javax.servlet.http,org.osgi.service.http.context,org.osgi.service.http.whiteboard",
                             osgi.service;objectClass:List&lt;String&gt;="org.osgi.service.http.runtime.HttpServiceRuntime";
                             uses:="org.osgi.service.http.runtime,org.osgi.service.http.runtime.dto"
@@ -186,7 +185,7 @@
         <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.http.api</artifactId>
-            <version>3.0.0</version>
+            <version>3.0.1-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>

Modified: felix/trunk/http/jetty/src/main/appended-resources/META-INF/DEPENDENCIES
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/appended-resources/META-INF/DEPENDENCIES?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/appended-resources/META-INF/DEPENDENCIES (original)
+++ felix/trunk/http/jetty/src/main/appended-resources/META-INF/DEPENDENCIES Tue Jan  3 08:12:45
2017
@@ -6,14 +6,14 @@ Licensed under the Apache License 2.0.
 
 This product includes software developed at
 The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2015).
+Copyright (c) OSGi Alliance (2000, 2016).
 Licensed under the Apache License 2.0.
 
 II. Used Third-Party Software
 
 This product uses software developed at
 The OSGi Alliance (http://www.osgi.org).
-Copyright (c) OSGi Alliance (2000, 2015).
+Copyright (c) OSGi Alliance (2000, 2016).
 Licensed under the Apache License 2.0.
 
 III. License Summary

Modified: felix/trunk/http/jetty/src/main/appended-resources/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/appended-resources/META-INF/NOTICE?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/appended-resources/META-INF/NOTICE (original)
+++ felix/trunk/http/jetty/src/main/appended-resources/META-INF/NOTICE Tue Jan  3 08:12:45
2017
@@ -1,6 +1,6 @@
 This product includes software developed at
 The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2015).
+Copyright (c) OSGi Alliance (2000, 2016).
 Licensed under the Apache License 2.0.
 
 This product includes software developed by



Mime
View raw message