felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1680011 [1/2] - in /felix/trunk/http/base/src: main/java/org/apache/felix/http/base/internal/handler/ main/java/org/apache/felix/http/base/internal/registry/ main/java/org/apache/felix/http/base/internal/runtime/dto/ main/java/org/apache/f...
Date Mon, 18 May 2015 12:44:56 GMT
Author: cziegeler
Date: Mon May 18 12:44:55 2015
New Revision: 1680011

URL: http://svn.apache.org/r1680011
Log:
FELIX-4888 : ServletHandler's are not sorted by longest matching path. DTO handling (WiP)

Added:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureFilterState.java   (with props)
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureServletState.java   (with props)
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FilterState.java   (with props)
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/ServletState.java   (with props)
Removed:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ErrorPageRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailureFilterRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailureServletRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FilterRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/InfoServletContextHelperRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletRuntime.java
Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/BaseServletDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ContextRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ErrorPageDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailureRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FilterDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RequestInfoDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ResourceDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextHelperRuntime.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletDTOBuilder.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/registry/HandlerRegistryTest.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/WhiteboardServiceHelper.java
    felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/FilterHandler.java Mon May 18 12:44:55 2015
@@ -31,14 +31,14 @@ import javax.servlet.ServletResponse;
 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.runtime.FilterInfo;
-import org.apache.felix.http.base.internal.runtime.dto.FilterRuntime;
+import org.apache.felix.http.base.internal.runtime.dto.state.FilterState;
 import org.apache.felix.http.base.internal.util.PatternUtil;
 import org.osgi.service.http.runtime.dto.DTOConstants;
 
 /**
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public class FilterHandler implements Comparable<FilterHandler>, FilterRuntime
+public class FilterHandler implements Comparable<FilterHandler>, FilterState
 {
     private final long contextServiceId;
 
@@ -99,7 +99,6 @@ public class FilterHandler implements Co
         return this.filterInfo.compareTo(other.filterInfo);
     }
 
-    @Override
     public long getContextServiceId()
     {
         return this.contextServiceId;

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/ServletHandler.java Mon May 18 12:44:55 2015
@@ -26,13 +26,12 @@ import javax.servlet.ServletResponse;
 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.runtime.ServletInfo;
-import org.apache.felix.http.base.internal.runtime.dto.ServletRuntime;
 import org.osgi.service.http.runtime.dto.DTOConstants;
 
 /**
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
-public abstract class ServletHandler implements Comparable<ServletHandler>, ServletRuntime
+public abstract class ServletHandler implements Comparable<ServletHandler>
 {
     private final long contextServiceId;
 
@@ -59,7 +58,6 @@ public abstract class ServletHandler imp
         return this.servletInfo.compareTo(other.servletInfo);
     }
 
-    @Override
     public long getContextServiceId()
     {
         return this.contextServiceId;
@@ -70,7 +68,6 @@ public abstract class ServletHandler imp
         return this.context;
     }
 
-    @Override
     public Servlet getServlet()
     {
         return servlet;
@@ -87,7 +84,6 @@ public abstract class ServletHandler imp
         this.servlet.service(req, res);
     }
 
-    @Override
     public ServletInfo getServletInfo()
     {
         return this.servletInfo;

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ErrorPageRegistry.java Mon May 18 12:44:55 2015
@@ -19,7 +19,7 @@ package org.apache.felix.http.base.inter
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashSet;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -29,11 +29,12 @@ import java.util.concurrent.ConcurrentHa
 import java.util.regex.Pattern;
 
 import javax.annotation.Nonnull;
+import javax.servlet.Servlet;
 
 import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
-import org.apache.felix.http.base.internal.runtime.dto.ErrorPageRuntime;
-import org.apache.felix.http.base.internal.runtime.dto.ServletRuntime;
+import org.apache.felix.http.base.internal.runtime.dto.state.FailureServletState;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.service.http.runtime.dto.DTOConstants;
 
 /**
@@ -58,7 +59,7 @@ public final class ErrorPageRegistry
         return Collections.unmodifiableList(result);
     }
 
-    private static String parseErrorCodes(final List<Long> codes, final String string)
+    private static String parseErrorCodes(final Set<Long> codes, final String string)
     {
         if (CLIENT_ERROR.equalsIgnoreCase(string))
         {
@@ -85,8 +86,8 @@ public final class ErrorPageRegistry
     private final Map<ServletInfo, ErrorRegistrationStatus> statusMapping = new ConcurrentHashMap<ServletInfo, ErrorRegistrationStatus>();
 
     private static final class ErrorRegistration {
-        final List<Long> errorCodes = new ArrayList<Long>();
-        final Set<String> exceptions = new HashSet<String>();
+        final Set<Long> errorCodes = new TreeSet<Long>();
+        final Set<String> exceptions = new TreeSet<String>();
     }
 
     private static final class ErrorRegistrationStatus {
@@ -385,50 +386,140 @@ public final class ErrorPageRegistry
         return result == -1;
     }
 
-    public Collection<ErrorPageRuntime> getErrorPageRuntimes()
+    public void getRuntimeInfo(final Collection<ServletState> servletStates,
+            final Collection<FailureServletState> failureServletStates)
     {
-        final Collection<ErrorPageRuntime> errorPages = new TreeSet<ErrorPageRuntime>(ServletRuntime.COMPARATOR);
-
         for(final ErrorRegistrationStatus status : this.statusMapping.values())
         {
             // TODO - we could do this calculation already when generating the status object
-            final Set<Long> activeCodes = new HashSet<Long>();
-            final Set<String> activeExceptions = new HashSet<String>();
-            final Set<Long> inactiveCodes = new HashSet<Long>();
-            final Set<String> inactiveExceptions = new HashSet<String>();
+            final ErrorRegistration active = new ErrorRegistration();
+            final Map<Integer, ErrorRegistration> inactive = new HashMap<Integer, ErrorRegistration>();
 
             for(Map.Entry<Long, Integer> codeEntry : status.errorCodeMapping.entrySet() )
             {
                 if ( codeEntry.getValue() == -1 )
                 {
-                    activeCodes.add(codeEntry.getKey());
+                    active.errorCodes.add(codeEntry.getKey());
                 }
                 else
                 {
-                    inactiveCodes.add(codeEntry.getKey());
+                    ErrorRegistration set = inactive.get(codeEntry.getValue());
+                    if ( set == null )
+                    {
+                        set = new ErrorRegistration();
+                        inactive.put(codeEntry.getValue(), set);
+                    }
+                    set.errorCodes.add(codeEntry.getKey());
                 }
             }
             for(Map.Entry<String, Integer> codeEntry : status.exceptionMapping.entrySet() )
             {
                 if ( codeEntry.getValue() == -1 )
                 {
-                    activeExceptions.add(codeEntry.getKey());
+                    active.exceptions.add(codeEntry.getKey());
                 }
                 else
                 {
-                    inactiveExceptions.add(codeEntry.getKey());
+                    ErrorRegistration set = inactive.get(codeEntry.getValue());
+                    if ( set == null )
+                    {
+                        set = new ErrorRegistration();
+                        inactive.put(codeEntry.getValue(), set);
+                    }
+                    set.exceptions.add(codeEntry.getKey());
                 }
             }
-            if ( !activeCodes.isEmpty() || !activeExceptions.isEmpty() )
+            if ( !active.errorCodes.isEmpty() || !active.exceptions.isEmpty() )
             {
-                errorPages.add(new ErrorPageRuntime(status.handler, activeCodes, activeExceptions));
+                servletStates.add(new ServletState()
+                {
+
+                    @Override
+                    public Servlet getServlet()
+                    {
+                        return status.handler.getServlet();
+                    }
+
+                    @Override
+                    public ServletInfo getServletInfo()
+                    {
+                        return status.handler.getServletInfo();
+                    }
+
+                    @Override
+                    public String[] getPatterns()
+                    {
+                        return null;
+                    }
+
+                    @Override
+                    public long[] getErrorCodes()
+                    {
+                        final long[] codes = new long[active.errorCodes.size()];
+                        final Iterator<Long> iter = active.errorCodes.iterator();
+                        for(int i=0; i<codes.length; i++)
+                        {
+                            codes[i] = iter.next();
+                        }
+                        return codes;
+                    }
+
+                    @Override
+                    public String[] getErrorExceptions()
+                    {
+                        return active.exceptions.toArray(new String[active.exceptions.size()]);
+                    }
+                });
             }
-            if ( !inactiveCodes.isEmpty() || !inactiveExceptions.isEmpty() )
+            for(final Map.Entry<Integer, ErrorRegistration> entry : inactive.entrySet())
             {
-                // add failure
+                failureServletStates.add(new FailureServletState()
+                {
+
+                    @Override
+                    public Servlet getServlet()
+                    {
+                        return status.handler.getServlet();
+                    }
+
+                    @Override
+                    public ServletInfo getServletInfo()
+                    {
+                        return status.handler.getServletInfo();
+                    }
+
+                    @Override
+                    public String[] getPatterns()
+                    {
+                        return null;
+                    }
+
+                    @Override
+                    public long[] getErrorCodes()
+                    {
+                        final long[] codes = new long[entry.getValue().errorCodes.size()];
+                        final Iterator<Long> iter = entry.getValue().errorCodes.iterator();
+                        for(int i=0; i<codes.length; i++)
+                        {
+                            codes[i] = iter.next();
+                        }
+                        return codes;
+                    }
+
+                    @Override
+                    public String[] getErrorExceptions()
+                    {
+                        return entry.getValue().exceptions.toArray(new String[entry.getValue().exceptions.size()]);
+                    }
+
+                    @Override
+                    public long getReason()
+                    {
+                        return entry.getKey();
+                    }
+
+                });
             }
         }
-
-        return errorPages;
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/FilterRegistry.java Mon May 18 12:44:55 2015
@@ -22,7 +22,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 
 import javax.annotation.CheckForNull;
@@ -32,8 +31,8 @@ import javax.servlet.DispatcherType;
 import org.apache.felix.http.base.internal.handler.FilterHandler;
 import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
-import org.apache.felix.http.base.internal.runtime.dto.FailureRuntime;
-import org.apache.felix.http.base.internal.runtime.dto.FilterRuntime;
+import org.apache.felix.http.base.internal.runtime.dto.state.FailureFilterState;
+import org.apache.felix.http.base.internal.runtime.dto.state.FilterState;
 
 /**
  * TODO - check if add/remove needs syncing
@@ -44,10 +43,19 @@ public final class FilterRegistry
 
     private final Map<FilterInfo, FilterRegistrationStatus> statusMapping = new ConcurrentHashMap<FilterInfo, FilterRegistrationStatus>();
 
-    private static final class FilterRegistrationStatus
+    private static final class FilterRegistrationStatus implements FailureFilterState
     {
         public int result;
         public FilterHandler handler;
+
+        @Override
+        public FilterInfo getFilterInfo() {
+            return handler.getFilterInfo();
+        }
+        @Override
+        public long getReason() {
+            return result;
+        }
     }
 
     public void addFilter(@Nonnull final FilterHandler handler)
@@ -134,11 +142,11 @@ public final class FilterRegistry
         return false;
     }
 
-    public Collection<FilterRuntime> getFilterRuntimes(final FailureRuntime.Builder failureRuntimeBuilder)
+    public void getRuntimeInfo(final Collection<FilterState> filterRuntimes,
+            final Collection<FailureFilterState> failureFilterRuntimes)
     {
         final HandlerMapping mapping = this.filterMapping;
-        final Collection<FilterRuntime> filterRuntimes = new TreeSet<FilterRuntime>(FilterRuntime.COMPARATOR);
-        for (final FilterRuntime filterRuntime : mapping.values())
+        for (final FilterState filterRuntime : mapping.values())
         {
             filterRuntimes.add(filterRuntime);
         }
@@ -147,9 +155,8 @@ public final class FilterRegistry
         {
             if ( status.getValue().result != -1 )
             {
-                failureRuntimeBuilder.add(status.getKey(), status.getValue().result);
+                failureFilterRuntimes.add(status.getValue());
             }
         }
-        return filterRuntimes;
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerRegistry.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/HandlerRegistry.java Mon May 18 12:44:55 2015
@@ -30,7 +30,6 @@ import org.apache.felix.http.base.intern
 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.dto.ContextRuntime;
-import org.apache.felix.http.base.internal.runtime.dto.FailureRuntime;
 
 /**
  * Registry for all services.
@@ -277,16 +276,13 @@ public final class HandlerRegistry
         return null;
     }
 
-    public List<ContextRuntime> getRuntime(FailureRuntime.Builder failureRuntimeBuilder)
+    public ContextRuntime getRuntime(final long contextId)
     {
-        final List<ContextRuntime> handlerRuntimes = new ArrayList<ContextRuntime>();
-
-        final List<PerContextHandlerRegistry> regs = this.registrations;
-        for (final PerContextHandlerRegistry contextRegistry : regs)
+        final PerContextHandlerRegistry reg = this.getRegistry(contextId);
+        if ( reg != null )
         {
-            handlerRuntimes.add(contextRegistry.getRuntime(failureRuntimeBuilder));
+            return reg.getRuntime();
         }
-
-        return handlerRuntimes;
+        return null;
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/PerContextHandlerRegistry.java Mon May 18 12:44:55 2015
@@ -16,6 +16,9 @@
  */
 package org.apache.felix.http.base.internal.registry;
 
