diff options
author | Raymond Auge | 2019-01-31 15:15:40 +0000 |
---|---|---|
committer | Raymond Auge | 2019-02-06 19:39:25 +0000 |
commit | dc5a6bfc8cc01e81ab1a6b3442e4f8a3012b4233 (patch) | |
tree | ec42ac07e867fc68112bba066d707f13585c6b29 | |
parent | 39a941ca4bdd208ccbc4bd96d6baac70d2e2d62c (diff) | |
download | rt.equinox.framework-dc5a6bfc8cc01e81ab1a6b3442e4f8a3012b4233.tar.gz rt.equinox.framework-dc5a6bfc8cc01e81ab1a6b3442e4f8a3012b4233.tar.xz rt.equinox.framework-dc5a6bfc8cc01e81ab1a6b3442e4f8a3012b4233.zip |
Bug 544011 - [http whiteboard] update to R7 (http whiteboard 1.1)
Signed-off-by: Raymond Auge <raymond.auge@liferay.com>
Change-Id: Idc22466f9cb767f94b121312b55738c7a52e3cbd
36 files changed, 508 insertions, 96 deletions
diff --git a/bundles/org.eclipse.osgi.services/META-INF/MANIFEST.MF b/bundles/org.eclipse.osgi.services/META-INF/MANIFEST.MF index cdd7b004d..5129383f1 100644 --- a/bundles/org.eclipse.osgi.services/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.osgi.services/META-INF/MANIFEST.MF @@ -16,10 +16,10 @@ Export-Package: org.osgi.service.cm;version="1.6";uses:="org.osgi.framework", org.osgi.service.device;version="1.1";uses:="org.osgi.framework", org.osgi.service.event;version="1.4";uses:="org.osgi.framework", org.osgi.service.http;version="1.2.1";uses:="javax.servlet,javax.servlet.http", - org.osgi.service.http.context;version="1.0";uses:="org.osgi.framework,javax.servlet.http", - org.osgi.service.http.runtime;version="1.0";uses:="org.osgi.service.http.runtime.dto", - org.osgi.service.http.runtime.dto;version="1.0";uses:="org.osgi.dto,org.osgi.framework.dto", - org.osgi.service.http.whiteboard;version="1.0", + org.osgi.service.http.context;version="1.1";uses:="org.osgi.framework,javax.servlet.http", + org.osgi.service.http.runtime;version="1.1";uses:="org.osgi.service.http.runtime.dto", + org.osgi.service.http.runtime.dto;version="1.1";uses:="org.osgi.dto,org.osgi.framework.dto", + org.osgi.service.http.whiteboard;version="1.1", org.osgi.service.log;version="1.4";uses:="org.osgi.framework", org.osgi.service.metatype;version="1.4";uses:="org.osgi.framework", org.osgi.service.provisioning;version="1.2", @@ -39,6 +39,10 @@ Import-Package: javax.servlet;resolution:=optional, org.osgi.service.device;version="[1.1,1.2)", org.osgi.service.event;version="[1.4,1.5)", org.osgi.service.http;version="[1.2,1.3)", + org.osgi.service.http.context;version="[1.1,1.2)", + org.osgi.service.http.runtime;version="[1.1,1.2)", + org.osgi.service.http.runtime.dto;version="[1.1,1.2)", + org.osgi.service.http.whiteboard;version="[1.1,1.2)", org.osgi.service.log;version="[1.4,1.5)", org.osgi.service.metatype;version="[1.4,1.5)", org.osgi.service.provisioning;version="[1.2,1.3)", 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 c7dcd5824..1ea12b9c4 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, 2013). All Rights Reserved. + * Copyright (c) OSGi Alliance (2000, 2015). 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. @@ -76,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 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 6e4d8f6f5..d44893b09 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, 2013). All Rights Reserved. + * Copyright (c) OSGi Alliance (2000, 2015). 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. @@ -66,6 +66,7 @@ public class NamespaceException extends Exception { * @return The cause of this exception or {@code null} if no cause was set. * @since 1.2 */ + @Override public Throwable getCause() { return super.getCause(); } @@ -81,6 +82,7 @@ public class NamespaceException extends Exception { * been set. * @since 1.2 */ + @Override public Throwable initCause(Throwable cause) { return super.initCause(cause); } 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 9e6f2e833..3808a8548 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2000, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2000, 2018). 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. @@ -21,8 +21,10 @@ import java.net.URL; import java.util.Enumeration; import java.util.LinkedHashSet; import java.util.Set; + import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + import org.osgi.annotation.versioning.ConsumerType; import org.osgi.framework.Bundle; import org.osgi.service.http.whiteboard.HttpWhiteboardConstants; @@ -149,12 +151,10 @@ public abstract class ServletContextHelper { /** * Handles security for the specified request. - * * <p> * The Http Whiteboard implementation calls this method prior to servicing * the specified request. This method controls whether the request is * processed in the normal manner or an error is returned. - * * <p> * If the request requires authentication and the {@code Authorization} * header in the request is missing or not acceptable, then this method @@ -162,19 +162,16 @@ public abstract class ServletContextHelper { * set the status in the response object to Unauthorized(401) and return * {@code false}. See also <a href="http://www.ietf.org/rfc/rfc2617.txt">RFC * 2617: HTTP Authentication: Basic and Digest Access Authentication</a>. - * * <p> * If the request requires a secure connection and the {@code getScheme} * method in the request does not return 'https' or some other acceptable * secure protocol, then this method should set the status in the response * object to Forbidden(403) and return {@code false}. - * * <p> * When this method returns {@code false}, the Http Whiteboard * implementation will send the response back to the client, thereby * completing the request. When this method returns {@code true}, the Http * Whiteboard implementation will proceed with servicing the request. - * * <p> * If the specified request has been authenticated, this method must set the * {@link #AUTHENTICATION_TYPE} request attribute to the type of @@ -182,27 +179,30 @@ public abstract class ServletContextHelper { * the remote user (request attributes are set using the * {@code setAttribute} method on the request). If this method does not * perform any authentication, it must not set these attributes. - * * <p> * If the authenticated user is also authorized to access certain resources, * this method must set the {@link #AUTHORIZATION} request attribute to the * {@code Authorization} object obtained from the * {@code org.osgi.service.useradmin.UserAdmin} service. - * * <p> * The servlet responsible for servicing the specified request determines * the authentication type and remote user by calling the * {@code getAuthType} and {@code getRemoteUser} methods, respectively, on * the request. - * + * <p> + * If there is the need to clean up resources at the end of the request, the + * method {@link #finishSecurity(HttpServletRequest, HttpServletResponse)} + * can be implemented. That method is only called if this method returns {@code true}. + * * @param request The HTTP request. * @param response The HTTP response. * @return {@code true} if the request should be serviced, {@code false} if * the request should not be serviced and Http Whiteboard * implementation will send the response back to the client. * @throws java.io.IOException May be thrown by this method. If this occurs, - * the Http Whiteboard implementation will terminate the request and - * close the socket. + * the Http Whiteboard implementation will terminate the request + * and close the socket. + * @see #finishSecurity(HttpServletRequest, HttpServletResponse) */ public boolean handleSecurity(final HttpServletRequest request, final HttpServletResponse response) @@ -211,8 +211,32 @@ public abstract class ServletContextHelper { } /** - * Maps a resource name to a URL. + * Finishes the security context for the specified request. + * <p> + * Implementations of this service can implement this method to clean up + * resources which have been setup in + * {@link #handleSecurity(HttpServletRequest, HttpServletResponse)}. + * <p> + * This method is only called if + * {@link #handleSecurity(HttpServletRequest, HttpServletResponse)} returned + * {@code true} for the specified request. This method is called once the + * pipeline finishes processing or if an exception is thrown from within the + * pipeline execution. + * <p> + * The default implementation of this method does nothing. * + * @param request The HTTP request. + * @param response The HTTP response. + * @since 1.1 + * @see #handleSecurity(HttpServletRequest, HttpServletResponse) + */ + public void finishSecurity(final HttpServletRequest request, + final HttpServletResponse response) { + // do nothing + } + + /** + * Maps a resource name to a URL. * <p> * Called by the Http Whiteboard implementation to map the specified * resource name to a URL. For servlets, the Http Whiteboard implementation @@ -220,7 +244,6 @@ public abstract class ServletContextHelper { * {@code getResource} and {@code getResourceAsStream}. For resources, the * Http Whiteboard implementation will call this method to locate the named * resource. - * * <p> * 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 diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/package-info.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/package-info.java index b6795f268..bc4d39ce0 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/package-info.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2018). 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,28 +15,28 @@ */ /** - * Http Whiteboard Context Package Version 1.0. - * + * Http Whiteboard Context 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.context; version="[1.0,2.0)"} + * {@code Import-Package: org.osgi.service.http.context; version="[1.1,2.0)"} * <p> * Example import for providers implementing the API in this package: * <p> - * {@code Import-Package: org.osgi.service.http.context; version="[1.0,1.1)"} + * {@code Import-Package: org.osgi.service.http.context; version="[1.1,1.2)"} * * @author $Id$ */ -@Version("1.0") +@Version(HTTP_WHITEBOARD_SPECIFICATION_VERSION) package org.osgi.service.http.context; +import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SPECIFICATION_VERSION; + import org.osgi.annotation.versioning.Version; diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/packageinfo b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/packageinfo deleted file mode 100644 index 7c8de0324..000000000 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/context/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0 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 349de707c..caee1296b 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, 2013). 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. @@ -32,9 +32,10 @@ * <p> * {@code Import-Package: org.osgi.service.http; version="[1.2,1.3)"} * - * @version 1.2.1 * @author $Id$ */ +@Version("1.2.1") 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 deleted file mode 100644 index 6ebb891f1..000000000 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.2.1 diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/HttpServiceRuntime.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/HttpServiceRuntime.java index 09d6cb78e..03eec1eb1 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/HttpServiceRuntime.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/HttpServiceRuntime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/HttpServiceRuntimeConstants.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/HttpServiceRuntimeConstants.java index 264c3ae61..f51ac2e99 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/HttpServiceRuntimeConstants.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/HttpServiceRuntimeConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/BaseServletDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/BaseServletDTO.java index 1bca590bf..9f8c24a22 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/BaseServletDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/BaseServletDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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. @@ -17,6 +17,7 @@ package org.osgi.service.http.runtime.dto; import java.util.Map; + import org.osgi.dto.DTO; /** @@ -27,7 +28,9 @@ import org.osgi.dto.DTO; */ public abstract class BaseServletDTO extends DTO { /** - * The name of the servlet. This value is never {@code null}. + * The name of the servlet. This value is never {@code null}, unless this + * object represents a {@code FailedServletDTO} or a + * {@code FailedErrorPageDTO} where the value might be {@code null}. */ public String name; @@ -35,7 +38,8 @@ public abstract class BaseServletDTO extends DTO { * The information string from the servlet. * <p> * This is the value returned by the {@code Servlet.getServletInfo()} - * method. + * method. For a {@code FailedServletDTO} or a {@code FailedErrorPageDTO} + * this is always {@code null}. */ public String servletInfo; 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 52e5fed38..95b617655 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2018). 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. @@ -73,4 +73,40 @@ public final class DTOConstants { * another servlet context. */ public static final int FAILURE_REASON_SERVICE_IN_USE = 7; + + /** + * The servlet is not registered as it is configured to have multipart + * enabled, but the bundle containing the servlet has no write permission to + * the provided location for the uploaded files. + * + * @since 1.1 + */ + public static final int FAILURE_REASON_SERVLET_WRITE_TO_LOCATION_DENIED = 8; + + /** + * The servlet is not registered as it is configured to have multipart + * enabled, but the whiteboard implementation has no write permission to the + * default location for the uploaded files. + * + * @since 1.1 + */ + public static final int FAILURE_REASON_WHITEBOARD_WRITE_TO_DEFAULT_DENIED = 9; + + /** + * The servlet is not registered as it is configured to have multipart + * enabled, but the bundle containing the servlet has no read permission to + * the default location for the uploaded files. + * + * @since 1.1 + */ + public static final int FAILURE_REASON_SERVLET_READ_FROM_DEFAULT_DENIED = 10; + + /** + * The servlet is not registered as it is configured to have multipart + * enabled, but the whiteboard implementation has no write permission to the + * provided location for the uploaded files. + * + * @since 1.1 + */ + public static final int FAILURE_REASON_WHITEBOARD_WRITE_TO_LOCATION_DENIED = 11; } diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ErrorPageDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ErrorPageDTO.java index 80437fba4..19baaa9c3 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ErrorPageDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ErrorPageDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/FailedErrorPageDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedErrorPageDTO.java index ac6a6c0be..f959f856d 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedErrorPageDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedErrorPageDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/FailedFilterDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedFilterDTO.java index e1016e9e3..a38fad38c 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedFilterDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedFilterDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/FailedListenerDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedListenerDTO.java index 5e2130cba..04f808b17 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedListenerDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedListenerDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/FailedPreprocessorDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedPreprocessorDTO.java new file mode 100644 index 000000000..7b446a1a9 --- /dev/null +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedPreprocessorDTO.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) OSGi Alliance (2012, 2017). 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.runtime.dto; + +/** + * Represents a preprocessor service which is currently not being used due to a + * problem. + * + * @NotThreadSafe + * @author $Id$ + * @since 1.1 + */ +public class FailedPreprocessorDTO extends PreprocessorDTO { + + /** + * The reason why the preprocessor represented by this DTO is not used. + * + * @see DTOConstants#FAILURE_REASON_UNKNOWN + * @see DTOConstants#FAILURE_REASON_EXCEPTION_ON_INIT + * @see DTOConstants#FAILURE_REASON_SERVICE_NOT_GETTABLE + */ + public int failureReason; + +} diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedResourceDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedResourceDTO.java index 2f8ab091c..b5cee8abb 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedResourceDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedResourceDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/FailedServletContextDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedServletContextDTO.java index 40beb0805..9ca911b03 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedServletContextDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedServletContextDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/FailedServletDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedServletDTO.java index 7fa7499d9..266814196 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedServletDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FailedServletDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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. @@ -21,8 +21,8 @@ package org.osgi.service.http.runtime.dto; * being used by a servlet context due to a problem. * <p> * As the servlet represented by this DTO is not used due to a failure, the - * field {@link FailedErrorPageDTO#servletContextId} always returns {@code 0} - * and does not point to an existing servlet context. + * field {@link FailedServletDTO#servletContextId} always returns {@code 0} and + * does not point to an existing servlet context. * * @NotThreadSafe * @author $Id$ @@ -38,6 +38,9 @@ public class FailedServletDTO extends ServletDTO { * @see DTOConstants#FAILURE_REASON_SERVICE_NOT_GETTABLE * @see DTOConstants#FAILURE_REASON_SERVLET_CONTEXT_FAILURE * @see DTOConstants#FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE + * @see DTOConstants#FAILURE_REASON_SERVLET_WRITE_TO_LOCATION_DENIED + * @see DTOConstants#FAILURE_REASON_WHITEBOARD_WRITE_TO_DEFAULT_DENIED + * @see DTOConstants#FAILURE_REASON_SERVLET_READ_FROM_DEFAULT_DENIED */ public int failureReason; } diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FilterDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FilterDTO.java index d9df0a9aa..ea523e825 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FilterDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/FilterDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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. @@ -17,6 +17,7 @@ package org.osgi.service.http.runtime.dto; import java.util.Map; + import org.osgi.dto.DTO; /** diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ListenerDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ListenerDTO.java index 6122537f6..f1404f169 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ListenerDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ListenerDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/PreprocessorDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/PreprocessorDTO.java new file mode 100644 index 000000000..be078563a --- /dev/null +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/PreprocessorDTO.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) OSGi Alliance (2012, 2017). 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.runtime.dto; + +import java.util.Map; + +import org.osgi.dto.DTO; + +/** + * Represents a preprocessor + * {@code org.osgi.service.http.whiteboard.Preprocessor} service currently being + * used during request processing. + * + * @NotThreadSafe + * @author $Id$ + * @since 1.1 + */ +public class PreprocessorDTO extends DTO { + + /** + * The preprocessor initialization parameters as provided during + * registration of the preprocessor. Additional parameters like the Http + * Service Runtime attributes are not included. If the preprocessor has not + * initialization parameters, this map is empty. + */ + public Map<String, String> initParams; + + /** + * Service property identifying the preprocessor. In the case of a + * preprocessor registered in the service registry and picked up by a Http + * Whiteboard Implementation, this value is not negative and corresponds to + * the service id in the registry. If the preprocessor has not been + * registered in the service registry, the value is negative and a unique + * negative value is generated by the Http Service Runtime in this case. + */ + public long serviceId; +} diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/RequestInfoDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/RequestInfoDTO.java index bea86cedc..42929c0cf 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/RequestInfoDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/RequestInfoDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/ResourceDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ResourceDTO.java index 9bf52d592..a960291f1 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ResourceDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ResourceDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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/runtime/dto/RuntimeDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/RuntimeDTO.java index 549bf4354..574f7ccda 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/RuntimeDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/RuntimeDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2018). 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. @@ -35,17 +35,28 @@ public class RuntimeDTO extends DTO { public ServiceReferenceDTO serviceDTO; /** + * Returns the representations of the + * {@code org.osgi.service.http.whiteboard.Preprocessor} objects used by the + * Http Service Runtime. The returned array may be empty if the Http Service + * Runtime is currently not using any + * {@code org.osgi.service.http.whiteboard.Preprocessor} objects. + * + * @since 1.1 + */ + public PreprocessorDTO[] preprocessorDTOs; + + /** * Returns the representations of the {@code javax.servlet.ServletContext} * objects used by the Http Service Runtime. The returned array may be empty * if the Http Service Runtime is currently not using any * {@code javax.servlet.ServletContext} objects. */ - public ServletContextDTO[] servletContextDTOs; + public ServletContextDTO[] servletContextDTOs; /** - * Returns the representations of the {@code javax.servlet.ServletContext} objects - * currently not used by the Http service runtime due to some problem. - * The returned array may be empty. + * Returns the representations of the {@code javax.servlet.ServletContext} + * objects currently not used by the Http service runtime due to some + * problem. The returned array may be empty. */ public FailedServletContextDTO[] failedServletContextDTOs; @@ -64,9 +75,19 @@ public class RuntimeDTO extends DTO { public FailedResourceDTO[] failedResourceDTOs; /** - * Returns the representations of the servlet {@code javax.servlet.Filter} - * services associated with this runtime but currently not used due to some - * problem. The returned array may be empty. + * Returns the representations of the servlet + * {@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; + + /** + * Returns the representations of the {@code javax.servlet.Filter} services + * associated with this runtime but currently not used due to some problem. + * The returned array may be empty. */ public FailedFilterDTO[] failedFilterDTOs; diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletContextDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletContextDTO.java index 51af19570..63044e1c8 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletContextDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletContextDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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. @@ -17,6 +17,7 @@ package org.osgi.service.http.runtime.dto; import java.util.Map; + import org.osgi.dto.DTO; /** diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletDTO.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletDTO.java index 4b078f335..5c7720dbf 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletDTO.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/ServletDTO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2017). 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. @@ -27,10 +27,53 @@ package org.osgi.service.http.runtime.dto; public class ServletDTO extends BaseServletDTO { /** * The request mappings for the servlet. - * * <p> * The specified patterns are used to determine whether a request is mapped - * to the servlet. This array is never empty. + * to the servlet. This array is never {@code null}. It might be empty for + * named servlets. */ public String[] patterns; + + /** + * Specifies whether multipart support is enabled. + * @since 1.1 + */ + public boolean multipartEnabled; + + /** + * Specifies the size threshold after which the file will be written to + * disk. If multipart is not enabled for this servlet, {@code 0} is + * returned. + * + * @since 1.1 + * @see #multipartEnabled + */ + public int multipartFileSizeThreshold; + + /** + * Specifies the location where the files can be stored on disk. If + * multipart is not enabled for this servlet, {@code null} is returned. + * + * @since 1.1 + * @see #multipartEnabled + */ + public String multipartLocation; + + /** + * Specifies the maximum size of a file being uploaded. If multipart is not + * enabled for this servlet, {@code 0} is returned. + * + * @since 1.1 + * @see #multipartEnabled + */ + public long multipartMaxFileSize; + + /** + * Specifies the maximum request size. If multipart is not enabled for this + * servlet, {@code 0} is returned. + * + * @since 1.1 + * @see #multipartEnabled + */ + public long multipartMaxRequestSize; } diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/package-info.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/package-info.java index f1721da50..9912367df 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/package-info.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2018). 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,28 +15,28 @@ */ /** - * 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$ */ -@Version("1.0") +@Version(HTTP_WHITEBOARD_SPECIFICATION_VERSION) package org.osgi.service.http.runtime.dto; +import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SPECIFICATION_VERSION; + import org.osgi.annotation.versioning.Version; diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/packageinfo b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/packageinfo deleted file mode 100644 index 7c8de0324..000000000 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/dto/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0 diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/package-info.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/package-info.java index 77af772c1..821fe04a7 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/package-info.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2018). 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,28 +15,28 @@ */ /** - * Http Runtime Package Version 1.0. - * + * Http Runtime 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; version="[1.0,2.0)"} + * {@code Import-Package: org.osgi.service.http.runtime; 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; version="[1.0,1.1)"} + * {@code Import-Package: org.osgi.service.http.runtime; version="[1.1,1.2)"} * * @author $Id$ */ -@Version("1.0") +@Version(HTTP_WHITEBOARD_SPECIFICATION_VERSION) package org.osgi.service.http.runtime; +import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SPECIFICATION_VERSION; + import org.osgi.annotation.versioning.Version; diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/packageinfo b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/packageinfo deleted file mode 100644 index 7c8de0324..000000000 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/runtime/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0 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 b82e6f543..e2762e37a 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2012, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2012, 2018). 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. @@ -17,6 +17,7 @@ package org.osgi.service.http.whiteboard; import javax.servlet.Servlet; + import org.osgi.framework.Filter; import org.osgi.service.http.context.ServletContextHelper; import org.osgi.service.http.runtime.HttpServiceRuntimeConstants; @@ -137,19 +138,19 @@ public final class HttpWhiteboardConstants { /** * Service property specifying the servlet name of a {@code Servlet} * service. - * * <p> - * This name is used as the value for the + * The servlet is registered with this name and the name can be used as a + * reference to the servlet for filtering or request dispatching. + * <p> + * This name is in addition used as the value for the * {@code ServletConfig.getServletName()} method. If this service property * is not specified, the fully qualified name of the service object's class * is used as the servlet name. Filter services may refer to servlets by * this name in their {@link #HTTP_WHITEBOARD_FILTER_SERVLET} service * property to apply the filter to the servlet. - * * <p> * Servlet names should be unique among all servlet services associated with * a single {@link ServletContextHelper}. - * * <p> * The value of this service property must be of type {@code String}. */ @@ -158,12 +159,11 @@ public final class HttpWhiteboardConstants { /** * Service property specifying the request mappings for a {@code Servlet} * service. - * * <p> * The specified patterns are used to determine whether a request should be - * mapped to the servlet. Servlet services without this service property or - * {@link #HTTP_WHITEBOARD_SERVLET_ERROR_PAGE} are ignored. - * + * mapped to the servlet. Servlet services without this service property, + * {@link #HTTP_WHITEBOARD_SERVLET_ERROR_PAGE} or + * {@link #HTTP_WHITEBOARD_SERVLET_NAME} are ignored. * <p> * The value of this service property must be of type {@code String}, * {@code String[]}, or {@code Collection<String>}. @@ -221,6 +221,82 @@ public final class HttpWhiteboardConstants { public static final String HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX = "servlet.init."; /** + * Service property specifying whether a {@code Servlet} service has enabled + * multipart request processing. + * <p> + * By default servlet services do not have multipart request processing + * enabled. + * <p> + * The value of this service property must be of type {@code Boolean}. + * + * @see "Java Servlet Specification Version 3.0, Section 8.1.5 @MultipartConfig" + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED = "osgi.http.whiteboard.servlet.multipart.enabled"; + + /** + * Service property specifying the size threshold after which the file will + * be written to disk. + * <p> + * When not set or when the value is not valid, the default threshold is + * determined by the implementation. This property is only evaluated if + * {@link #HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED} is set to {@code true} + * . + * <p> + * The value of this service property must be of type {@code Integer}. + * + * @see "Java Servlet Specification Version 3.0, Section 14.4 Deployment Descriptor Diagram" + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_SERVLET_MULTIPART_FILESIZETHRESHOLD = "osgi.http.whiteboard.servlet.multipart.fileSizeThreshold"; + + /** + * Service property specifying the location where the files can be stored on + * disk. + * <p> + * When not set the default location is defined by the value of the system + * property "java.io.tmpdir". This property is only evaluated if + * {@link #HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED} is set to {@code true} + * . + * <p> + * The value of this service property must be of type {@code String}. + * + * @see "Java Servlet Specification Version 3.0, Section 14.4 Deployment Descriptor Diagram" + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_SERVLET_MULTIPART_LOCATION = "osgi.http.whiteboard.servlet.multipart.location"; + + /** + * Service property specifying the maximum size of a file being uploaded. + * <p> + * When not set or when the value is not valid, the default maximum size is + * [@code -1} (no maximum size). This property is only evaluated if + * {@link #HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED} is set to {@code true} + * . + * <p> + * The value of this service property must be of type {@code Long}. + * + * @see "Java Servlet Specification Version 3.0, Section 14.4 Deployment Descriptor Diagram" + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXFILESIZE = "osgi.http.whiteboard.servlet.multipart.maxFileSize"; + + /** + * Service property specifying the maximum request size. + * <p> + * When not set or when the value is not valid, the default maximum request + * size is {@code -1} (no maximum size). This property is only evaluated if + * {@link #HTTP_WHITEBOARD_SERVLET_MULTIPART_ENABLED} is set to {@code true} + * . + * <p> + * The value of this service property must be of type {@code Long}. + * + * @see "Java Servlet Specification Version 3.0, Section 14.4 Deployment Descriptor Diagram" + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_SERVLET_MULTIPART_MAXREQUESTSIZE = "osgi.http.whiteboard.servlet.multipart.maxRequestSize"; + + /** * Service property specifying the servlet filter name of a {@code Filter} * service. * @@ -344,6 +420,22 @@ public final class HttpWhiteboardConstants { public static final String HTTP_WHITEBOARD_FILTER_INIT_PARAM_PREFIX = "filter.init."; /** + * Service property prefix referencing a {@link Preprocessor} service. + * <p> + * For {@link Preprocessor} services this prefix can be used for service + * properties to mark them as initialization parameters which can be + * retrieved from the associated filter configuration. The prefix is removed + * from the service property name to build the initialization parameter + * name. + * <p> + * For {@link Preprocessor} services, the value of each initialization + * parameter service property must be of type {@code String}. + * + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX = "preprocessor.init."; + + /** * Service property to mark a Listener service as a Whiteboard service. * Listener services with this property set to the string value "true" will * be treated as Whiteboard services opting in to being handled by the Http @@ -351,7 +443,6 @@ public final class HttpWhiteboardConstants { * is opting out and this case is treated exactly the same as if this * property is missing. If an invalid value is specified this is treated as * a failure. - * * <p> * The value of this service property must be of type {@code String}. Valid * values are "true" and "false" ignoring case. @@ -462,4 +553,45 @@ public final class HttpWhiteboardConstants { * a valid {@link Filter filter string}. */ public static final String HTTP_WHITEBOARD_TARGET = "osgi.http.whiteboard.target"; + + /** + * If a servlet filter, error page or listener wants to be registered with + * 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 are treated as an + * invalid registration. + * + * @see #HTTP_SERVICE_CONTEXT_FILTER + * @since 1.1 + */ + public static final String HTTP_SERVICE_CONTEXT_PROPERTY = "osgi.http.whiteboard.context.httpservice"; + + /** + * If a servlet filter, error page or listener wants to be registered with + * the Http Context(s) managed by the Http Service, they can select the + * contexts having the {@link #HTTP_SERVICE_CONTEXT_PROPERTY} property using + * this filter. + * + * @see #HTTP_SERVICE_CONTEXT_PROPERTY + * @since 1.1 + */ + public static final String HTTP_SERVICE_CONTEXT_FILTER = "(" + + HTTP_SERVICE_CONTEXT_PROPERTY + "=*)"; + + /** + * The name of the implementation capability for the Http Whiteboard + * specification + * + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_IMPLEMENTATION = "osgi.http"; + + /** + * The version of the implementation capability for the Http Whiteboard + * specification + * + * @since 1.1 + */ + public static final String HTTP_WHITEBOARD_SPECIFICATION_VERSION = "1.1.0"; } diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/Preprocessor.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/Preprocessor.java new file mode 100644 index 000000000..2f2430d5a --- /dev/null +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/Preprocessor.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) OSGi Alliance (2017). 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.whiteboard; + +import javax.servlet.Filter; + +import org.osgi.annotation.versioning.ConsumerType; + +/** + * Services registered as a {@code Preprocessor} using a whiteboard pattern are + * executed for every request before the dispatching is performed. + * <p> + * If there are several services of this type, they are run in order of their + * service ranking, the one with the highest ranking is used first. In the case + * of a service ranking tie, the service with the lowest service id is processed + * first. + * <p> + * The preprocessor is handled in the same way as filters. When a preprocessor + * is put into service {@link Filter#init(javax.servlet.FilterConfig)} is + * called, when it is not used anymore {@link Filter#destroy()} is called. As + * these preprocessors are run before dispatching and therefore the targeted + * servlet context is not known yet, + * {@link javax.servlet.FilterConfig#getServletContext()} returns the servlet + * context of the backing implementation. The same context is returned by the + * request object. The context path is the context path of this underlying + * servlet context. The passed in chain can be used to invoke the next + * preprocessor in the chain, or if the end of that chain is reached to start + * dispatching of the request. A preprocessor might decide to terminate the + * processing and directly generate a response. + * <p> + * Service properties with the prefix + * {@code HttpWhiteboardConstants#HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX} + * are passed as init parameters to this service. + * + * @ThreadSafe + * @author $Id$ + * @since 1.1 + */ +@ConsumerType +public interface Preprocessor extends Filter { + + // this interface is a marker interface +} diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/package-info.java b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/package-info.java index 033e5c048..18453f058 100644 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/package-info.java +++ b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) OSGi Alliance (2010, 2015). All Rights Reserved. + * Copyright (c) OSGi Alliance (2010, 2017). 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,28 +15,28 @@ */ /** - * 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$ */ -@Version("1.0") +@Version(HTTP_WHITEBOARD_SPECIFICATION_VERSION) package org.osgi.service.http.whiteboard; +import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_SPECIFICATION_VERSION; + import org.osgi.annotation.versioning.Version; diff --git a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/packageinfo b/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/packageinfo deleted file mode 100644 index 7c8de0324..000000000 --- a/bundles/org.eclipse.osgi.services/src/org/osgi/service/http/whiteboard/packageinfo +++ /dev/null @@ -1 +0,0 @@ -version 1.0 |