felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1777088 [2/3] - in /felix/trunk/http: api/ api/src/main/appended-resources/META-INF/ api/src/main/java/org/apache/felix/http/api/ api/src/main/java/org/osgi/ api/src/main/java/org/osgi/service/ api/src/main/java/org/osgi/service/http/ api/...
Date Tue, 03 Jan 2017 08:12:45 GMT
Added: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/package-info.java?rev=1777088&view=auto
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/package-info.java (added)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/package-info.java Tue Jan  3 08:12:45 2017
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) OSGi Alliance (2010, 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.
+ * 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.
+ */
+
+/**
+ * Http Runtime Package Version 1.0.
+ * 
+ * <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)"}
+ * <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)"}
+ * 
+ * @author $Id$
+ */
+
+@Version("1.0")
+package org.osgi.service.http.runtime;
+
+import org.osgi.annotation.versioning.Version;
+

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/runtime/package-info.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Added: 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=1777088&view=auto
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java (added)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java Tue Jan  3 08:12:45 2017
@@ -0,0 +1,558 @@
+/*
+ * Copyright (c) OSGi Alliance (2012, 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.
+ * 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.Servlet;
+
+import org.osgi.framework.Filter;
+import org.osgi.service.http.context.ServletContextHelper;
+import org.osgi.service.http.runtime.HttpServiceRuntimeConstants;
+
+/**
+ * Defines standard constants for the Http Whiteboard services.
+ * 
+ * @author $Id$
+ */
+public final class HttpWhiteboardConstants {
+	private HttpWhiteboardConstants() {
+		// non-instantiable
+	}
+
+	/**
+	 * Service property specifying the name of an {@link ServletContextHelper}
+	 * service.
+	 * 
+	 * <p>
+	 * For {@link ServletContextHelper} services, this service property must be
+	 * specified. Context services without this service property are ignored.
+	 * 
+	 * <p>
+	 * Servlet, listener, servlet filter, and resource services might refer to a
+	 * specific {@link ServletContextHelper} service referencing the name with
+	 * the {@link #HTTP_WHITEBOARD_CONTEXT_SELECT} property.
+	 * 
+	 * <p>
+	 * For {@link ServletContextHelper} services, the value of this service
+	 * property must be of type {@code String}. The value must follow the
+	 * "symbolic-name" specification from Section 1.3.2 of the OSGi Core
+	 * Specification.
+	 * 
+	 * @see #HTTP_WHITEBOARD_CONTEXT_PATH
+	 * @see #HTTP_WHITEBOARD_CONTEXT_SELECT
+	 * @see #HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME
+	 */
+	public static final String	HTTP_WHITEBOARD_CONTEXT_NAME				= "osgi.http.whiteboard.context.name";
+
+	/**
+	 * The name of the default {@link ServletContextHelper}. If a service is
+	 * registered with this property, it is overriding the default context with
+	 * a custom provided context.
+	 * 
+	 * @see #HTTP_WHITEBOARD_CONTEXT_NAME
+	 */
+	public static final String	HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME		= "default";
+
+	/**
+	 * Service property specifying the path of an {@link ServletContextHelper}
+	 * service.
+	 * 
+	 * <p>
+	 * For {@link ServletContextHelper} services this service property is
+	 * required. Context services without this service property are ignored.
+	 * 
+	 * <p>
+	 * This property defines a context path under which all whiteboard services
+	 * associated with this context are registered. Having different contexts
+	 * with different paths allows to separate the URL space.
+	 * 
+	 * <p>
+	 * For {@link ServletContextHelper} services, the value of this service
+	 * property must be of type {@code String}. The value is either a slash for
+	 * the root or it must start with a slash but not end with a slash. Valid
+	 * characters are defined in rfc3986#section-3.3. Contexts with an invalid
+	 * path are ignored.
+	 * 
+	 * @see #HTTP_WHITEBOARD_CONTEXT_NAME
+	 * @see #HTTP_WHITEBOARD_CONTEXT_SELECT
+	 */
+	public static final String	HTTP_WHITEBOARD_CONTEXT_PATH				= "osgi.http.whiteboard.context.path";
+
+	/**
+	 * Service property prefix referencing a {@link ServletContextHelper}
+	 * service.
+	 * 
+	 * <p>
+	 * For {@link ServletContextHelper} services this prefix can be used for
+	 * service properties to mark them as initialization parameters which can be
+	 * retrieved from the associated servlet context. The prefix is removed from
+	 * the service property name to build the initialization parameter name.
+	 *
+	 * <p>
+	 * For {@link ServletContextHelper} services, the value of each
+	 * initialization parameter service property must be of type {@code String}.
+	 * 
+	 */
+	public static final String	HTTP_WHITEBOARD_CONTEXT_INIT_PARAM_PREFIX	= "context.init.";
+
+	/**
+	 * Service property referencing a {@link ServletContextHelper} service.
+	 * 
+	 * <p>
+	 * For servlet, listener, servlet filter, or resource services, this service
+	 * property refers to the associated {@code ServletContextHelper} service.
+	 * The value of this property is a filter expression which is matched
+	 * against the service registration properties of the
+	 * {@code ServletContextHelper} service. If this service property is not
+	 * specified, the default context is used. If there is no context service
+	 * matching, the servlet, listener, servlet filter, or resource service is
+	 * ignored.
+	 * <p>
+	 * For example, if a whiteboard service wants to select a servlet context
+	 * helper with the name &quot;Admin&quot; the expression would be
+	 * &quot;(osgi.http.whiteboard.context.name=Admin)&quot;. Selecting all
+	 * contexts could be done with
+	 * &quot;(osgi.http.whiteboard.context.name=*)&quot;.
+	 * <p>
+	 * For servlet, listener, servlet filter, or resource services, the value of
+	 * this service property must be of type {@code String}.
+	 * 
+	 * @see #HTTP_WHITEBOARD_CONTEXT_NAME
+	 * @see #HTTP_WHITEBOARD_CONTEXT_PATH
+	 */
+	public static final String	HTTP_WHITEBOARD_CONTEXT_SELECT				= "osgi.http.whiteboard.context.select";
+
+	/**
+	 * Service property specifying the servlet name of a {@code Servlet}
+	 * service.
+	 * <p>
+	 * 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}.
+	 */
+	public static final String	HTTP_WHITEBOARD_SERVLET_NAME				= "osgi.http.whiteboard.servlet.name";
+
+	/**
+	 * 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,
+	 * {@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>}.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 12.2 Specification of Mappings"
+	 */
+	public static final String	HTTP_WHITEBOARD_SERVLET_PATTERN				= "osgi.http.whiteboard.servlet.pattern";
+
+	/**
+	 * Service property specifying whether a {@code Servlet} service acts as an
+	 * error page.
+	 * 
+	 * <p>
+	 * The service property values may be the name of a fully qualified
+	 * exception class, a three digit HTTP status code, the value "4xx" for all
+	 * error codes in the 400 range, or the value "5xx" for all error codes in
+	 * the 500 range. Any value that is not a three digit number, or one of the
+	 * two special values is considered to be the name of a fully qualified
+	 * exception class.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String},
+	 * {@code String[]}, or {@code Collection<String>}.
+	 */
+	public static final String	HTTP_WHITEBOARD_SERVLET_ERROR_PAGE			= "osgi.http.whiteboard.servlet.errorPage";
+
+	/**
+	 * Service property specifying whether a {@code Servlet} service supports
+	 * asynchronous processing.
+	 * 
+	 * <p>
+	 * By default servlet services do not support asynchronous processing.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code Boolean}.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 2.3.3.3 Asynchronous Processing"
+	 */
+	public static final String	HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED		= "osgi.http.whiteboard.servlet.asyncSupported";
+
+	/**
+	 * Service property prefix referencing a {@link Servlet} service.
+	 * 
+	 * <p>
+	 * For {@link Servlet} services this prefix can be used for service
+	 * properties to mark them as initialization parameters which can be
+	 * retrieved from the associated servlet config. The prefix is removed from
+	 * the service property name to build the initialization parameter name.
+	 *
+	 * <p>
+	 * For {@link Servlet} services, the value of each initialization parameter
+	 * service property must be of type {@code String}.
+	 * 
+	 */
+	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 the default threshold is determined by the implementation.
+	 * <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".
+	 * <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 the default maximum size is -1 (no maximum size).
+	 * <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 the default maximum request size is -1 (no maximum size).
+	 * <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.
+	 * 
+	 * <p>
+	 * This name is used as the value for the
+	 * {@code FilterConfig.getFilterName()} method. If this service property is
+	 * not specified, the fully qualified name of the service object's class is
+	 * used as the servlet filter name.
+	 * 
+	 * <p>
+	 * Servlet filter names should be unique among all servlet filter services
+	 * associated with a single {@link ServletContextHelper}.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String}.
+	 */
+	public static final String	HTTP_WHITEBOARD_FILTER_NAME					= "osgi.http.whiteboard.filter.name";
+
+	/**
+	 * Service property specifying the request mappings for a {@code Filter}
+	 * service.
+	 * 
+	 * <p>
+	 * The specified patterns are used to determine whether a request should be
+	 * mapped to the servlet filter. Filter services without this service
+	 * property or the {@link #HTTP_WHITEBOARD_FILTER_SERVLET} or the
+	 * {@link #HTTP_WHITEBOARD_FILTER_REGEX} service property are ignored.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String},
+	 * {@code String[]}, or {@code Collection<String>}.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 12.2 Specification of Mappings"
+	 */
+	public static final String	HTTP_WHITEBOARD_FILTER_PATTERN				= "osgi.http.whiteboard.filter.pattern";
+
+	/**
+	 * Service property specifying the {@link #HTTP_WHITEBOARD_SERVLET_NAME
+	 * servlet names} for a servlet {@code Filter} service.
+	 * 
+	 * <p>
+	 * The specified names are used to determine the servlets whose requests
+	 * should be mapped to the servlet filter. Servlet filter services without
+	 * this service property or the {@link #HTTP_WHITEBOARD_FILTER_PATTERN} or
+	 * the {@link #HTTP_WHITEBOARD_FILTER_REGEX} service property are ignored.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String},
+	 * {@code String[]}, or {@code Collection<String>}.
+	 */
+	public static final String	HTTP_WHITEBOARD_FILTER_SERVLET				= "osgi.http.whiteboard.filter.servlet";
+
+	/**
+	 * Service property specifying the request mappings for a servlet
+	 * {@code Filter} service.
+	 * 
+	 * <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 {@code java.util.regex.Pattern}. Servlet
+	 * filter services without this service property or the
+	 * {@link #HTTP_WHITEBOARD_FILTER_SERVLET} or the
+	 * {@link #HTTP_WHITEBOARD_FILTER_PATTERN} service property are ignored.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String},
+	 * {@code String[]}, or {@code Collection<String>}.
+	 * 
+	 * @see "java.util.regex.Pattern"
+	 */
+	public static final String	HTTP_WHITEBOARD_FILTER_REGEX				= "osgi.http.whiteboard.filter.regex";
+
+	/**
+	 * Service property specifying whether a servlet {@code Filter} service
+	 * supports asynchronous processing.
+	 * 
+	 * <p>
+	 * By default servlet filters services do not support asynchronous
+	 * processing.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code Boolean}.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 2.3.3.3 Asynchronous Processing"
+	 */
+	public static final String	HTTP_WHITEBOARD_FILTER_ASYNC_SUPPORTED		= "osgi.http.whiteboard.filter.asyncSupported";
+
+	/**
+	 * Service property specifying the dispatcher handling of a servlet
+	 * {@code Filter}.
+	 * 
+	 * <p>
+	 * By default servlet filter services are associated with client requests
+	 * only (see value {@link #DISPATCHER_REQUEST}).
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String},
+	 * {@code String[]}, or {@code Collection<String>}. Allowed values are
+	 * {@link #DISPATCHER_ASYNC}, {@link #DISPATCHER_ERROR},
+	 * {@link #DISPATCHER_FORWARD}, {@link #DISPATCHER_INCLUDE},
+	 * {@link #DISPATCHER_REQUEST}.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 6.2.5 Filters and the RequestDispatcher"
+	 */
+	public static final String	HTTP_WHITEBOARD_FILTER_DISPATCHER			= "osgi.http.whiteboard.filter.dispatcher";
+
+	/**
+	 * Service property prefix referencing a {@link Filter} service.
+	 * 
+	 * <p>
+	 * For {@link Filter} services this prefix can be used for service
+	 * properties to mark them as initialization parameters which can be
+	 * retrieved from the associated filter config. The prefix is removed from
+	 * the service property name to build the initialization parameter name.
+	 *
+	 * <p>
+	 * For {@link Filter} services, the value of each initialization parameter
+	 * service property must be of type {@code String}.
+	 * 
+	 */
+	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
+	 * Whiteboard implementation. If the value "false" is specified, the service
+	 * 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.
+	 */
+	public static final String	HTTP_WHITEBOARD_LISTENER					= "osgi.http.whiteboard.listener";
+
+	/**
+	 * Possible value for the {@link #HTTP_WHITEBOARD_FILTER_DISPATCHER}
+	 * property indicating the servlet filter is applied to client requests.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 6.2.5 Filters and the RequestDispatcher"
+	 */
+	public static final String	DISPATCHER_REQUEST							= "REQUEST";
+
+	/**
+	 * Possible value for the {@link #HTTP_WHITEBOARD_FILTER_DISPATCHER}
+	 * property indicating the servlet filter is applied to include calls to the
+	 * dispatcher.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 6.2.5 Filters and the RequestDispatcher"
+	 */
+	public static final String	DISPATCHER_INCLUDE							= "INCLUDE";
+
+	/**
+	 * Possible value for the {@link #HTTP_WHITEBOARD_FILTER_DISPATCHER}
+	 * property indicating the servlet filter is applied to forward calls to the
+	 * dispatcher.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 6.2.5 Filters and the RequestDispatcher"
+	 */
+	public static final String	DISPATCHER_FORWARD							= "FORWARD";
+
+	/**
+	 * Possible value for the {@link #HTTP_WHITEBOARD_FILTER_DISPATCHER}
+	 * property indicating the servlet filter is applied in the asynchronous
+	 * context.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 6.2.5 Filters and the RequestDispatcher"
+	 */
+	public static final String	DISPATCHER_ASYNC							= "ASYNC";
+
+	/**
+	 * Possible value for the {@link #HTTP_WHITEBOARD_FILTER_DISPATCHER}
+	 * property indicating the servlet filter is applied when an error page is
+	 * called.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 6.2.5 Filters and the RequestDispatcher"
+	 */
+	public static final String	DISPATCHER_ERROR							= "ERROR";
+
+	/**
+	 * Service property specifying the request mappings for resources.
+	 * 
+	 * <p>
+	 * The specified patterns are used to determine whether a request should be
+	 * mapped to resources. Resource services without this service property are
+	 * ignored.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String},
+	 * {@code String[]}, or {@code Collection<String>}.
+	 * 
+	 * @see "Java Servlet Specification Version 3.0, Section 12.2 Specification of Mappings"
+	 * @see #HTTP_WHITEBOARD_RESOURCE_PREFIX
+	 */
+	public static final String	HTTP_WHITEBOARD_RESOURCE_PATTERN			= "osgi.http.whiteboard.resource.pattern";
+
+	/**
+	 * Service property specifying the resource entry prefix for a resource
+	 * service.
+	 * 
+	 * <p>
+	 * If a resource service is registered with this property, requests are
+	 * served with bundle resources.
+	 * 
+	 * <p>
+	 * This prefix is used to map a requested resource to the bundle's entries.
+	 * The value must not end with slash (&quot;/&quot;) with the exception that
+	 * a name of the form &quot;/&quot; is used to denote the root of the
+	 * bundle. See the specification text for details on how HTTP requests are
+	 * mapped.
+	 *
+	 * <p>
+	 * The value of this service property must be of type {@code String}.
+	 * 
+	 * @see #HTTP_WHITEBOARD_RESOURCE_PATTERN
+	 */
+	public static final String	HTTP_WHITEBOARD_RESOURCE_PREFIX				= "osgi.http.whiteboard.resource.prefix";
+
+	/**
+	 * Service property specifying the target filter to select the Http
+	 * Whiteboard implementation to process the service.
+	 * 
+	 * <p>
+	 * An Http Whiteboard implementation can define any number of service
+	 * properties which can be referenced by the target filter. The service
+	 * properties should always include the
+	 * {@link HttpServiceRuntimeConstants#HTTP_SERVICE_ENDPOINT
+	 * osgi.http.endpoint} service property if the endpoint information is
+	 * known.
+	 * 
+	 * <p>
+	 * If this service property is not specified, then all Http Whiteboard
+	 * implementations can process the service.
+	 * 
+	 * <p>
+	 * The value of this service property must be of type {@code String} and be
+	 * 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 for filtering are
+	 * treated as an invalid registration.
+	 * 
+	 * @since 1.1
+	 */
+	public static final String	HTTP_SERVICE_CONTEXT_PROPERTY						= "osgi.http.whiteboard.context.httpservice";
+}
+

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/HttpWhiteboardConstants.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Added: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/Preprocessor.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/Preprocessor.java?rev=1777088&view=auto
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/Preprocessor.java (added)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/Preprocessor.java Tue Jan  3 08:12:45 2017
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) OSGi Alliance (2000, 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.
+ * 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
+}

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/Preprocessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/Preprocessor.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Added: 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=1777088&view=auto
==============================================================================
--- felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java (added)
+++ felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java Tue Jan  3 08:12:45 2017
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) OSGi Alliance (2010, 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.
+ * 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.
+ */
+
+/**
+ * Http Whiteboard Package Version 1.0.
+ * 
+ * <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)"}
+ * <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)"}
+ * 
+ * @author $Id$
+ */
+
+@Version("1.1")
+package org.osgi.service.http.whiteboard;
+
+import org.osgi.annotation.versioning.Version;
+

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/http/api/src/main/java/org/osgi/service/http/whiteboard/package-info.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Modified: felix/trunk/http/base/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/pom.xml?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/pom.xml (original)
+++ felix/trunk/http/base/pom.xml Tue Jan  3 08:12:45 2017
@@ -73,16 +73,16 @@
             <artifactId>osgi.core</artifactId>
         </dependency>
         <dependency>
-            <groupId>org.osgi</groupId>
-            <artifactId>osgi.cmpn</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.apache.felix</groupId>
             <artifactId>org.apache.felix.http.api</artifactId>
-            <version>3.0.0</version>
+            <version>3.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>osgi.cmpn</artifactId>
+        </dependency>
+        <dependency>
             <groupId>com.google.code.findbugs</groupId>
             <artifactId>jsr305</artifactId>
             <version>3.0.0</version>

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/dispatch/Dispatcher.java Tue Jan  3 08:12:45 2017
@@ -85,6 +85,12 @@ public final class Dispatcher
             mgr.sessionDestroyed(session, ids);
         }
 
