You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/01/04 16:36:47 UTC

svn commit: r1777335 - in /felix/trunk/http: api/src/main/java/org/osgi/service/http/runtime/dto/ api/src/main/java/org/osgi/service/http/whiteboard/ base/ base/src/main/java/org/apache/felix/http/base/internal/whiteboard/ base/src/main/java/org/apache...

Author: cziegeler
Date: Wed Jan  4 16:36:47 2017
New Revision: 1777335

URL: http://svn.apache.org/viewvc?rev=1777335&view=rev
Log:
FELIX-5296 : Implement Http Whiteboard Service Updates (RFC 223)

Modified:
    felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/FailedPreprocessorDTO.java
    felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/PreprocessorDTO.java
    felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/RuntimeDTO.java
    felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletDTO.java
    felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/package-info.java
    felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java
    felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java
    felix/trunk/http/base/pom.xml
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandler.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/WhiteboardManager.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/PreprocessorTracker.java

Modified: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/FailedPreprocessorDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/FailedPreprocessorDTO.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/FailedPreprocessorDTO.java (original)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/FailedPreprocessorDTO.java Wed Jan  4 16:36:47 2017
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2012, 2016). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/PreprocessorDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/PreprocessorDTO.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/PreprocessorDTO.java (original)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/PreprocessorDTO.java Wed Jan  4 16:36:47 2017
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2012, 2016). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.

Modified: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/RuntimeDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/RuntimeDTO.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/RuntimeDTO.java (original)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/RuntimeDTO.java Wed Jan  4 16:36:47 2017
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2012, 2016). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -79,6 +79,8 @@ public class RuntimeDTO extends DTO {
 	 * {@code org.osgi.service.http.whiteboard.Preprocessor} services associated
 	 * with this runtime but currently not used due to some problem. The
 	 * returned array may be empty.
+	*
+	 * since 1.1
 	 */
 	public FailedPreprocessorDTO[]		failedPreprocessorDTOs;
 

Modified: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletDTO.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletDTO.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletDTO.java (original)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletDTO.java Wed Jan  4 16:36:47 2017
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2012, 2016). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ public class ServletDTO extends BaseServ
 	 * 
 	 * <p>
 	 * The specified patterns are used to determine whether a request is mapped
-	 * to the servlet. This field is never {@code null}. The array might be empty.
+	 * to the servlet. This array is never empty.
 	 */
 	public String[]				patterns;
 

Modified: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/package-info.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/package-info.java (original)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/dto/package-info.java Wed Jan  4 16:36:47 2017
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2010, 2015). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2010, 2016). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,22 +15,20 @@
  */
 
 /**
- * Http Runtime DTO Package Version 1.0.
- * 
+ * Http Runtime DTO Package Version 1.1.
  * <p>
  * Bundles wishing to use this package must list the package in the
  * Import-Package header of the bundle's manifest. This package has two types of
  * users: the consumers that use the API in this package and the providers that
  * implement the API in this package.
- * 
  * <p>
  * Example import for consumers using the API in this package:
  * <p>
- * {@code  Import-Package: org.osgi.service.http.runtime.dto; version="[1.0,2.0)"}
+ * {@code  Import-Package: org.osgi.service.http.runtime.dto; version="[1.1,2.0)"}
  * <p>
  * Example import for providers implementing the API in this package:
  * <p>
- * {@code  Import-Package: org.osgi.service.http.runtime.dto; version="[1.0,1.1)"}
+ * {@code  Import-Package: org.osgi.service.http.runtime.dto; version="[1.1,1.2)"}
  * 
  * @author $Id$
  */

Modified: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java (original)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java Wed Jan  4 16:36:47 2017
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2012, 2016). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -548,11 +548,10 @@ public final class HttpWhiteboardConstan
 	 * the Http Context(s) managed by the Http Service, they can select the
 	 * contexts having this property.
 	 * <p>
