Class 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 (like HttpContext and ServletContextHelper).

    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-scoped HttpService 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 related ServletContextModel (and eventually - ServletContext). It is even more important during unregistration - simple call to HttpService.unregister(String) has to iterate over all mapped ServletContextModel 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 target ServletContextModel. If two (or more) OsgiContextModel point to the same ServletContextModel, priority (service rank + service id) is checked to find single OsgiContextModel and associated helper.

    Since:
    8.0.0
    • Constructor Detail

      • ServletContextModel

        public ServletContextModel​(String contextPath)