Class ServletContextModel
- java.lang.Object
-
- org.ops4j.pax.web.service.spi.model.Identity
-
- org.ops4j.pax.web.service.spi.model.ServletContextModel
-
public final class ServletContextModel extends Identity
This class is 1:1 representation of server-specific
ServletContext
and is unaware of OSGi-related representation of a context (likeHttpContext
andServletContextHelper
).It represents a web application (that could be described using single
web.xml
descriptor), while the web elements (like servlets, filters, ...) or configuration (session, JSP config, ...) are contributed possibly by many bundles (bundle-scopedHttpService
services or whiteboard service registrations).Normally, web applications are represented by
web.xml
files which are parsed by server-specific parsers:- Jetty:
org.eclipse.jetty.webapp.StandardDescriptorProcessor.visit()
- Tomcat:
org.apache.catalina.startup.ContextConfig#configureContext()
,org.apache.tomcat.util.descriptor.web.WebXmlParser#parseWebXml()
When user registers (through
HttpService
or Whiteboard) a web element (like servlet), the registration seems unique, but physically, given servlet has to be explicitly registered to all relatedServletContextModel
(and eventually -ServletContext
). It is even more important during unregistration - simple call toHttpService.unregister(String)
has to iterate over all mappedServletContextModel
contexts.Each
OsgiContextModel
pointing to this class may declare virtual hosts. Actual, server specific context has to be mapped (server-specific method) to all these virtual hosts.Registered whiteboard element may refer to many
OsgiContextModel
- pointing to different or the same targetServletContextModel
. If two (or more)OsgiContextModel
point to the sameServletContextModel
, priority (service rank + service id) is checked to find singleOsgiContextModel
and associated helper.- Since:
- 8.0.0
- Jetty:
-
-
Constructor Summary
Constructors Constructor Description ServletContextModel(String contextPath)
-
Method Summary
-
Methods inherited from class org.ops4j.pax.web.service.spi.model.Identity
getId, getIdPrefix, getNumericId
-
-
-
-
Constructor Detail
-
ServletContextModel
public ServletContextModel(String contextPath)
-
-
Method Detail
-
enableServletModel
public void enableServletModel(ServletModel model)
Marks given
ServletModel
as enabled, which means it has to be immediately added to relevant mappings, because validation was performed earlier.- Parameters:
model
-
-
disableServletModel
public void disableServletModel(ServletModel model)
Marks given
ServletModel
as disabled, which means it should no longer be available on active mappings, and should be moved to list of disabled servlets.This method just removes the model from
ServletContextModel
, but special care should be taken, because givenServletModel
has to be remembered as disabled inServerModel
.- Parameters:
model
-
-
enableFilterModel
public void enableFilterModel(FilterModel model)
Marks given
FilterModel
as enabled.- Parameters:
model
-
-
disableFilterModel
public void disableFilterModel(FilterModel model)
Marks given
FilterModel
as disabled.- Parameters:
model
-
-
enableErrorPageModel
public void enableErrorPageModel(ErrorPageModel model)
Mark givenErrorPageModel
as enabled- Parameters:
model
-
-
disableErrorPageModel
public void disableErrorPageModel(ErrorPageModel model)
Mark givenErrorPageModel
as disabled- Parameters:
model
-
-
enableWebSocketModel
public void enableWebSocketModel(WebSocketModel model)
Marks given
WebSocketModel
as enabled.- Parameters:
model
-
-
disableWebSocketModel
public void disableWebSocketModel(WebSocketModel model)
Marks given
WebSocketModel
as disabled.- Parameters:
model
-
-
getContextPath
public String getContextPath()
-
getServletNameMapping
public Map<String,ServletModel> getServletNameMapping()
-
getFilterNameMapping
public Map<String,FilterModel> getFilterNameMapping()
-
getAliasMapping
public Map<String,ServletModel> getAliasMapping()
-
getServletUrlPatternMapping
public Map<String,ServletModel> getServletUrlPatternMapping()
-
getErrorPageMapping
public Map<String,ErrorPageModel> getErrorPageMapping()
-
getWebSocketUrlPathMapping
public Map<String,WebSocketModel> getWebSocketUrlPathMapping()
-
-