diff options
author | Thomas Watson | 2014-09-22 15:34:51 +0000 |
---|---|---|
committer | Thomas Watson | 2014-10-21 20:53:17 +0000 |
commit | ca85007c652d774e0a752edffb0785ab8e3205b3 (patch) | |
tree | 325cb3adbd64714e63efc3eb1678446b791e85c8 | |
parent | abe332ed0e44057e10a1420db362b6eb4180aaa2 (diff) | |
download | rt.equinox.framework-ca85007c652d774e0a752edffb0785ab8e3205b3.tar.gz rt.equinox.framework-ca85007c652d774e0a752edffb0785ab8e3205b3.tar.xz rt.equinox.framework-ca85007c652d774e0a752edffb0785ab8e3205b3.zip |
Bug 436698 - [http] [RFC 189] Implement the proposed R6 Http Whiteboard Service
- update the OSGi API to the latest
9 files changed, 41 insertions, 83 deletions
diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpContext.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpContext.java index acf728222..5b4612284 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpContext.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpContext.java @@ -20,7 +20,6 @@ import java.io.IOException; import java.net.URL; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.osgi.annotation.versioning.ConsumerType; /** * Context for HTTP Requests. @@ -53,10 +52,8 @@ import org.osgi.annotation.versioning.ConsumerType; * </ul> * * - * @ThreadSafe * @author $Id$ */ -@ConsumerType public interface HttpContext { /** * {@code HttpServletRequest} attribute specifying the name of the @@ -151,17 +148,17 @@ public interface HttpContext { * <p> * Called by the Http Service to map a resource name to a URL. For servlet * registrations, Http Service will call this method to support the - * <code>ServletContext</code> methods <code>getResource</code> and - * <code>getResourceAsStream</code>. For resource registrations, Http - * Service will call this method to locate the named resource. The context - * can control from where resources come. For example, the resource can be + * {@code ServletContext} methods {@code getResource} and + * {@code getResourceAsStream}. For resource registrations, Http Service + * will call this method to locate the named resource. The context can + * control from where resources come. For example, the resource can be * mapped to a file in the bundle's persistent storage area via - * <code>bundleContext.getDataFile(name).toURL()</code> or to a resource in - * the context's bundle via <code>getClass().getResource(name)</code> + * {@code bundleContext.getDataFile(name).toURL()} or to a resource in the + * context's bundle via {@code getClass().getResource(name)} * * @param name the name of the requested resource * @return URL that Http Service can use to read the resource or - * <code>null</code> if the resource does not exist. + * {@code null} if the resource does not exist. */ public URL getResource(String name); diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpService.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpService.java index fd0cd031b..c7dcd5824 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpService.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/HttpService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2000, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2000, 2013). 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. @@ -19,18 +19,16 @@ package org.osgi.service.http; import java.util.Dictionary; import javax.servlet.Servlet; import javax.servlet.ServletException; -import org.osgi.annotation.versioning.ProviderType; /** * The Http Service allows other bundles in the OSGi environment to dynamically * register resources and servlets into the URI namespace of Http Service. A * bundle may later unregister its resources or servlets. * - * @ThreadSafe + * @noimplement * @author $Id$ * @see HttpContext */ -@ProviderType public interface HttpService { /** * Registers a servlet into the URI namespace. @@ -78,7 +76,7 @@ public interface HttpService { * @throws java.lang.IllegalArgumentException if any of the arguments are * invalid */ - public void registerServlet(String alias, Servlet servlet, Dictionary<String, String> initparams, HttpContext context) throws ServletException, NamespaceException; + public void registerServlet(String alias, Servlet servlet, Dictionary initparams, HttpContext context) throws ServletException, NamespaceException; /** * Registers resources into the URI namespace. diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/NamespaceException.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/NamespaceException.java index bfc8f8361..6e4d8f6f5 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/NamespaceException.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/NamespaceException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2000, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2000, 2013). 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. diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/ServletContextHelper.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/ServletContextHelper.java index 0052bc23b..ecd33a7fa 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/ServletContextHelper.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/ServletContextHelper.java @@ -175,7 +175,6 @@ public abstract class ServletContextHelper { * {@code getAuthType} and {@code getRemoteUser} methods, respectively, on * the request. * - * @param context The servlet context helper context for this call. * @param request The HTTP request. * @param response The HTTP response. * @return {@code true} if the request should be serviced, {@code false} if @@ -185,14 +184,9 @@ public abstract class ServletContextHelper { * the Http Whiteboard Service will terminate the request and close * the socket. */ - public boolean handleSecurity(final ServletContextHelperContext context, - final HttpServletRequest request, + public boolean handleSecurity(final HttpServletRequest request, final HttpServletResponse response) throws IOException { - final ServletContextHelper parent = context.getParentContext(this); - if ( parent != null ) { - return parent.handleSecurity(context, request, response); - } return true; } @@ -212,12 +206,11 @@ public abstract class ServletContextHelper { * via {@code bundleContext.getDataFile(name).toURL()} or to a resource in * the context's bundle via {@code getClass().getResource(name)} * - * @param context The servlet context helper context for this call. * @param name The name of the requested resource. * @return A URL that Http Whiteboard Service can use to read the resource * or {@code null} if the resource does not exist. */ - public URL getResource(final ServletContextHelperContext context, String name) { + public URL getResource(String name) { final Bundle localBundle = this.bundle; if (name != null && localBundle != null) { if (name.startsWith("/")) { @@ -240,17 +233,12 @@ public abstract class ServletContextHelper { * will call this method to determine the MIME type for the * {@code Content-Type} header in the response. * - * @param context The servlet context helper context for this call. * @param name The name for which to determine the MIME type. * @return The MIME type (e.g. text/html) of the specified name or * {@code null} to indicate that the Http Service should determine * the MIME type itself. */ - public String getMimeType(final ServletContextHelperContext context, final String name) { - final ServletContextHelper parent = context.getParentContext(this); - if (parent != null) { - parent.getMimeType(context, name); - } + public String getMimeType(final String name) { return null; } @@ -264,14 +252,13 @@ public abstract class ServletContextHelper { * {@code ServletContext} method {@code getResourcePaths} for whiteboard * services. * - * @param context The servlet context helper context for this call. * @param path the partial path used to match the resources, which must * start with a / * @return a Set containing the directory listing, or null if there are no * resources in the web application whose path begins with the * supplied path. */ - public Set<String> getResourcePaths(final ServletContextHelperContext context, final String path) { + public Set<String> getResourcePaths(final String path) { final Bundle localBundle = this.bundle; if (path != null && localBundle != null) { final Enumeration<URL> e = localBundle.findEntries(path, null, false); @@ -294,11 +281,10 @@ public abstract class ServletContextHelper { * {@code ServletContext} method {@code getRealPath} for whiteboard * services. * - * @param context The servlet context helper context for this call. * @param path the virtual path to be translated to a real path * @return the real path, or null if the translation cannot be performed */ - public String getRealPath(final ServletContextHelperContext context, final String path) { + public String getRealPath(final String path) { return null; } } diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/ServletContextHelperContext.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/ServletContextHelperContext.java deleted file mode 100644 index fe7a2ac51..000000000 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/ServletContextHelperContext.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) OSGi Alliance (2000, 2014). 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. - * 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.osgi.service.http.context; - -import org.osgi.annotation.versioning.ProviderType; - -/** - * This context object is passed to each method of the - * {@code ServletContextHelper}. - * - * @NotThreadSafe - * @author $Id$ - */ -@ProviderType -public interface ServletContextHelperContext { - - /** - * Return the parent context for the given {@code ServletContextHelper} - * - * @param context The current {@code ServletContextHelper} - * @return The parent {@code ServletContextHelper} or {@code null} - */ - ServletContextHelper getParentContext(ServletContextHelper context); -} diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/package-info.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/package-info.java index 1d0550157..349de707c 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/package-info.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2013). 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,7 +15,7 @@ */ /** - * Http Service Package Version 1.3. + * Http Service Package Version 1.2. * * <p> * Bundles wishing to use this package must list the package in the @@ -26,17 +26,15 @@ * <p> * Example import for consumers using the API in this package: * <p> - * {@code Import-Package: org.osgi.service.http; version="[1.2.2,2.0)"} + * {@code Import-Package: org.osgi.service.http; version="[1.2,2.0)"} * <p> * Example import for providers implementing the API in this package: * <p> - * {@code Import-Package: org.osgi.service.http; version="[1.2.2,1.3)"} + * {@code Import-Package: org.osgi.service.http; version="[1.2,1.3)"} * + * @version 1.2.1 * @author $Id$ */ -@Version("1.2.2") package org.osgi.service.http; -import org.osgi.annotation.versioning.Version; - diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/packageinfo b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/packageinfo index 19727573b..6ebb891f1 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/packageinfo +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/packageinfo @@ -1 +1 @@ -version 1.2.2 +version 1.2.1 diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/DTOConstants.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/DTOConstants.java index fd445b21b..8b4538395 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/DTOConstants.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/DTOConstants.java @@ -69,4 +69,21 @@ public final class DTOConstants { * The value of {@code FAILURE_REASON_SERVICE_NOT_GETTABLE} is 5. */ public static final int FAILURE_REASON_SERVICE_NOT_GETTABLE = 5; + + /** + * The service is registered in the servlet registry but the provided + * registration properties are invalid. + * <p> + * The value of {@code FAILURE_REASON_VALIDATION_FAILED} is 6. + */ + public static final int FAILURE_REASON_VALIDATION_FAILED = 6; + + /** + * The service is not registered as a prototype scoped service and is + * already used with one servlet context and therefore can't be used with + * another servlet context. + * <p> + * The value of {@code FAILURE_REASON_SERVICE_ALREAY_USED} is 7. + */ + public static final int FAILURE_REASON_SERVICE_ALREAY_USED = 7; } diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java index 1308cfa4a..77173e81d 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java @@ -248,7 +248,7 @@ public final class HttpWhiteboardConstants { * <p> * The specified regular expressions are used to determine whether a request * should be mapped to the servlet filter. The regular expressions must - * follow the syntax defined in {@link java.util.regex.Pattern}. Filter + * follow the syntax defined in {@code java.util.regex.Pattern}. Filter * services without this service property or the * {@link #HTTP_WHITEBOARD_FILTER_SERVLET} or the * {@link #HTTP_WHITEBOARD_FILTER_PATTERN} service property must be ignored. @@ -257,7 +257,7 @@ public final class HttpWhiteboardConstants { * The value of this service property must be of type {@code String}, * {@code String[]}, or {@code Collection<String>}. * - * @see java.util.regex.Pattern + * @see "java.util.regex.Pattern" */ public static final String HTTP_WHITEBOARD_FILTER_REGEX = "osgi.http.whiteboard.filter.regex"; |