+        // invoke preprocessors
+        if ( !mgr.invokePreprocessors(req, res) )
+        {
+            return;
+        }
+
         // get full decoded path for dispatching
         // we can't use req.getRequestURI() or req.getRequestURL() as these are returning the encoded path
         String path = req.getServletPath();

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PreprocessorHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PreprocessorHandler.java?rev=1777088&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PreprocessorHandler.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/handler/PreprocessorHandler.java Tue Jan  3 08:12:45 2017
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.felix.http.base.internal.handler;
+
+import java.io.IOException;
+
+import javax.annotation.Nonnull;
+import javax.servlet.FilterChain;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.felix.http.base.internal.logger.SystemLogger;
+import org.apache.felix.http.base.internal.runtime.PreprocessorInfo;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.runtime.dto.DTOConstants;
+import org.osgi.service.http.whiteboard.Preprocessor;
+
+/**
+ * The preprocessor handler handles the initialization and destruction of preprocessor
+ * objects.
+ */
+public class PreprocessorHandler implements Comparable<PreprocessorHandler>
+{
+    private final PreprocessorInfo info;
+
+    private final ServletContext context;
+
+    private final BundleContext bundleContext;
+
+    private volatile Preprocessor preprocessor;
+
+    public PreprocessorHandler(final BundleContext bundleContext,
+            final ServletContext context,
+            final PreprocessorInfo info)
+    {
+        this.bundleContext = bundleContext;
+        this.context = context;
+        this.info = info;
+    }
+
+    @Override
+    public int compareTo(final PreprocessorHandler other)
+    {
+        return this.info.compareTo(other.info);
+    }
+
+    public ServletContext getContext()
+    {
+        return this.context;
+    }
+
+    public PreprocessorInfo getPreprocessorInfo()
+    {
+        return this.info;
+    }
+
+    public int init()
+    {
+        final ServiceReference<Preprocessor> serviceReference = this.info.getServiceReference();
+        this.preprocessor = this.bundleContext.getService(serviceReference);
+
+        if (this.preprocessor == null)
+        {
+            return DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE;
+        }
+
+        try
+        {
+            this.preprocessor.init(new FilterConfigImpl(this.preprocessor.getClass().getName(),
+                    getContext(),
+                    getPreprocessorInfo().getInitParameters()));
+        }
+        catch (final Exception e)
+        {
+            SystemLogger.error(this.getPreprocessorInfo().getServiceReference(),
+                    "Error during calling init() on preprocessor " + this.preprocessor,
+                    e);
+
+            this.preprocessor = null;
+            this.bundleContext.ungetService(serviceReference);
+
+            return DTOConstants.FAILURE_REASON_EXCEPTION_ON_INIT;
+        }
+
+        return -1;
+    }
+
+    public boolean destroy()
+    {
+        if (this.preprocessor == null)
+        {
+            return false;
+        }
+
+        try
+        {
+            preprocessor.destroy();
+        }
+        catch ( final Exception ignore )
+        {
+            // we ignore this
+            SystemLogger.error(this.getPreprocessorInfo().getServiceReference(),
+                    "Error during calling destroy() on preprocessor " + this.preprocessor,
+                    ignore);
+        }
+        this.preprocessor = null;
+        this.bundleContext.ungetService(this.info.getServiceReference());
+
+        return true;
+    }
+
+    public void handle(@Nonnull final ServletRequest req,
+            @Nonnull final ServletResponse res,
+            @Nonnull final FilterChain chain) throws ServletException, IOException
+    {
+        this.preprocessor.doFilter(req, res, chain);
+    }
+
+    public boolean dispose()
+    {
+        // fully destroy the preprocessor
+        return this.destroy();
+    }
+
+    @Override
+    public int hashCode()
+    {
+        return 31 + info.hashCode();
+    }
+
+    @Override
+    public boolean equals(final Object obj)
+    {
+        if (this == obj)
+        {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass() )
+        {
+            return false;
+        }
+        final PreprocessorHandler other = (PreprocessorHandler) obj;
+        return info.equals(other.info);
+    }
+}

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

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

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/registry/ServletRegistry.java Tue Jan  3 08:12:45 2017
@@ -33,6 +33,7 @@ import javax.annotation.Nonnull;
 
 import org.apache.felix.http.base.internal.handler.ServletHandler;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
