public interface ServletMapping extends ContextRelated
Servlet mapping contains all the information required to register a Servlet (either directly or
using whiteboard pattern).
This interface may be used directly, when user registers OSGi services using it as
Constants.OBJECTCLASS (explicit whiteboard approach) or will be used internally,
when user registers actual Servlet instance with service properties (or class annotations)
(as recommended by Whiteboard specification).
Registering a Servlet can be done in two ways:
Servlet service, while required properties (mapping, name, parameters) are specified
using service registration properties or annotations (OSGi CMPN Whiteboard approach)| Modifier and Type | Method and Description |
|---|---|
String |
getAlias()
Get an alias to use for servlet registration.
|
Boolean |
getAsyncSupported()
Get flag for supporting asynchronous servlet invocation.
|
String[] |
getErrorPages()
Get error page declarations to use for the servlet being registered.
|
Map<String,String> |
getInitParameters()
Get init parameters for the servlet being registered.
|
Integer |
getLoadOnStartup()
Get load on startup value for the servlet being registered.
|
javax.servlet.MultipartConfigElement |
getMultipartConfig()
Get
MultipartConfigElement to configuration multipart support for the servlet being registered. |
javax.servlet.Servlet |
getServlet()
Get an actual
Servlet instance to register. |
Class<? extends javax.servlet.Servlet> |
getServletClass()
Get a class of
Servlet to register. |
String |
getServletName()
Get a name of the servlet being registered.
|
String[] |
getUrlPatterns()
Get URL patterns to map into the servlet being registered.
|
getContextId, getContextSelectFilterjavax.servlet.Servlet getServlet()
Get an actual Servlet instance to register.
In whiteboard method, this is actual OSGi service instance.
Class<? extends javax.servlet.Servlet> getServletClass()
Get a class of Servlet to register. Matches <servlet>/<servlet-class> element from
web.xml. If getServlet() is also specified, servlet class isn't used.
There's no whiteboard specific method to specify this class.
String getServletName()
Get a name of the servlet being registered. Matches <servlet>/<servlet-name> element from
web.xml.
In whiteboard method, this can be specified as:
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME
propertyservlet-name service registration property (legacy Pax Web Whiteboard approach)If not specified, the name defaults to fully qualified class name of the servlet.
String[] getUrlPatterns()
Get URL patterns to map into the servlet being registered. URL patterns should be specified according
to Servlet API 4 specification (chapter 12.2) and OSGi CMPN R6+ Whiteboard specification (chapter 140.4).
It matches <servlet-mapping>/<url-pattern> elements from web.xml.
In whiteboard method, this can be specified as:
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN
propertyorg.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletPattern annotationurlPatterns service registration property (legacy Pax Web Whiteboard approach)String, String[] or
Collection<String> types.String getAlias()
Get an alias to use for servlet registration. An alias is defined in OSGi CMPN specification
of HTTP Service and is often (even in specification) confused with
servlet name: name in the URI namespace. For the purpose of Pax Web and consistency, single
alias is treated as one-element array of URL Patterns if the patterns are not specified.
There's no whiteboard specific method to specify an alias.
String[] getErrorPages()
Get error page declarations to use for the servlet being registered. The declarations mark the servlet
as error servlet matching <error-page>/<error-code> and <error-page>/<exception-type>
elementss from web.xml.
In whiteboard method, this can be specified as:
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ERROR_PAGE
propertyorg.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletErrorPage annotationBoolean getAsyncSupported()
Get flag for supporting asynchronous servlet invocation. It matches <servlet>/<async-supported>
element from web.xml.
In whiteboard method, this can be specified as:
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_ASYNC_SUPPORTED
propertyorg.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletAsyncSupported
annotationjavax.servlet.MultipartConfigElement getMultipartConfig()
Get MultipartConfigElement to configuration multipart support for the servlet being registered.
See Servlet API 4 specification (chapter 3.2 File upload) for details. It matches
<servlet>/<multipart-config> element from web.xml.
In whiteboard method, this can be specified as:
org.osgi.service.http.whiteboard.HttpWhiteboardConstants#HTTP_WHITEBOARD_SERVLET_MULTIPART_*
propertiesorg.osgi.service.http.whiteboard.propertytypes.HttpWhiteboardServletMultipart annotationMap<String,String> getInitParameters()
Get init parameters for the servlet being registered. It matches <servlet>/<init-param>
elements from web.xml.
In whiteboard method, this can be specified as (no annotation here):
HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_INIT_PARAM_PREFIX
prefixed properties (OSGi CMPN Whiteboard approach)init. prefixed properties (or prefix may be specified using init-prefix
service registration property (legacy Pax Web Whiteboard approach)Integer getLoadOnStartup()
Get load on startup value for the servlet being registered. It matches
<servlet>/<load-on-startup> element from web.xml.
Whiteboard specification doesn't mention this parameter.
Copyright © 2006–2024 OPS4J - Open Participation Software for Java. All rights reserved.