+import java.util.Collection;
+import java.util.TreeSet;
+
 import javax.annotation.Nonnull;
 import javax.servlet.DispatcherType;
 
@@ -25,7 +28,10 @@ import org.apache.felix.http.base.intern
 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.dto.ContextRuntime;
-import org.apache.felix.http.base.internal.runtime.dto.FailureRuntime;
+import org.apache.felix.http.base.internal.runtime.dto.state.FailureFilterState;
+import org.apache.felix.http.base.internal.runtime.dto.state.FailureServletState;
+import org.apache.felix.http.base.internal.runtime.dto.state.FilterState;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 
 /**
  * This registry keeps track of all processing components per context:
@@ -184,14 +190,24 @@ public final class PerContextHandlerRegi
         return this.errorPageRegistry.get(exception, code);
     }
 
-    public ContextRuntime getRuntime(final FailureRuntime.Builder failureRuntimeBuilder)
+    public ContextRuntime getRuntime()
     {
+        final Collection<FilterState> filterRuntimes = new TreeSet<FilterState>(FilterState.COMPARATOR);
+        final Collection<FailureFilterState> failureFilterRuntimes = new TreeSet<FailureFilterState>(FailureFilterState.COMPARATOR);
+        this.filterRegistry.getRuntimeInfo(filterRuntimes, failureFilterRuntimes);
+
+        final Collection<ServletState> errorPageRuntimes = new TreeSet<ServletState>(ServletState.COMPARATOR);
+        final Collection<FailureServletState> failureErrorPageRuntimes = new TreeSet<FailureServletState>(FailureServletState.COMPARATOR);
+        this.errorPageRegistry.getRuntimeInfo(errorPageRuntimes, failureErrorPageRuntimes);
         // TODO - add servlets
         // TODO - add failures from filters and error pages
-        return new ContextRuntime(this.filterRegistry.getFilterRuntimes(failureRuntimeBuilder),
-                this.errorPageRegistry.getErrorPageRuntimes(),
+        return new ContextRuntime(filterRuntimes,
+                errorPageRuntimes,
+                null,
                 null,
+                failureFilterRuntimes,
+                failureErrorPageRuntimes,
                 null,
-                this.serviceId);
+                null);
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/BaseServletDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/BaseServletDTOBuilder.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/BaseServletDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/BaseServletDTOBuilder.java Mon May 18 12:44:55 2015
@@ -21,9 +21,10 @@ package org.apache.felix.http.base.inter
 import javax.servlet.Servlet;
 
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.service.http.runtime.dto.BaseServletDTO;
 
-abstract class BaseServletDTOBuilder<T extends ServletRuntime, U extends BaseServletDTO> extends BaseDTOBuilder<T, U>
+abstract class BaseServletDTOBuilder<T extends ServletState, U extends BaseServletDTO> extends BaseDTOBuilder<T, U>
 {
     BaseServletDTOBuilder(DTOFactory<U> servletDTOFactory)
     {

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ContextRuntime.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ContextRuntime.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ContextRuntime.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ContextRuntime.java Mon May 18 12:44:55 2015
@@ -19,61 +19,83 @@
 package org.apache.felix.http.base.internal.runtime.dto;
 
 import java.util.Collection;
-import java.util.Collections;
 
+import org.apache.felix.http.base.internal.runtime.dto.state.FailureFilterState;
+import org.apache.felix.http.base.internal.runtime.dto.state.FailureServletState;
+import org.apache.felix.http.base.internal.runtime.dto.state.FilterState;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
+
+/**
+ * Contains all information about a context wrt to the servlet/filter registry.
+ */
 public final class ContextRuntime
 {
-    private final Collection<FilterRuntime> filterRuntimes;
-    private final Collection<ErrorPageRuntime> errorPageRuntimes;
-    private final long serviceId;
-    private final Collection<ServletRuntime> servletRuntimes;
-    private final Collection<ServletRuntime> resourceRuntimes;
-
-
-    public ContextRuntime(Collection<FilterRuntime> filterRuntimes,
-            Collection<ErrorPageRuntime> errorPageRuntimes,
-            Collection<ServletRuntime> servletRuntimes,
-            Collection<ServletRuntime> resourceRuntimes,
-            long serviceId)
+    private final Collection<FilterState> filterRuntimes;
+    private final Collection<ServletState> errorPageRuntimes;
+    private final Collection<ServletState> servletRuntimes;
+    private final Collection<ServletState> resourceRuntimes;
+
+    private final Collection<FailureFilterState> failureFilterRuntimes;
+    private final Collection<FailureServletState> failureErrorPageRuntimes;
+    private final Collection<FailureServletState> failureServletRuntimes;
+    private final Collection<FailureServletState> failureResourceRuntimes;
+
+    public ContextRuntime(final Collection<FilterState> filterRuntimes,
+            final Collection<ServletState> errorPageRuntimes,
+            final Collection<ServletState> servletRuntimes,
+            final Collection<ServletState> resourceRuntimes,
+            final Collection<FailureFilterState> failureFilterRuntimes,
+            final Collection<FailureServletState> failureErrorPageRuntimes,
+            final Collection<FailureServletState> failureServletRuntimes,
+            final Collection<FailureServletState> failureResourceRuntimes)
     {
         this.filterRuntimes = filterRuntimes;
         this.errorPageRuntimes = errorPageRuntimes;
-        this.serviceId = serviceId;
         this.servletRuntimes = servletRuntimes;
         this.resourceRuntimes = resourceRuntimes;
+        this.failureFilterRuntimes = failureFilterRuntimes;
+        this.failureErrorPageRuntimes = failureErrorPageRuntimes;
+        this.failureServletRuntimes = failureServletRuntimes;
+        this.failureResourceRuntimes = failureResourceRuntimes;
     }
 
-    public static ContextRuntime empty(long serviceId)
-    {
-        return new ContextRuntime(Collections.<FilterRuntime>emptyList(),
-                Collections.<ErrorPageRuntime> emptyList(),
-                Collections.<ServletRuntime> emptyList(),
-                Collections.<ServletRuntime> emptyList(),
-                serviceId);
-    }
-
-    Collection<ServletRuntime> getServletRuntimes()
+    Collection<ServletState> getServletRuntimes()
     {
         return servletRuntimes;
     }
 
-    Collection<ServletRuntime> getResourceRuntimes()
+    Collection<ServletState> getResourceRuntimes()
     {
         return resourceRuntimes;
     }
 
-    Collection<FilterRuntime> getFilterRuntimes()
+    Collection<FilterState> getFilterRuntimes()
     {
         return filterRuntimes;
     }
 
-    Collection<ErrorPageRuntime> getErrorPageRuntimes()
+    Collection<ServletState> getErrorPageRuntimes()
     {
         return errorPageRuntimes;
     }
 
-    public long getServiceId()
+    Collection<FailureServletState> getFailureServletRuntimes()
+    {
+        return failureServletRuntimes;
+    }
+
+    Collection<FailureServletState> getFailureResourceRuntimes()
+    {
+        return failureResourceRuntimes;
+    }
+
+    Collection<FailureFilterState> getFailureFilterRuntimes()
+    {
+        return failureFilterRuntimes;
+    }
+
+    Collection<FailureServletState> getFailureErrorPageRuntimes()
     {
-        return serviceId;
+        return failureErrorPageRuntimes;
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ErrorPageDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ErrorPageDTOBuilder.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ErrorPageDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ErrorPageDTOBuilder.java Mon May 18 12:44:55 2015
@@ -18,12 +18,10 @@
  */
 package org.apache.felix.http.base.internal.runtime.dto;
 
-import java.util.Collection;
-import java.util.Iterator;
-
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.service.http.runtime.dto.ErrorPageDTO;
 
-final class ErrorPageDTOBuilder<T extends ErrorPageDTO> extends BaseServletDTOBuilder<ErrorPageRuntime, T>
+final class ErrorPageDTOBuilder<T extends ErrorPageDTO> extends BaseServletDTOBuilder<ServletState, T>
 {
     static ErrorPageDTOBuilder<ErrorPageDTO> create()
     {
@@ -36,22 +34,11 @@ final class ErrorPageDTOBuilder<T extend
     }
 
     @Override
-    T buildDTO(ErrorPageRuntime errorPage, long servletConextId)
+    T buildDTO(ServletState errorPage, long servletConextId)
     {
         T errorPageDTO = super.buildDTO(errorPage, servletConextId);
-        errorPageDTO.errorCodes = getErrorCodes(errorPage.getErrorCodes());
-        errorPageDTO.exceptions = errorPage.getExceptions().toArray(BuilderConstants.STRING_ARRAY);
+        errorPageDTO.errorCodes = errorPage.getErrorCodes();
+        errorPageDTO.exceptions = errorPage.getErrorExceptions();
         return errorPageDTO;
     }
-
-    private long[] getErrorCodes(Collection<Long> errorCodes)
-    {
-        Iterator<Long> itr = errorCodes.iterator();
-        long[] result = new long[errorCodes.size()];
-        for (int i = 0; i < result.length; i++)
-        {
-            result[i] = itr.next();
-        }
-        return result;
-    }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailureRuntime.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailureRuntime.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailureRuntime.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailureRuntime.java Mon May 18 12:44:55 2015
@@ -37,6 +37,8 @@ import org.apache.felix.http.base.intern
 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.dto.state.FilterState;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.http.runtime.dto.FailedErrorPageDTO;
 import org.osgi.service.http.runtime.dto.FailedFilterDTO;
@@ -47,10 +49,10 @@ import org.osgi.service.http.runtime.dto
 
 public final class FailureRuntime
 {
-    private static final FailureComparator<ErrorPageRuntime> ERROR_PAGE_COMPARATOR = FailureComparator.<ErrorPageRuntime>create(ServletRuntime.COMPARATOR);
-    private static final FailureComparator<FilterRuntime> FILTER_COMPARATOR = FailureComparator.create(FilterRuntime.COMPARATOR);
+    private static final FailureComparator<ServletState> ERROR_PAGE_COMPARATOR = FailureComparator.<ServletState>create(ServletState.COMPARATOR);
+    private static final FailureComparator<FilterState> FILTER_COMPARATOR = FailureComparator.create(FilterState.COMPARATOR);
     private static final FailureComparator<ServletContextHelperRuntime> CONTEXT_COMPARATOR = FailureComparator.create(ServletContextHelperRuntime.COMPARATOR);
-    private static final FailureComparator<ServletRuntime> SERVLET_COMPARATOR = FailureComparator.create(ServletRuntime.COMPARATOR);
+    private static final FailureComparator<ServletState> SERVLET_COMPARATOR = FailureComparator.create(ServletState.COMPARATOR);
     private static final Comparator<Failure<ServiceReference<?>>> REFERENCE_COMPARATOR = new Comparator<Failure<ServiceReference<?>>>()
     {
         @Override
@@ -61,18 +63,18 @@ public final class FailureRuntime
     };
 
     private final List<Failure<ServletContextHelperRuntime>> contextRuntimes;
-    private final List<Failure<ServletRuntime>> servletRuntimes;
-    private final List<Failure<FilterRuntime>> filterRuntimes;
-    private final List<Failure<ServletRuntime>> resourceRuntimes;
-    private final List<Failure<ErrorPageRuntime>> errorPageRuntimes;
+    private final List<Failure<ServletState>> servletRuntimes;
+    private final List<Failure<FilterState>> filterRuntimes;
+    private final List<Failure<ServletState>> resourceRuntimes;
+    private final List<Failure<ServletState>> errorPageRuntimes;
     private final List<Failure<ServiceReference<?>>> listenerRuntimes;
 
     private FailureRuntime(List<Failure<ServletContextHelperRuntime>> contextRuntimes,
             List<Failure<ServiceReference<?>>> listenerRuntimes,
-            List<Failure<ServletRuntime>> servletRuntimes,
-            List<Failure<FilterRuntime>> filterRuntimes,
-            List<Failure<ServletRuntime>> resourceRuntimes,
-            List<Failure<ErrorPageRuntime>> errorPageRuntimes)
+            List<Failure<ServletState>> servletRuntimes,
+            List<Failure<FilterState>> filterRuntimes,
+            List<Failure<ServletState>> resourceRuntimes,
+            List<Failure<ServletState>> errorPageRuntimes)
     {
         this.contextRuntimes = contextRuntimes;
         this.servletRuntimes = servletRuntimes;
@@ -86,10 +88,10 @@ public final class FailureRuntime
     {
         return new FailureRuntime(Collections.<Failure<ServletContextHelperRuntime>>emptyList(),
                 Collections.<Failure<ServiceReference<?>>>emptyList(),
-                Collections.<Failure<ServletRuntime>>emptyList(),
-                Collections.<Failure<FilterRuntime>>emptyList(),
-                Collections.<Failure<ServletRuntime>>emptyList(),
-                Collections.<Failure<ErrorPageRuntime>>emptyList());
+                Collections.<Failure<ServletState>>emptyList(),
+                Collections.<Failure<FilterState>>emptyList(),
+                Collections.<Failure<ServletState>>emptyList(),
+                Collections.<Failure<ServletState>>emptyList());
     }
 
     public static FailureRuntime.Builder builder()
@@ -100,14 +102,14 @@ public final class FailureRuntime
     public FailedServletDTO[] getServletDTOs()
     {
         List<FailedServletDTO> servletDTOs = new ArrayList<FailedServletDTO>();
-        for (Failure<ServletRuntime> failure : servletRuntimes)
+        for (Failure<ServletState> failure : servletRuntimes)
         {
             servletDTOs.add(getServletDTO(failure.service, failure.failureCode));
         }
         return servletDTOs.toArray(SERVLET_FAILURE_DTO_ARRAY);
     }
 
-    private FailedServletDTO getServletDTO(ServletRuntime failedServlet, int failureCode)
+    private FailedServletDTO getServletDTO(ServletState failedServlet, int failureCode)
     {
         ServletDTOBuilder<FailedServletDTO> dtoBuilder = new ServletDTOBuilder<FailedServletDTO>(DTOFactories.FAILED_SERVLET);
         FailedServletDTO servletDTO = dtoBuilder.buildDTO(failedServlet, 0);
@@ -118,14 +120,14 @@ public final class FailureRuntime
     public FailedFilterDTO[] getFilterDTOs()
     {
         List<FailedFilterDTO> filterDTOs = new ArrayList<FailedFilterDTO>();
-        for (Failure<FilterRuntime> failure : filterRuntimes)
+        for (Failure<FilterState> failure : filterRuntimes)
         {
             filterDTOs.add(getFilterDTO(failure.service, failure.failureCode));
         }
         return filterDTOs.toArray(FILTER_FAILURE_DTO_ARRAY);
     }
 
-    private FailedFilterDTO getFilterDTO(FilterRuntime failedFilter, int failureCode)
+    private FailedFilterDTO getFilterDTO(FilterState failedFilter, int failureCode)
     {
         FilterDTOBuilder<FailedFilterDTO> dtoBuilder = new FilterDTOBuilder<FailedFilterDTO>(DTOFactories.FAILED_FILTER);
         FailedFilterDTO filterDTO = dtoBuilder.buildDTO(failedFilter, 0);
@@ -136,14 +138,14 @@ public final class FailureRuntime
     public FailedResourceDTO[] getResourceDTOs()
     {
         List<FailedResourceDTO> resourceDTOs = new ArrayList<FailedResourceDTO>();
-        for (Failure<ServletRuntime> failure : resourceRuntimes)
+        for (Failure<ServletState> failure : resourceRuntimes)
         {
             resourceDTOs.add(getResourceDTO(failure.service, failure.failureCode));
         }
         return resourceDTOs.toArray(RESOURCE_FAILURE_DTO_ARRAY);
     }
 
-    private FailedResourceDTO getResourceDTO(ServletRuntime failedResource, int failureCode)
+    private FailedResourceDTO getResourceDTO(ServletState failedResource, int failureCode)
     {
         ResourceDTOBuilder<FailedResourceDTO> dtoBuilder = new ResourceDTOBuilder<FailedResourceDTO>(DTOFactories.FAILED_RESOURCE);
         FailedResourceDTO resourceDTO = dtoBuilder.buildDTO(failedResource, 0);
@@ -154,14 +156,14 @@ public final class FailureRuntime
     public FailedErrorPageDTO[] getErrorPageDTOs()
     {
         List<FailedErrorPageDTO> errorPageDTOs = new ArrayList<FailedErrorPageDTO>();
-        for (Failure<ErrorPageRuntime> failure : errorPageRuntimes)
+        for (Failure<ServletState> failure : errorPageRuntimes)
         {
             errorPageDTOs.add(getErrorPageDTO(failure.service, failure.failureCode));
         }
         return errorPageDTOs.toArray(ERROR_PAGE_FAILURE_DTO_ARRAY);
     }
 
-    private FailedErrorPageDTO getErrorPageDTO(ErrorPageRuntime failedErrorPage, int failureCode)
+    private FailedErrorPageDTO getErrorPageDTO(ServletState failedErrorPage, int failureCode)
     {
         ErrorPageDTOBuilder<FailedErrorPageDTO> dtoBuilder = new ErrorPageDTOBuilder<FailedErrorPageDTO>(DTOFactories.FAILED_ERROR_PAGE);
         FailedErrorPageDTO errorPageDTO = dtoBuilder.buildDTO(failedErrorPage, 0);
@@ -208,10 +210,10 @@ public final class FailureRuntime
     public static class Builder
     {
         private final List<Failure<ServletContextHelperRuntime>> contextRuntimes = new ArrayList<FailureRuntime.Failure<ServletContextHelperRuntime>>();
-        private final List<Failure<ServletRuntime>> servletRuntimes = new ArrayList<Failure<ServletRuntime>>();
-        private final List<Failure<FilterRuntime>> filterRuntimes = new ArrayList<Failure<FilterRuntime>>();
-        private final List<Failure<ServletRuntime>> resourceRuntimes = new ArrayList<Failure<ServletRuntime>>();
-        private final List<Failure<ErrorPageRuntime>> errorPageRuntimes = new ArrayList<Failure<ErrorPageRuntime>>();
+        private final List<Failure<ServletState>> servletRuntimes = new ArrayList<Failure<ServletState>>();
+        private final List<Failure<FilterState>> filterRuntimes = new ArrayList<Failure<FilterState>>();
+        private final List<Failure<ServletState>> resourceRuntimes = new ArrayList<Failure<ServletState>>();
+        private final List<Failure<ServletState>> errorPageRuntimes = new ArrayList<Failure<ServletState>>();
         private final List<Failure<ServiceReference<?>>> listenerRuntimes = new ArrayList<Failure<ServiceReference<?>>>();
 
         public FailureRuntime.Builder add(Map<AbstractInfo<?>, Integer> failureInfos)
@@ -227,30 +229,33 @@ public final class FailureRuntime
         {
             if (info instanceof ServletContextHelperInfo)
             {
-                ServletContextHelperRuntime servletRuntime = new InfoServletContextHelperRuntime((ServletContextHelperInfo) info);
-                contextRuntimes.add(new Failure<ServletContextHelperRuntime>(servletRuntime, failureCode));
+                // TODO
+//                ServletContextHelperRuntime servletRuntime = new InfoServletContextHelperRuntime((ServletContextHelperInfo) info);
+//                contextRuntimes.add(new Failure<ServletContextHelperRuntime>(servletRuntime, failureCode));
             }
             else if (info instanceof ServletInfo && ((ServletInfo) info).getErrorPage() != null)
             {
                 // TODO
-                FailureServletRuntime servletRuntime = new FailureServletRuntime((ServletInfo) info);
+//                FailureServletState servletRuntime = new FailureServletRuntime((ServletInfo) info);
 //                ErrorPageRuntime errorPageRuntime = ErrorPageRuntime.fromServletRuntime(servletRuntime);
 //                errorPageRuntimes.add(new Failure<ErrorPageRuntime>(errorPageRuntime, failureCode));
             }
             else if (info instanceof ServletInfo)
             {
-                ServletRuntime servletRuntime = new FailureServletRuntime((ServletInfo) info);
-                servletRuntimes.add(new Failure<ServletRuntime>(servletRuntime, failureCode));
+                // TODO
+//                ServletState servletRuntime = new FailureServletState((ServletInfo) info);
+//                servletRuntimes.add(new Failure<ServletRuntime>(servletRuntime, failureCode));
             }
             else if (info instanceof FilterInfo)
             {
-                FilterRuntime filterRuntime = new FailureFilterRuntime((FilterInfo) info);
-                filterRuntimes.add(new Failure<FilterRuntime>(filterRuntime, failureCode));
+                // TODO
+//                FilterState filterRuntime = new FailureFilterState((FilterInfo) info, failureCode);
+//                filterRuntimes.add(new Failure<FilterState>(filterRuntime, failureCode));
             }
             else if (info instanceof ResourceInfo)
             {
-                ServletRuntime servletRuntime = new FailureServletRuntime(new ServletInfo((ResourceInfo) info));
-                resourceRuntimes.add(new Failure<ServletRuntime>(servletRuntime, failureCode));
+//                ServletState servletRuntime = new FailureServletRuntime(new ServletInfo((ResourceInfo) info));
+//                resourceRuntimes.add(new Failure<ServletRuntime>(servletRuntime, failureCode));
             }
             else if (info instanceof ListenerInfo)
             {

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FilterDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FilterDTOBuilder.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FilterDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FilterDTOBuilder.java Mon May 18 12:44:55 2015
@@ -21,9 +21,10 @@ package org.apache.felix.http.base.inter
 import javax.servlet.DispatcherType;
 
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
+import org.apache.felix.http.base.internal.runtime.dto.state.FilterState;
 import org.osgi.service.http.runtime.dto.FilterDTO;
 
-final class FilterDTOBuilder<T extends FilterDTO> extends BaseDTOBuilder<FilterRuntime, T>
+final class FilterDTOBuilder<T extends FilterDTO> extends BaseDTOBuilder<FilterState, T>
 {
     static FilterDTOBuilder<FilterDTO> create()
     {
@@ -36,7 +37,7 @@ final class FilterDTOBuilder<T extends F
     }
 
     @Override
-    T buildDTO(FilterRuntime filterRuntime, long servletContextId)
+    T buildDTO(FilterState filterRuntime, long servletContextId)
     {
         FilterInfo info = filterRuntime.getFilterInfo();
 

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java Mon May 18 12:44:55 2015
@@ -22,62 +22,28 @@ import static org.osgi.service.http.whit
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TreeSet;
 
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.framework.ServiceReference;
 
 public final class RegistryRuntime
 {
     private final Collection<ServletContextHelperRuntime> contexts;
-    private final Map<Long, Collection<ServiceReference<?>>> listenerRuntimes;
-    private final Map<Long, ContextRuntime> handlerRuntimes;
     private final FailureRuntime failureRuntime;
 
     public RegistryRuntime(Collection<ServletContextHelperRuntime> contexts,
-            Collection<ContextRuntime> contextRuntimes,
-            Map<Long, Collection<ServiceReference<?>>> listenerRuntimes,
             FailureRuntime failureRuntime)
     {
         this.contexts = contexts;
         this.failureRuntime = failureRuntime;
-        this.handlerRuntimes = createServiceIdMap(contextRuntimes);
-        // TODO
-//        this.servletRuntimes = createServletServiceIdMap(servletRegistryRuntime.getServletRuntimes());
-//        this.resourceRuntimes = createServletServiceIdMap(servletRegistryRuntime.getResourceRuntimes());
-        this.listenerRuntimes = listenerRuntimes;
     }
 
-    private static Map<Long, ContextRuntime> createServiceIdMap(Collection<ContextRuntime> contextRuntimes)
-    {
-        Map<Long, ContextRuntime> runtimesMap = new HashMap<Long, ContextRuntime>();
-        for (ContextRuntime contextRuntime : contextRuntimes)
-        {
-            runtimesMap.put(contextRuntime.getServiceId(), contextRuntime);
-        }
-        return runtimesMap;
-    }
 
-    private static Map<Long, Collection<ServletRuntime>> createServletServiceIdMap(Collection<ServletRuntime> runtimes)
-    {
-        Map<Long, Collection<ServletRuntime>> runtimesMap = new HashMap<Long, Collection<ServletRuntime>>();
-        for (ServletRuntime runtime : runtimes)
-        {
-            long contextServiceId = runtime.getContextServiceId();
-            if (!runtimesMap.containsKey(contextServiceId))
-            {
-                runtimesMap.put(contextServiceId, new TreeSet<ServletRuntime>(ServletRuntime.COMPARATOR));
-            }
-            runtimesMap.get(contextServiceId).add(runtime);
-        }
-        return runtimesMap;
-    }
 
     public ContextRuntime getHandlerRuntime(ServletContextHelperRuntime contextRuntime)
     {
         long serviceId = contextRuntime.getContextInfo().getServiceId();
-
+/**
         if (handlerRuntimes.containsKey(serviceId) && isDefaultContext(contextRuntime))
         {
             // TODO Merge with the default context of the HttpService ( handlerRuntimes.get(0) )
@@ -86,11 +52,11 @@ public final class RegistryRuntime
         else if (handlerRuntimes.containsKey(serviceId))
         {
             return handlerRuntimes.get(serviceId);
-        }
-        return ContextRuntime.empty(serviceId);
+        }**/
+        return null; //ContextRuntime.empty(serviceId);
     }
 
-    public Collection<ServletRuntime> getServletRuntimes(ServletContextHelperRuntime contextRuntime)
+    public Collection<ServletState> getServletRuntimes(ServletContextHelperRuntime contextRuntime)
     {
         /* TODO
         if (servletRuntimes.containsKey(contextRuntime.getContextInfo().getServiceId()))
@@ -101,7 +67,7 @@ public final class RegistryRuntime
         return Collections.emptyList();
     }
 
-    public Collection<ServletRuntime> getResourceRuntimes(ServletContextHelperRuntime contextRuntime)
+    public Collection<ServletState> getResourceRuntimes(ServletContextHelperRuntime contextRuntime)
     {
         /* TODO
         if (resourceRuntimes.containsKey(contextRuntime.getContextInfo().getServiceId()))
@@ -119,10 +85,11 @@ public final class RegistryRuntime
 
     public Collection<ServiceReference<?>> getListenerRuntimes(ServletContextHelperRuntime contextRuntime)
     {
+        /**
         if (listenerRuntimes.containsKey(contextRuntime.getContextInfo().getServiceId()))
         {
             return listenerRuntimes.get(contextRuntime.getContextInfo().getServiceId());
-        }
+        }*/
         return Collections.emptyList();
     }
 

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RequestInfoDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RequestInfoDTOBuilder.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RequestInfoDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RequestInfoDTOBuilder.java Mon May 18 12:44:55 2015
@@ -18,9 +18,13 @@ package org.apache.felix.http.base.inter
 
 import static java.util.Arrays.asList;
 
+import javax.servlet.Servlet;
+
 import org.apache.felix.http.base.internal.handler.FilterHandler;
 import org.apache.felix.http.base.internal.registry.HandlerRegistry;
 import org.apache.felix.http.base.internal.registry.PathResolution;
+import org.apache.felix.http.base.internal.runtime.ServletInfo;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.service.http.runtime.dto.FilterDTO;
 import org.osgi.service.http.runtime.dto.RequestInfoDTO;
 
@@ -53,12 +57,80 @@ public final class RequestInfoDTOBuilder
         if (pr.handler.getServletInfo().isResource())
         {
             requestInfoDTO.resourceDTO = ResourceDTOBuilder.create()
-                    .buildDTO(pr.handler, pr.handler.getContextServiceId());
+                    .buildDTO(new ServletState()
+                    {
+
+                        @Override
+                        public ServletInfo getServletInfo()
+                        {
+                            // TODO Auto-generated method stub
+                            return pr.handler.getServletInfo();
+                        }
+
+                        @Override
+                        public Servlet getServlet()
+                        {
+                            // TODO Auto-generated method stub
+                            return pr.handler.getServlet();
+                        }
+
+                        @Override
+                        public String[] getPatterns()
+                        {
+                            return pr.handler.getServletInfo().getPatterns();
+                        }
+
+                        @Override
+                        public String[] getErrorExceptions()
+                        {
+                            return null;
+                        }
+
+                        @Override
+                        public long[] getErrorCodes()
+                        {
+                            return null;
+                        }
+                    },
+
+                            pr.handler.getContextServiceId());
         }
         else
         {
             requestInfoDTO.servletDTO = ServletDTOBuilder.create()
-                    .buildDTO(pr.handler, pr.handler.getContextServiceId());
+                    .buildDTO(new ServletState()
+                    {
+
+                        @Override
+                        public ServletInfo getServletInfo()
+                        {
+                            return pr.handler.getServletInfo();
+                        }
+
+                        @Override
+                        public Servlet getServlet()
+                        {
+                            return pr.handler.getServlet();
+                        }
+
+                        @Override
+                        public String[] getPatterns()
+                        {
+                            return pr.handler.getServletInfo().getPatterns();
+                        }
+
+                        @Override
+                        public String[] getErrorExceptions()
+                        {
+                            return new String[0];
+                        }
+
+                        @Override
+                        public long[] getErrorCodes()
+                        {
+                            return new long[0];
+                        }
+                    }, pr.handler.getContextServiceId());
         }
 
         final FilterHandler[] filterHandlers = registry.getFilters(pr, null, path);

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ResourceDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ResourceDTOBuilder.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ResourceDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ResourceDTOBuilder.java Mon May 18 12:44:55 2015
@@ -19,9 +19,10 @@
 package org.apache.felix.http.base.internal.runtime.dto;
 
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.service.http.runtime.dto.ResourceDTO;
 
-final class ResourceDTOBuilder<T extends ResourceDTO> extends BaseDTOBuilder<ServletRuntime, T>
+final class ResourceDTOBuilder<T extends ResourceDTO> extends BaseDTOBuilder<ServletState, T>
 {
     static ResourceDTOBuilder<ResourceDTO> create()
     {
@@ -34,7 +35,7 @@ final class ResourceDTOBuilder<T extends
     }
 
     @Override
-    T buildDTO(ServletRuntime runtime, long servletContextId)
+    T buildDTO(ServletState runtime, long servletContextId)
     {
         ServletInfo servletInfo = runtime.getServletInfo();
 

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java Mon May 18 12:44:55 2015
@@ -18,12 +18,12 @@
  */
 package org.apache.felix.http.base.internal.runtime.dto;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
+import org.apache.felix.http.base.internal.runtime.dto.state.FilterState;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
@@ -96,27 +96,29 @@ public final class RuntimeDTOBuilder
 
     private ServletContextDTO[] createContextDTOs()
     {
-        List<ServletContextDTO> contextDTOs = new ArrayList<ServletContextDTO>();
-        for (ServletContextHelperRuntime context : registry.getContexts())
+        final Collection<ServletContextHelperRuntime> contexts = registry.getContexts();
+        final ServletContextDTO[] result = new ServletContextDTO[contexts.size()];
+        int index = 0;
+        for (final ServletContextHelperRuntime context : contexts)
         {
-            contextDTOs.add(createContextDTO(context,
+            result[index++] = createContextDTO(context,
                     registry.getHandlerRuntime(context),
                     registry.getServletRuntimes(context),
                     registry.getResourceRuntimes(context),
-                    registry.getListenerRuntimes(context)));
+                    registry.getListenerRuntimes(context));
         }
-        return contextDTOs.toArray(BuilderConstants.CONTEXT_DTO_ARRAY);
+        return result;
     }
 
     private ServletContextDTO createContextDTO(ServletContextHelperRuntime context,
             ContextRuntime contextRuntime,
-            Collection<ServletRuntime> servletRuntimes,
-            Collection<ServletRuntime> resourceRuntimes,
+            Collection<ServletState> servletRuntimes,
+            Collection<ServletState> resourceRuntimes,
             Collection<ServiceReference<?>> listenerRuntimes)
     {
-        Collection<FilterRuntime> filterRuntimes = contextRuntime.getFilterRuntimes();
-        Collection<ErrorPageRuntime> errorPageRuntimes = contextRuntime.getErrorPageRuntimes();
-        long servletContextId = contextRuntime.getServiceId();
+        Collection<FilterState> filterRuntimes = contextRuntime.getFilterRuntimes();
+        Collection<ServletState> errorPageRuntimes = contextRuntime.getErrorPageRuntimes();
+        long servletContextId = context.getContextInfo().getServiceId();
 
         Collection<ServletDTO> servletDTOs = ServletDTOBuilder.create().build(servletRuntimes, servletContextId);
         Collection<ResourceDTO> resourceDTOs = ResourceDTOBuilder.create().build(resourceRuntimes, servletContextId);

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextHelperRuntime.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextHelperRuntime.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextHelperRuntime.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextHelperRuntime.java Mon May 18 12:44:55 2015
@@ -18,11 +18,13 @@
  */
 package org.apache.felix.http.base.internal.runtime.dto;
 
+import java.util.Collection;
 import java.util.Comparator;
 
 import javax.servlet.ServletContext;
 
 import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
+import org.osgi.framework.ServiceReference;
 
 public interface ServletContextHelperRuntime
 {
@@ -38,4 +40,8 @@ public interface ServletContextHelperRun
     ServletContext getSharedContext();
 
     ServletContextHelperInfo getContextInfo();
+
+    ContextRuntime getContextRuntime();
+
+    Collection<ServiceReference<?>> getListeners();
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletDTOBuilder.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletDTOBuilder.java Mon May 18 12:44:55 2015
@@ -19,9 +19,10 @@
 package org.apache.felix.http.base.internal.runtime.dto;
 
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
+import org.apache.felix.http.base.internal.runtime.dto.state.ServletState;
 import org.osgi.service.http.runtime.dto.ServletDTO;
 
-final class ServletDTOBuilder<T extends ServletDTO> extends BaseServletDTOBuilder<ServletRuntime, T>
+final class ServletDTOBuilder<T extends ServletDTO> extends BaseServletDTOBuilder<ServletState, T>
 {
     static ServletDTOBuilder<ServletDTO> create()
     {
@@ -34,7 +35,7 @@ final class ServletDTOBuilder<T extends
     }
 
     @Override
-    T buildDTO(ServletRuntime servletRuntime, long servletContextId)
+    T buildDTO(ServletState servletRuntime, long servletContextId)
     {
         ServletInfo info = servletRuntime.getServletInfo();
 

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureFilterState.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureFilterState.java?rev=1680011&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureFilterState.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureFilterState.java Mon May 18 12:44:55 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.runtime.dto.state;
+
+
+public interface FailureFilterState extends FilterState {
+
+    long getReason();
+}

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureFilterState.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureFilterState.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureServletState.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureServletState.java?rev=1680011&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureServletState.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureServletState.java Mon May 18 12:44:55 2015
@@ -0,0 +1,25 @@
+/*
+ * 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.runtime.dto.state;
+
+
+public interface FailureServletState extends ServletState
+{
+    long getReason();
+}

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureServletState.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FailureServletState.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FilterState.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FilterState.java?rev=1680011&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FilterState.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FilterState.java Mon May 18 12:44:55 2015
@@ -0,0 +1,37 @@
+/*
+ * 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.runtime.dto.state;
+
+import java.util.Comparator;
+
+import org.apache.felix.http.base.internal.runtime.FilterInfo;
+
+public interface FilterState {
+
+    static final Comparator<FilterState> COMPARATOR = new Comparator<FilterState>()
+    {
+        @Override
+        public int compare(final FilterState o1, final FilterState o2)
+        {
+            return o1.getFilterInfo().compareTo(o2.getFilterInfo());
+        }
+    };
+
+    FilterInfo getFilterInfo();
+}

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FilterState.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/FilterState.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/ServletState.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/ServletState.java?rev=1680011&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/ServletState.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/ServletState.java Mon May 18 12:44:55 2015
@@ -0,0 +1,47 @@
+/*
+ * 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.runtime.dto.state;
+
+import java.util.Comparator;
+
+import javax.servlet.Servlet;
+
+import org.apache.felix.http.base.internal.runtime.ServletInfo;
+
+public interface ServletState
+{
+    static final Comparator<ServletState> COMPARATOR = new Comparator<ServletState>()
+    {
+        @Override
+        public int compare(ServletState o1, ServletState o2)
+        {
+            return o1.getServletInfo().compareTo(o2.getServletInfo());
+        }
+    };
+
+    Servlet getServlet();
+
+    ServletInfo getServletInfo();
+
+    String[] getPatterns();
+
+    long[] getErrorCodes();
+
+    String[] getErrorExceptions();
+}

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/ServletState.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/state/ServletState.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceRuntimeImpl.java Mon May 18 12:44:55 2015
@@ -22,7 +22,6 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.felix.http.base.internal.registry.HandlerRegistry;
-import org.apache.felix.http.base.internal.runtime.dto.RegistryRuntime;
 import org.apache.felix.http.base.internal.runtime.dto.RequestInfoDTOBuilder;
 import org.apache.felix.http.base.internal.runtime.dto.RuntimeDTOBuilder;
 import org.apache.felix.http.base.internal.whiteboard.WhiteboardManager;
@@ -50,8 +49,8 @@ public final class HttpServiceRuntimeImp
     @Override
     public RuntimeDTO getRuntimeDTO()
     {
-        RegistryRuntime runtime = contextManager.getRuntime(registry);
-        RuntimeDTOBuilder runtimeDTOBuilder = new RuntimeDTOBuilder(runtime, this.serviceReference);
+        final RuntimeDTOBuilder runtimeDTOBuilder = new RuntimeDTOBuilder(contextManager.getRuntime(registry),
+                this.serviceReference);
         return runtimeDTOBuilder.build();
     }
 
@@ -84,7 +83,8 @@ public final class HttpServiceRuntimeImp
     }
 
     public void setServiceReference(
-            final ServiceReference<HttpServiceRuntime> reference) {
+            final ServiceReference<HttpServiceRuntime> reference)
+    {
         this.serviceReference = reference;
     }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ContextHandler.java Mon May 18 12:44:55 2015
@@ -24,12 +24,11 @@ import javax.servlet.ServletContext;
 
 import org.apache.felix.http.base.internal.context.ExtServletContext;
 import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
-import org.apache.felix.http.base.internal.runtime.dto.ServletContextHelperRuntime;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceObjects;
 import org.osgi.service.http.context.ServletContextHelper;
 
-public final class ContextHandler implements Comparable<ContextHandler>, ServletContextHelperRuntime
+public final class ContextHandler implements Comparable<ContextHandler>
 {
     /** The info object for the context. */
     private final ServletContextHelperInfo info;
@@ -59,7 +58,6 @@ public final class ContextHandler implem
                 eventListener);
     }
 
-    @Override
     public ServletContextHelperInfo getContextInfo()
     {
         return this.info;
@@ -81,7 +79,6 @@ public final class ContextHandler implem
         this.ungetServletContext(bundle);
     }
 
-    @Override
     public ServletContext getSharedContext()
     {
         return sharedContext;

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=1680011&r1=1680010&r2=1680011&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 Mon May 18 12:44:55 2015
@@ -61,7 +61,6 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.runtime.WhiteboardServiceInfo;
 import org.apache.felix.http.base.internal.runtime.dto.ContextRuntime;
 import org.apache.felix.http.base.internal.runtime.dto.FailureRuntime;
-import org.apache.felix.http.base.internal.runtime.dto.InfoServletContextHelperRuntime;
 import org.apache.felix.http.base.internal.runtime.dto.RegistryRuntime;
 import org.apache.felix.http.base.internal.runtime.dto.ServletContextHelperRuntime;
 import org.apache.felix.http.base.internal.service.HttpServiceFactory;
@@ -744,36 +743,78 @@ public final class WhiteboardManager
 
     private static final String HTTP_SERVICE_CONTEXT_NAME = "Http Service context";
 
-    public RegistryRuntime getRuntime(HandlerRegistry registry)
+    public RegistryRuntime getRuntime(final HandlerRegistry registry)
     {
+        // we create a ServletContextHelperRuntime for each servlet context
         final Collection<ServletContextHelperRuntime> contextRuntimes = new TreeSet<ServletContextHelperRuntime>(ServletContextHelperRuntime.COMPARATOR);
-        List<ContextRuntime> handlerRuntimes;
-        final Map<Long, Collection<ServiceReference<?>>> listenerRuntimes = new HashMap<Long, Collection<ServiceReference<?>>>();
+
         final FailureRuntime.Builder failureRuntime = FailureRuntime.builder();
         synchronized ( this.contextMap )
         {
-            for (List<ContextHandler> contextHandlerList : this.contextMap.values())
+            for (final List<ContextHandler> contextHandlerList : this.contextMap.values())
             {
                 if ( !contextHandlerList.isEmpty() )
                 {
                     final ContextHandler handler = contextHandlerList.get(0);
-                    contextRuntimes.add(handler);
+                    final ContextRuntime cr = registry.getRuntime(handler.getContextInfo().getServiceId());
+                    if ( cr != null )
+                    {
+                        contextRuntimes.add(new ServletContextHelperRuntime() {
 
-                    final long serviceId = handler.getContextInfo().getServiceId();
-                    listenerRuntimes.put(serviceId, handler.getListenerRegistry().getRuntime());
+                            @Override
+                            public ServletContext getSharedContext() {
+                                return handler.getSharedContext();
+                            }
+
+                            @Override
+                            public Collection<ServiceReference<?>> getListeners() {
+                                return handler.getListenerRegistry().getRuntime();
+                            }
+
+                            @Override
+                            public ContextRuntime getContextRuntime() {
+                                return cr;
+                            }
+
+                            @Override
+                            public ServletContextHelperInfo getContextInfo() {
+                                return handler.getContextInfo();
+                            }
+                        });
+                    }
                 }
             }
-            // TODO - this is the wrong place, it adds the context for the http service
-            final ServletContextHelperInfo info = new ServletContextHelperInfo(Integer.MAX_VALUE, 0, HTTP_SERVICE_CONTEXT_NAME, "/", null);
-            contextRuntimes.add(new InfoServletContextHelperRuntime(info, this.webContext));
-
-            handlerRuntimes = registry.getRuntime(failureRuntime);
             failureRuntime.add(serviceFailures);
         }
 
-        return new RegistryRuntime(contextRuntimes,
-            handlerRuntimes,
-            listenerRuntimes,
-            failureRuntime.build());
+        // add the context for the http service
+        final ServletContextHelperInfo info = new ServletContextHelperInfo(Integer.MAX_VALUE, 0, HTTP_SERVICE_CONTEXT_NAME, "/", null);
+        final ContextRuntime cr = registry.getRuntime(0);
+        if ( cr != null )
+        {
+            contextRuntimes.add(new ServletContextHelperRuntime() {
+
+                @Override
+                public ServletContext getSharedContext() {
+                    return webContext;
+                }
+
+                @Override
+                public Collection<ServiceReference<?>> getListeners() {
+                    return Collections.emptyList();
+                }
+
+                @Override
+                public ContextRuntime getContextRuntime() {
+                    return cr;
+                }
+
+                @Override
+                public ServletContextHelperInfo getContextInfo() {
+                    return info;
+                }
+            });
+        }
+        return new RegistryRuntime(contextRuntimes, failureRuntime.build());
     }
 }

Modified: felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/registry/HandlerRegistryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/registry/HandlerRegistryTest.java?rev=1680011&r1=1680010&r2=1680011&view=diff
==============================================================================
--- felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/registry/HandlerRegistryTest.java (original)
+++ felix/trunk/http/base/src/test/java/org/apache/felix/http/base/internal/registry/HandlerRegistryTest.java Mon May 18 12:44:55 2015
@@ -16,12 +16,8 @@
  */
 package org.apache.felix.http.base.internal.registry;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
+import static org.junit.Assert.assertNull;
 
 import org.apache.felix.http.base.internal.runtime.dto.ContextRuntime;
 import org.junit.Test;
@@ -33,25 +29,17 @@ public class HandlerRegistryTest
 
     @Test public void testInitialSetup()
     {
-        List<ContextRuntime> runtimes = registry.getRuntime(null);
-        assertNotNull(runtimes);
-        assertTrue(runtimes.isEmpty());
+        ContextRuntime runtime = registry.getRuntime(0);
+        assertNull(runtime);
 
         registry.init();
 
-        runtimes = registry.getRuntime(null);
-        assertNotNull(runtimes);
-        assertFalse(runtimes.isEmpty());
-        assertEquals(1, runtimes.size());
-
-        final ContextRuntime cr = runtimes.get(0);
-
-        assertEquals(0, cr.getServiceId());
+        runtime = registry.getRuntime(0);
+        assertNotNull(runtime);
 
         registry.shutdown();
-        runtimes = registry.getRuntime(null);
-        assertNotNull(runtimes);
-        assertTrue(runtimes.isEmpty());
+        runtime = registry.getRuntime(0);
+        assertNull(runtime);
     }
     /*
     @Test



Mime
View raw message