+import org.apache.felix.http.base.internal.runtime.dto.BuilderConstants;
 import org.apache.felix.http.base.internal.runtime.dto.ResourceDTOBuilder;
 import org.apache.felix.http.base.internal.runtime.dto.ServletDTOBuilder;
 import org.osgi.service.http.runtime.dto.DTOConstants;
@@ -48,6 +49,8 @@ import org.osgi.service.http.runtime.dto
  */
 public final class ServletRegistry
 {
+    private static final String NAMED_SERVLET_PATTERN = ":::";
+
     private volatile List<PathResolver> activeResolvers = Collections.emptyList();
 
     private final Map<String, List<ServletHandler>> inactiveServletMappings = new HashMap<String, List<ServletHandler>>();
@@ -104,7 +107,7 @@ public final class ServletRegistry
     public synchronized void addServlet(@Nonnull final ServletHandler handler)
     {
         // we have to check for every pattern in the info
-        // Can be null in case of error-handling servlets...
+        // Can be null in case of error-handling servlets and named servlets
         if ( handler.getServletInfo().getPatterns() != null )
         {
             final Map<ServletInfo, RegistrationStatus> newMap = new TreeMap<ServletInfo, ServletRegistry.RegistrationStatus>(this.mapping);
@@ -173,6 +176,26 @@ public final class ServletRegistry
             this.activeResolvers = resolvers;
             this.mapping = newMap;
         }
+        else if ( !handler.getServletInfo().isResource() && handler.getServletInfo().getName() != null )
+        {
+            final Map<ServletInfo, RegistrationStatus> newMap = new TreeMap<ServletInfo, ServletRegistry.RegistrationStatus>(this.mapping);
+
+            final RegistrationStatus status = new RegistrationStatus();
+            status.handler = handler;
+
+            // if a servlet has only a name we always try to activate
+            // this is not very efficient, but works
+            // add to active
+            final int result = handler.init();
+            if ( result == -1 )
+            {
+                addToNameMapping(handler);
+            }
+            addPattern(status, result, NAMED_SERVLET_PATTERN);
+
+            newMap.put(handler.getServletInfo(), status);
+            this.mapping = newMap;
+        }
     }
 
     private void addToNameMapping(final ServletHandler handler)
@@ -324,6 +347,21 @@ public final class ServletRegistry
                 cleanupHandler.dispose();
             }
         }
