Interface ContextMapping
-
- All Known Subinterfaces:
HttpContextMapping
,ServletContextHelperMapping
public interface ContextMapping
Interface common for mappings related to context:HttpContext
for Http Service scenarioServletContextHelper
for Whiteboard Service scenario
-
-
Field Summary
Fields Modifier and Type Field Description static String[]
EMPTY_STRING_ARRAY
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default String[]
getConnectors()
Get connector names through which this context should be accessible.String
getContextId()
Get an ID of the context that may be referenced later: UsinghttpContext.id
service registration property (legacy Pax Web Whiteboard approach) Usingosgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=name)
service registration property (OSGi CMPN Whiteboard approach)String
getContextPath()
Get a context path (directly matchingServletContext.getContextPath()
from Servlet API.Map<String,String>
getInitParameters()
Get context initialization parameters as defined byServletContext.getInitParameterNames()
(<context-param>
elements inweb.xml
).default String[]
getVirtualHosts()
Get virtual host names to which this context is mapped.
-
-
-
Field Detail
-
EMPTY_STRING_ARRAY
static final String[] EMPTY_STRING_ARRAY
-
-
Method Detail
-
getContextId
String getContextId()
Get an ID of the context that may be referenced later:
- Using
httpContext.id
service registration property (legacy Pax Web Whiteboard approach) - Using
osgi.http.whiteboard.context.select=(osgi.http.whiteboard.context.name=name)
service registration property (OSGi CMPN Whiteboard approach)
- Returns:
- context identifier; cannot be null
- Using
-
getContextPath
String getContextPath()
Get a context path (directly matching
ServletContext.getContextPath()
from Servlet API. This allows to augmentHttpContext
with context path, because original specification doesn't do it at all.When registering
HttpContext
directly, context path may be specified ashttpContext.id
service registration property.For complete picture, OSGi CMPN Whiteboard's
ServletContextHelper
may have context path specified usingosgi.http.whiteboard.context.name
service registration property orHttpWhiteboardContext
annotation.- Returns:
- context path as in servlet context path; can be null
-
getInitParameters
Map<String,String> getInitParameters()
Get context initialization parameters as defined by
ServletContext.getInitParameterNames()
(<context-param>
elements inweb.xml
).Please notice the "init" vs. "context" parameters confusion. Here - it's the same.
- Returns:
- context parameters; can be null
-
getVirtualHosts
default String[] getVirtualHosts()
Get virtual host names to which this context is mapped. Virtual hosts may be targeted by deployments in several ways:
- Legacy Pax Web way: by passing
httpContext.virtualhosts
init parameter (yes - init parameter, not service registration property) with mapped context (HttpContextMapping
). - Legacy (?) Pax Web way: by setting
Web-VirtualHosts
manifest header in WAR bundle - New (?) Pax Web way: by implementing this method when registering a context using
(
HttpContextMapping
orServletContextHelperMapping
).
By default, a context is mapped to all virtual hosts, which means that any web element registered with such context will be available in all virtual hosts.
Elements like servlets, filters are never directly associated with virtual hosts. It can only be done via association with some context.
- Returns:
- list of virtual hosts to which this context should be mapped. If
null
or 0-sized array is returned, context will be mapped to all virtual hosts.
- Legacy Pax Web way: by passing
-
getConnectors
default String[] getConnectors()
Get connector names through which this context should be accessible. This is mostly modelled for Jetty, but Tomcat and Undertow also have some tricky configuration.
- Returns:
-
-