-	 * Servlets or resources registered using this property for filtering are
-	 * treated as an invalid registration.
+	 * Servlets or resources registered using this property are treated as an
+	 * invalid registration.
 	 * 
 	 * @since 1.1
 	 */
 	public static final String	HTTP_SERVICE_CONTEXT_PROPERTY						= "osgi.http.whiteboard.context.httpservice";
 }
-

Modified: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java (original)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java Wed Jan  4 16:36:47 2017
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) OSGi Alliance (2010, 2015). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2010, 2016). All Rights Reserved.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,22 +15,20 @@
  */
 
 /**
- * Http Whiteboard Package Version 1.0.
- * 
+ * Http Whiteboard Package Version 1.1.
  * <p>
  * Bundles wishing to use this package must list the package in the
  * Import-Package header of the bundle's manifest. This package has two types of
  * users: the consumers that use the API in this package and the providers that
  * implement the API in this package.
- * 
  * <p>
  * Example import for consumers using the API in this package:
  * <p>
- * {@code  Import-Package: org.osgi.service.http.whiteboard; version="[1.0,2.0)"}
+ * {@code  Import-Package: org.osgi.service.http.whiteboard; version="[1.1,2.0)"}
  * <p>
  * Example import for providers implementing the API in this package:
  * <p>
- * {@code  Import-Package: org.osgi.service.http.whiteboard; version="[1.0,1.1)"}
+ * {@code  Import-Package: org.osgi.service.http.whiteboard; version="[1.1,1.2)"}
  * 
  * @author $Id$
  */

Modified: felix/trunk/http/base/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/pom.xml?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/base/pom.xml (original)
+++ felix/trunk/http/base/pom.xml Wed Jan  4 16:36:47 2017
@@ -37,32 +37,6 @@
         <url>http://svn.apache.org/viewvc/felix/trunk/http/base/</url>
     </scm>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                <configuration>
-                    <instructions>
-                        <Private-Package>
-                            org.apache.felix.http.base.*
-                        </Private-Package>
-                        <Import-Package>
-                        <!-- Maven bundle plugin version 2.5.3 has a problem
-                             with correctly calculating the import ranges -->
-                            org.osgi.service.http;version="[1.2,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.useradmin;resolution:=optional,
-                            *
-                        </Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
     <dependencies>
         <dependency>
             <groupId>javax.servlet</groupId>
@@ -80,12 +54,21 @@
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
-            <artifactId>osgi.cmpn</artifactId>
+            <artifactId>org.osgi.service.log</artifactId>
+            <version>1.3.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.service.useradmin</artifactId>
+            <version>1.1.0</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>com.google.code.findbugs</groupId>
             <artifactId>jsr305</artifactId>
             <version>3.0.0</version>
+            <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.hamcrest</groupId>

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandler.java?rev=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandler.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/FailureStateHandler.java Wed Jan  4 16:36:47 2017
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentHa
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.apache.felix.http.base.internal.runtime.AbstractInfo;
 import org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder;