+        else if ( !info.isResource() && info.getName() != null )
+        {
+            final Map<ServletInfo, RegistrationStatus> newMap = new TreeMap<ServletInfo, ServletRegistry.RegistrationStatus>(this.mapping);
+            final RegistrationStatus status = newMap.remove(info);
+
+            if ( status != null )
+            {
+                removeFromNameMapping(info.getName(), status.handler);
+
+                this.mapping = newMap;
+
+                status.handler.dispose();
+            }
+
+        }
     }
 
     public synchronized void cleanup()
@@ -435,7 +473,14 @@ public final class ServletRegistry
                 if ( entry.getKey().isResource() )
                 {
                     final ResourceDTO state = ResourceDTOBuilder.build(entry.getValue().handler, map.getKey());
-                    state.patterns = Arrays.copyOf(map.getValue(), map.getValue().length);
+                    if ( map.getValue().length == 1 && NAMED_SERVLET_PATTERN == map.getValue()[0] )
+                    {
+                        state.patterns = BuilderConstants.EMPTY_STRING_ARRAY;
+                    }
+                    else
+                    {
+                        state.patterns = Arrays.copyOf(map.getValue(), map.getValue().length);
+                    }
                     if ( map.getKey() == -1 )
                     {
                         resourceDTOs.put(serviceId, state);
@@ -448,7 +493,14 @@ public final class ServletRegistry
                 else
                 {
                     final ServletDTO state = ServletDTOBuilder.build(entry.getValue().handler, map.getKey());
-                    state.patterns = Arrays.copyOf(map.getValue(), map.getValue().length);
+                    if ( map.getValue().length == 1 && NAMED_SERVLET_PATTERN == map.getValue()[0] )
+                    {
+                        state.patterns = BuilderConstants.EMPTY_STRING_ARRAY;
+                    }
+                    else
+                    {
+                        state.patterns = Arrays.copyOf(map.getValue(), map.getValue().length);
+                    }
                     if ( map.getKey() == -1 )
                     {
                         servletDTOs.put(serviceId, state);

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/FilterInfo.java Tue Jan  3 08:12:45 2017
@@ -41,12 +41,6 @@ import org.osgi.service.http.whiteboard.
 public final class FilterInfo extends WhiteboardServiceInfo<Filter>
 {
     /**
-     * Properties starting with this prefix are passed as filter init parameters to the
-     * {@code init()} method of the filter.
-     */
-    private static final String FILTER_INIT_PREFIX = "filter.init.";
-
-    /**
      * The name of the filter.
      */
     private final String name;
@@ -104,7 +98,7 @@ public final class FilterInfo extends Wh
         this.servletNames = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_SERVLET);
         this.patterns = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN);
         this.regexs = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX);
-        this.initParams = getInitParams(ref, FILTER_INIT_PREFIX);
+        this.initParams = getInitParams(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_INIT_PARAM_PREFIX);
         String[] dispatcherNames = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER);
         if (dispatcherNames != null && dispatcherNames.length > 0)
         {

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/PreprocessorInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/PreprocessorInfo.java?rev=1777088&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/PreprocessorInfo.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/PreprocessorInfo.java Tue Jan  3 08:12:45 2017
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.http.base.internal.runtime;
+
+import java.util.Map;
+
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+import org.osgi.service.http.whiteboard.Preprocessor;
+
+/**
+ * Provides registration information for a {@link Preprocessor}.
+ * <p>
+ * This class only provides information used at registration time, and as such differs
+ * slightly from the corresponding DTO
+ * </p>
+ */
+public final class PreprocessorInfo extends WhiteboardServiceInfo<Preprocessor>
+{
+    /**
+     * The preprocessor initialization parameters as provided during registration of the preprocessor.
+     */
+    private final Map<String, String> initParams;
+
+    public PreprocessorInfo(final ServiceReference<Preprocessor> ref)
+    {
+        super(ref);
+        this.initParams = getInitParams(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_PREPROCESSOR_INIT_PARAM_PREFIX);
+    }
+
+    /**
+     * Returns an immutable map of the init parameters.
+     */
+    public Map<String, String> getInitParameters()
+    {
+        return initParams;
+    }
+}

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

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

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/ServletInfo.java Tue Jan  3 08:12:45 2017
@@ -38,12 +38,6 @@ import org.osgi.service.http.whiteboard.
 public class ServletInfo extends WhiteboardServiceInfo<Servlet>
 {
     /**
-     * Properties starting with this prefix are passed as servlet init parameters to the
-     * {@code init()} method of the servlet.
-     */
-    private static final String SERVLET_INIT_PREFIX = "servlet.init.";
-
-    /**
      * The name of the servlet.
      */
     private final String name;
@@ -85,7 +79,7 @@ public class ServletInfo extends Whitebo
         this.errorPage = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE);
         this.patterns = getStringArrayProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN);
         this.asyncSupported = getBooleanProperty(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED);
-        this.initParams = getInitParams(ref, SERVLET_INIT_PREFIX);
+        this.initParams = getInitParams(ref, HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX);
         this.isResource = false;
         this.prefix = null;
     }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailedDTOHolder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailedDTOHolder.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailedDTOHolder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/FailedDTOHolder.java Tue Jan  3 08:12:45 2017
