Class ServletContainer


  • public final class ServletContainer
    extends Object
    A static registry for the servlet container context.
    Version:
    $Revision: 1.1 $
    Author:
    Julien Viet
    • Constructor Detail

      • ServletContainer

        public ServletContainer()
    • Method Detail

      • registerWebApp

        public void registerWebApp​(WebAppContext webappContext,
                                   String dispatchPath)
        Manually register a webapp with this ServletContainerContext.
        Parameters:
        webappContext - the WebAppContext associated with the application
        dispatchPath - the path to be used
      • unregisterWebApp

        public void unregisterWebApp​(javax.servlet.ServletContext servletContext)
        Manually unregister a webapp associated with this ServletContainerContext.
        Parameters:
        servletContext - the servletContext of the application to be deregistered
      • isDisabledNativeRegistration

        public static boolean isDisabledNativeRegistration​(javax.servlet.ServletContext servletContext)
      • register

        public void register​(ServletContainerContext context)
        Register a servlet container context. The registration is considered as successful if no existing context is already registered.
        Parameters:
        context - the servlet container context to register
        Throws:
        IllegalArgumentException - if the context is null
      • login

        public void login​(javax.servlet.http.HttpServletRequest request,
                          javax.servlet.http.HttpServletResponse response,
                          Credentials credentials)
                   throws javax.servlet.ServletException,
                          IOException
        Authentication support.
        Parameters:
        request - the request valid in the current servlet context
        response - the response valid in the current servlet context
        credentials - the credentials which try to authenticate
        Throws:
        AuthenticationException - when authentication fails
        IllegalStateException - when the user is already authenticated
        javax.servlet.ServletException - any servlet exception that would prevent authentication to be performed
        IOException - any io exception that would prevent authentication to be performed
      • logout

        public void logout​(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
        Authentication support.
        Parameters:
        request - the request valid in the current servlet context
        response - the response valid in the current servlet context
        Throws:
        IllegalStateException - when the user is not authenticated
      • addAuthenticationListener

        public void addAuthenticationListener​(AuthenticationListener listener)
        Add the authentication listener.
        Parameters:
        listener - AuthenticationListener to add
      • removeAuthenticationlistener

        public void removeAuthenticationlistener​(AuthenticationListener listener)
        Remove the authentication listener.
        Parameters:
        listener - AuthenticationListener to remove
      • getContainerInfo

        public String getContainerInfo()
        Returns the name and version of the servlet container in which the context is running.

        The form of the returned string is containername/versionnumber.

        Returns:
        the string containing at least name and version number
      • addWebAppListener

        public boolean addWebAppListener​(WebAppListener listener)
        Add a web listener.
        Parameters:
        listener - the listener
        Returns:
        true if the listener has been added
      • removeWebAppListener

        public boolean removeWebAppListener​(WebAppListener listener)
        Removes a web listener.
        Parameters:
        listener - the listener
        Returns:
        true if the listener has been removed
      • include

        public Object include​(javax.servlet.ServletContext targetServletContext,
                              javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response,
                              RequestDispatchCallback callback,
                              Object handback)
                       throws javax.servlet.ServletException,
                              IOException
        Generic detyped request dispatch to a servlet context using the include mechanism.
        Parameters:
        targetServletContext - the target servlet context to dispatch to
        request - the request valid in the current servlet context
        response - the response valid in the current servlet context
        callback - the callback to perform after the dispatch operation
        handback - the handback object that will be provided to the callback
        Returns:
        the object returned by the callback
        Throws:
        javax.servlet.ServletException - any servlet exception
        IOException - any io exception
      • visit

        public void visit​(ServletContainerVisitor visitor)
        Visit the registered WebApps
        Parameters:
        visitor - ServletContainerVisitor instance