+import org.osgi.framework.Bundle;
 
 public class FailureStateHandler {
 
@@ -67,13 +68,14 @@ public class FailureStateHandler {
 
     public void addFailure(final AbstractInfo<?> info, final long contextId, final int reason, final Exception ex)
     {
-        final String type = info.getClass().getSimpleName().substring(0, info.getClass().getSimpleName().length() - 4);
+    	final String type = info.getClass().getSimpleName().substring(0, info.getClass().getSimpleName().length() - 4);
         final String serviceInfo;
         if ( info.getServiceReference() == null ) {
-            serviceInfo = "with id " + info.getServiceId();
+            serviceInfo = "with id " + String.valueOf(info.getServiceId());
         } else {
+        	final Bundle bundle = info.getServiceReference().getBundle();
             serviceInfo = String.valueOf(info.getServiceId()) +
-                    " (bundle " + info.getServiceReference().getBundle().getSymbolicName()
+                   " (bundle " + (bundle == null ? "<uninstalled>" : bundle.getSymbolicName())
                     + " reference " + info.getServiceReference() + ")";
         }
         if ( reason == FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING )

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=1777335&r1=1777334&r2=1777335&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 Wed Jan  4 16:36:47 2017
@@ -78,6 +78,7 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.service.ResourceServlet;
 import org.apache.felix.http.base.internal.whiteboard.tracker.FilterTracker;
 import org.apache.felix.http.base.internal.whiteboard.tracker.ListenersTracker;
+import org.apache.felix.http.base.internal.whiteboard.tracker.PreprocessorTracker;
 import org.apache.felix.http.base.internal.whiteboard.tracker.ResourceTracker;
 import org.apache.felix.http.base.internal.whiteboard.tracker.ServletContextHelperTracker;
 import org.apache.felix.http.base.internal.whiteboard.tracker.ServletTracker;
@@ -208,6 +209,7 @@ public final class WhiteboardManager
                 }, props);
         addTracker(new FilterTracker(this.httpBundleContext, this));
         addTracker(new ListenersTracker(this.httpBundleContext, this));
+        addTracker(new PreprocessorTracker(this.httpBundleContext, this));
         addTracker(new ResourceTracker(this.httpBundleContext, this));
         addTracker(new ServletContextHelperTracker(this.httpBundleContext, this));
         addTracker(new ServletTracker(this.httpBundleContext, this));
@@ -432,7 +434,7 @@ public final class WhiteboardManager
                         }
                         else
                         {
-                            this.failureStateHandler.addFailure(handler.getContextInfo(), DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE);
+                            this.failureStateHandler.addFailure(info, DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE);
                         }
                     }
                     else
@@ -441,7 +443,7 @@ public final class WhiteboardManager
                         Collections.sort(handlerList);
                         this.contextMap.put(info.getName(), handlerList);
 
-                        this.failureStateHandler.addFailure(handler.getContextInfo(), FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
+                        this.failureStateHandler.addFailure(info, FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
                     }
                 }
             }
@@ -660,7 +662,7 @@ public final class WhiteboardManager
         {
             if ( h.getContextInfo().getServiceId() == HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID )
             {
-                this.failureStateHandler.addFailure(info, h.getContextInfo().getServiceId(), DTOConstants.FAILURE_REASON_VALIDATION_FAILED);
+                this.failureStateHandler.addFailure(info, HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID, DTOConstants.FAILURE_REASON_VALIDATION_FAILED);
 
                 return DTOConstants.FAILURE_REASON_VALIDATION_FAILED;
             }
@@ -961,11 +963,13 @@ public final class WhiteboardManager
             return true;
         }
         final AtomicBoolean result = new AtomicBoolean(true);
-        final FilterChain chain = new FilterChain() {
+        final FilterChain chain = new FilterChain() 
+        {
 
             @Override
             public void doFilter(final ServletRequest request, final ServletResponse response)
-            throws IOException, ServletException {
+            throws IOException, ServletException 
+            {
                 result.set(true);
             }
         };

Modified: 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=1777335&r1=1777334&r2=1777335&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/PreprocessorTracker.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/whiteboard/tracker/PreprocessorTracker.java Wed Jan  4 16:36:47 2017
@@ -28,19 +28,18 @@ public final class PreprocessorTracker e
 
    /**
      * Create a new tracker
-     * @param contextManager The context manager
      * @param bundleContext The bundle context.
-     * @param filterExpr The filter expression for the services to track
+     * @param contextManager The context manager
      */
-    public PreprocessorTracker(final WhiteboardManager contextManager,
-            final BundleContext bundleContext, final String filterExpr)
+    public PreprocessorTracker(final BundleContext bundleContext, final WhiteboardManager contextManager)
     {
-        super(contextManager, bundleContext, String.format("(objectClass=%s)",
-                Preprocessor.class.getName()));
+        super(contextManager, bundleContext, 
+        		String.format("(objectClass=%s)", Preprocessor.class.getName()));
     }
 
     @Override
-    protected WhiteboardServiceInfo<Preprocessor> getServiceInfo(final ServiceReference<Preprocessor> ref) {
+    protected WhiteboardServiceInfo<Preprocessor> getServiceInfo(final ServiceReference<Preprocessor> ref) 
+    {
         return new PreprocessorInfo(ref);
     }
 }