@@ -26,12 +26,14 @@ import org.apache.felix.http.base.intern
 import org.apache.felix.http.base.internal.runtime.AbstractInfo;
 import org.apache.felix.http.base.internal.runtime.FilterInfo;
 import org.apache.felix.http.base.internal.runtime.ListenerInfo;
+import org.apache.felix.http.base.internal.runtime.PreprocessorInfo;
 import org.apache.felix.http.base.internal.runtime.ResourceInfo;
 import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
 import org.apache.felix.http.base.internal.runtime.ServletInfo;
 import org.osgi.service.http.runtime.dto.FailedErrorPageDTO;
 import org.osgi.service.http.runtime.dto.FailedFilterDTO;
 import org.osgi.service.http.runtime.dto.FailedListenerDTO;
+import org.osgi.service.http.runtime.dto.FailedPreprocessorDTO;
 import org.osgi.service.http.runtime.dto.FailedResourceDTO;
 import org.osgi.service.http.runtime.dto.FailedServletContextDTO;
 import org.osgi.service.http.runtime.dto.FailedServletDTO;
@@ -49,14 +51,16 @@ public final class FailedDTOHolder
 
     public final List<FailedErrorPageDTO> failedErrorPageDTOs = new ArrayList<FailedErrorPageDTO>();
 
-    public final List<FailedServletContextDTO> failedServletContextDTO = new ArrayList<FailedServletContextDTO>();
+    public final List<FailedServletContextDTO> failedServletContextDTOs = new ArrayList<FailedServletContextDTO>();
+
+    public final List<FailedPreprocessorDTO> failedPreprocessorDTOs = new ArrayList<FailedPreprocessorDTO>();
 
     public void add(final AbstractInfo<?> info, final long contextId, final int failureCode)
     {
         if (info instanceof ServletContextHelperInfo)
         {
             final FailedServletContextDTO dto = (FailedServletContextDTO)ServletContextDTOBuilder.build((ServletContextHelperInfo)info, null, failureCode);
-            this.failedServletContextDTO.add(dto);
+            this.failedServletContextDTOs.add(dto);
         }
         else if (info instanceof ServletInfo )
         {
@@ -105,6 +109,11 @@ public final class FailedDTOHolder
             dto.servletContextId = contextId;
             this.failedListenerDTOs.add(dto);
         }
+        else if ( info instanceof PreprocessorInfo )
+        {
+            final FailedPreprocessorDTO dto = (FailedPreprocessorDTO)PreprocessorDTOBuilder.build((PreprocessorInfo) info, failureCode);
+            this.failedPreprocessorDTOs.add(dto);
+        }
         else
         {
             SystemLogger.error("Unsupported info type: " + info.getClass(), null);

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/PreprocessorDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/PreprocessorDTOBuilder.java?rev=1777088&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/PreprocessorDTOBuilder.java (added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/PreprocessorDTOBuilder.java Tue Jan  3 08:12:45 2017
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.http.base.internal.runtime.dto;
+
+import javax.annotation.Nonnull;
+
+import org.apache.felix.http.base.internal.runtime.PreprocessorInfo;
+import org.osgi.service.http.runtime.dto.FailedPreprocessorDTO;
+import org.osgi.service.http.runtime.dto.PreprocessorDTO;
+
+public final class PreprocessorDTOBuilder
+{
+
+    /**
+     * Build a preprocessor DTO from a filter info
+     * @param info The preprocessor info
+     * @return A preprocessor DTO
+     */
+    public static @Nonnull PreprocessorDTO build(@Nonnull final PreprocessorInfo info, final int reason)
+    {
+        final PreprocessorDTO dto = (reason != -1 ? new FailedPreprocessorDTO() : new PreprocessorDTO());
+
+        dto.initParams = info.getInitParameters();
+        dto.serviceId = info.getServiceId();
+
+        if ( reason != -1 )
+        {
+            ((FailedPreprocessorDTO)dto).failureReason = reason;
+        }
+
+        return dto;
+    }
+}

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

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

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RegistryRuntime.java Tue Jan  3 08:12:45 2017
@@ -20,18 +20,22 @@ package org.apache.felix.http.base.inter
 
 import java.util.Collection;
 
+import org.osgi.service.http.runtime.dto.PreprocessorDTO;
 import org.osgi.service.http.runtime.dto.ServletContextDTO;
 
 public final class RegistryRuntime
 {
     private final Collection<ServletContextDTO> contextDTOs;
     private final FailedDTOHolder failedDTOHolder;
+    private final Collection<PreprocessorDTO> preprocessorDTOs;
 
     public RegistryRuntime(final FailedDTOHolder failedDTOHolder,
-            final Collection<ServletContextDTO> contextDTOs)
+            final Collection<ServletContextDTO> contextDTOs,
+            final Collection<PreprocessorDTO> preprocessorDTOs)
     {
         this.failedDTOHolder = failedDTOHolder;
         this.contextDTOs = contextDTOs;
+        this.preprocessorDTOs = preprocessorDTOs;
     }
 
     public FailedDTOHolder getFailedDTOHolder()
@@ -43,4 +47,9 @@ public final class RegistryRuntime
     {
         return this.contextDTOs;
     }
+
+    public Collection<PreprocessorDTO> getPreprocessorDTOs()
+    {
+        return this.preprocessorDTOs;
+    }
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java?rev=1777088&r1=1777087&r2=1777088&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java (original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilder.java Tue Jan  3 08:12:45 2017
@@ -30,9 +30,11 @@ import org.osgi.service.http.runtime.Htt
 import org.osgi.service.http.runtime.dto.FailedErrorPageDTO;
 import org.osgi.service.http.runtime.dto.FailedFilterDTO;
 import org.osgi.service.http.runtime.dto.FailedListenerDTO;
+import org.osgi.service.http.runtime.dto.FailedPreprocessorDTO;
 import org.osgi.service.http.runtime.dto.FailedResourceDTO;
 import org.osgi.service.http.runtime.dto.FailedServletContextDTO;
 import org.osgi.service.http.runtime.dto.FailedServletDTO;
+import org.osgi.service.http.runtime.dto.PreprocessorDTO;
 import org.osgi.service.http.runtime.dto.RuntimeDTO;
 import org.osgi.service.http.runtime.dto.ServletContextDTO;
 
@@ -53,13 +55,15 @@ public final class RuntimeDTOBuilder
         final RuntimeDTO runtimeDTO = new RuntimeDTO();
         runtimeDTO.serviceDTO = createServiceDTO();
         runtimeDTO.servletContextDTOs = createContextDTOs();
+        runtimeDTO.preprocessorDTOs = createPreprocessorDTOs();
 
         runtimeDTO.failedErrorPageDTOs = registry.getFailedDTOHolder().failedErrorPageDTOs.toArray(new FailedErrorPageDTO[registry.getFailedDTOHolder().failedErrorPageDTOs.size()]);
         runtimeDTO.failedFilterDTOs = registry.getFailedDTOHolder().failedFilterDTOs.toArray(new FailedFilterDTO[registry.getFailedDTOHolder().failedFilterDTOs.size()]);
         runtimeDTO.failedListenerDTOs = registry.getFailedDTOHolder().failedListenerDTOs.toArray(new FailedListenerDTO[registry.getFailedDTOHolder().failedListenerDTOs.size()]);
         runtimeDTO.failedResourceDTOs = registry.getFailedDTOHolder().failedResourceDTOs.toArray(new FailedResourceDTO[registry.getFailedDTOHolder().failedResourceDTOs.size()]);
-        runtimeDTO.failedServletContextDTOs = registry.getFailedDTOHolder().failedServletContextDTO.toArray(new FailedServletContextDTO[registry.getFailedDTOHolder().failedServletContextDTO.size()]);
+        runtimeDTO.failedServletContextDTOs = registry.getFailedDTOHolder().failedServletContextDTOs.toArray(new FailedServletContextDTO[registry.getFailedDTOHolder().failedServletContextDTOs.size()]);
         runtimeDTO.failedServletDTOs = registry.getFailedDTOHolder().failedServletDTOs.toArray(new FailedServletDTO[registry.getFailedDTOHolder().failedServletDTOs.size()]);
+        runtimeDTO.failedPreprocessorDTOs = registry.getFailedDTOHolder().failedPreprocessorDTOs.toArray(new FailedPreprocessorDTO[registry.getFailedDTOHolder().failedPreprocessorDTOs.size()]);
 
         return runtimeDTO;
     }
@@ -98,4 +102,10 @@ public final class RuntimeDTOBuilder
         final Collection<ServletContextDTO> contexts = registry.getServletContextDTOs();
         return contexts.toArray(new ServletContextDTO[contexts.size()]);
     }
+
+    private PreprocessorDTO[] createPreprocessorDTOs()
+    {
+        final Collection<PreprocessorDTO> dtos = registry.getPreprocessorDTOs();
+        return dtos.toArray(new PreprocessorDTO[dtos.size()]);
+    }
 }

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=1777088&r1=1777087&r2=1777088&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 Tue Jan  3 08:12:45 2017
@@ -16,12 +16,20 @@
  */
 package org.apache.felix.http.base.internal.whiteboard;
 
+import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING;
+import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_SERVICE_NOT_GETTABLE;
+import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_SERVLET_CONTEXT_FAILURE;
+import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE;
+import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_UNKNOWN;
+import static org.osgi.service.http.runtime.dto.DTOConstants.FAILURE_REASON_VALIDATION_FAILED;
+
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
+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;
 
@@ -42,13 +50,61 @@ public class FailureStateHandler {
         this.serviceFailures.clear();
     }
 
-    public void add(final AbstractInfo<?> info, final int reason)
+    public void addFailure(final AbstractInfo<?> info, final int reason, final Exception ex)
+    {
+        this.addFailure(info, 0, reason, ex);
+    }
+
+    public void addFailure(final AbstractInfo<?> info, final int reason)
     {
-        this.add(info, 0, reason);
+        this.addFailure(info, 0, reason);
     }
 
-    public void add(final AbstractInfo<?> info, final long contextId, final int reason)
+    public void addFailure(final AbstractInfo<?> info, final long contextId, final int reason)
     {
+        this.addFailure(info, contextId, reason, null);
+    }
+
+    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 serviceInfo;
+        if ( info.getServiceReference() == null ) {
+            serviceInfo = "with id " + info.getServiceId();
+        } else {
+            serviceInfo = String.valueOf(info.getServiceId()) +
+                    " (bundle " + info.getServiceReference().getBundle().getSymbolicName()
+                    + " reference " + info.getServiceReference() + ")";
+        }
+        if ( reason == FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING )
+        {
+            SystemLogger.debug("Ignoring unmatching " + type + " service " + serviceInfo);
+        }
+        else if ( reason == FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE )
+        {
+            SystemLogger.debug("Ignoring shadowed " + type + " service " + serviceInfo);
+        }
+        else if ( reason == FAILURE_REASON_SERVICE_NOT_GETTABLE )
+        {
+            SystemLogger.error("Ignoring ungettable " + type + " service " + serviceInfo, ex);
+        }
+        else if ( reason == FAILURE_REASON_VALIDATION_FAILED )
+        {
+            SystemLogger.debug("Ignoring invalid " + type + " service " + serviceInfo);
+        }
+        else if ( reason == FAILURE_REASON_NO_SERVLET_CONTEXT_MATCHING )
+        {
+            SystemLogger.debug("Ignoring unmatched " + type + " service " + serviceInfo);
+        }
+        else if ( reason == FAILURE_REASON_SERVLET_CONTEXT_FAILURE )
+        {
+            SystemLogger.debug("Servlet context " + String.valueOf(contextId) + " failure: Ignoring " + type + " service " + serviceInfo);
+        }
+        else if ( reason == FAILURE_REASON_UNKNOWN)
+        {
+            SystemLogger.error("Exception while registering " + type + " service " + serviceInfo, ex);
+        }
+
         FailureStatus status = serviceFailures.get(info);
         if ( status == null )
         {



Mime
View raw message