java.lang.Object
org.glassfish.grizzly.http.server.util.Mapper

public class Mapper extends Object
Mapper, which implements the servlet API mapping rules (which are derived from the HTTP rules).
Author:
Remy Maucherat
  • Field Details

    • hosts

      protected Mapper.Host[] hosts
      Array containing the virtual hosts definitions.
    • defaultHostName

      protected String defaultHostName
      Default host name.
    • context

      protected final Mapper.Context context
      Context associated with this wrapper, used for wrapper mapping.
  • Constructor Details

    • Mapper

      public Mapper()
  • Method Details

    • setAllowReplacement

      public static void setAllowReplacement(boolean ar)
    • allowReplacement

      public static boolean allowReplacement()
    • setPort

      public void setPort(int port)
      The Port this instance is used for mapping.
    • getPort

      public int getPort()
      Returns:
      the port this instance is used for mapping.
    • getDefaultHostName

      public String getDefaultHostName()
      Returns:
      Default host name
    • setDefaultHostName

      public void setDefaultHostName(String defaultHostName)
      Set default host.
      Parameters:
      defaultHostName - Default host name
    • addHost

      public void addHost(String name, String[] aliases, Object host)
      Add a new host to the mapper.
      Parameters:
      name - Virtual host name
      host - Host object
    • removeHost

      public void removeHost(String name)
      Remove a host from the mapper.
      Parameters:
      name - Virtual host name
    • getHosts

      public String[] getHosts()
    • setContext

      public void setContext(String path, String[] welcomeResources, NamingContext resources)
      Set context, used for wrapper mapping (request dispatcher).
      Parameters:
      welcomeResources - Welcome files defined for this context
      resources - Static resources of the context
    • addContext

      public void addContext(String hostName, String path, Object context, String[] welcomeResources, NamingContext resources)
      Add a new Context to an existing Host.
      Parameters:
      hostName - Virtual host name this context belongs to
      path - Context path
      context - Context object
      welcomeResources - Welcome files defined for this context
      resources - Static resources of the context
    • addContext

      public void addContext(String hostName, String path, Object context, String[] welcomeResources, NamingContext resources, List<AlternateDocBase> alternateDocBases)
      Add a new Context to an existing Host.
      Parameters:
      hostName - Virtual host name this context belongs to
      path - Context path
      context - Context object
      welcomeResources - Welcome files defined for this context
      resources - Static resources of the context
      alternateDocBases - the alternate docbases of the context
    • removeContext

      public void removeContext(String hostName, String path)
      Remove a context from an existing host.
      Parameters:
      hostName - Virtual host name this context belongs to
      path - Context path
    • getContextNames

      public String[] getContextNames()
      Return all contexts, in //HOST/PATH form
      Returns:
      The context names
    • addWrapper

      public void addWrapper(String hostName, String contextPath, String path, Object wrapper)
      Add a new Wrapper to an existing Context.
      Parameters:
      hostName - Virtual host name this wrapper belongs to
      contextPath - Context path this wrapper belongs to
      path - Wrapper mapping
      wrapper - Wrapper object
    • addWrapper

      public void addWrapper(String hostName, String contextPath, String path, Object wrapper, boolean jspWildCard)
      Add a new Wrapper to an existing Context.
      Parameters:
      hostName - Virtual host name this wrapper belongs to
      contextPath - Context path this wrapper belongs to
      path - Wrapper mapping
      wrapper - Wrapper object
      jspWildCard - jsp wildcard
    • addWrapper

      public void addWrapper(String hostName, String contextPath, String path, Object wrapper, boolean jspWildCard, String servletName, boolean isEmptyPathSpecial)
      Add a new Wrapper to an existing Context.
      Parameters:
      hostName - Virtual host name this wrapper belongs to
      contextPath - Context path this wrapper belongs to
      path - Wrapper mapping
      wrapper - Wrapper object
      jspWildCard - jsp wildcard
      servletName - servlet name or null if unknown
    • addWrapper

      public void addWrapper(String path, Object wrapper)
      Add a wrapper to the context associated with this wrapper.
      Parameters:
      path - Wrapper mapping
      wrapper - The Wrapper object
    • addWrapper

      public void addWrapper(String path, Object wrapper, boolean jspWildCard, boolean isEmptyPathSpecial)
    • addWrapper

      protected void addWrapper(Mapper.Context context, String path, Object wrapper)
    • addWrapper

      protected void addWrapper(Mapper.Context context, String path, Object wrapper, boolean jspWildCard, boolean isEmptyPathSpecial)
    • addWrapper

      protected void addWrapper(Mapper.Context context, String path, Object wrapper, boolean jspWildCard, String servletName, boolean isEmptyPathSpecial)
      Adds a wrapper to the given context.
      Parameters:
      context - The context to which to add the wrapper
      path - Wrapper mapping
      wrapper - The Wrapper object
      jspWildCard - true if the wrapper corresponds to the JspServlet and the mapping path contains a wildcard; false otherwise
      servletName - then name of servletName or null if unknown
    • removeWrapper

      public void removeWrapper(String path)
      Remove a wrapper from the context associated with this wrapper.
      Parameters:
      path - Wrapper mapping
    • removeWrapper

      public void removeWrapper(String hostName, String contextPath, String path)
      Remove a wrapper from an existing context.
      Parameters:
      hostName - Virtual host name this wrapper belongs to
      contextPath - Context path this wrapper belongs to
      path - Wrapper mapping
    • removeWrapper

      protected void removeWrapper(Mapper.Context context, String path)
    • getWrappersString

      public String getWrappersString(String host, String context)
    • getWrapperNames

      public String[] getWrapperNames(String host, String context)
    • setDefaultContextPath

      public void setDefaultContextPath(String hostName, String defaultContextPath) throws Exception
      Configures the given virtual server with the given default context path. The given default path corresponds to the context path of one of the web contexts deployed on the virtual server that has been designated as the virtual server's new default-web-module.
      Throws:
      Exception - if there is no web context deployed on the given virtual server that matches the given default context path
    • mapUriWithSemicolon

      public void mapUriWithSemicolon(org.glassfish.grizzly.http.HttpRequestPacket requestPacket, org.glassfish.grizzly.http.util.DataChunk decodedURI, MappingData mappingData, int semicolonPos) throws Exception
      Maps the decodedURI to the corresponding HttpHandler, considering that URI may have a semicolon with extra data followed, which shouldn't be a part of mapping process.
      Parameters:
      requestPacket - the request packet containing the host information to be used by the mapping process.
      decodedURI - decoded URI
      mappingData - MappingData based on the URI.
      semicolonPos - semicolon position. Might be 0 if position wasn't resolved yet (so it will be resolved in the method), or -1 if there is no semicolon in the URI.
      Throws:
      Exception - if an error occurs mapping the request
    • mapUriWithSemicolon

      public void mapUriWithSemicolon(org.glassfish.grizzly.http.util.DataChunk serverName, org.glassfish.grizzly.http.util.DataChunk decodedURI, MappingData mappingData, int semicolonPos) throws Exception
      Maps the decodedURI to the corresponding HttpHandler, considering that URI may have a semicolon with extra data followed, which shouldn't be a part of mapping process.
      Parameters:
      serverName - the server name as described by the Host header.
      decodedURI - decoded URI
      mappingData - MappingData based on the URI.
      semicolonPos - semicolon position. Might be 0 if position wasn't resolved yet (so it will be resolved in the method), or -1 if there is no semicolon in the URI.
      Throws:
      Exception - if an error occurs mapping the request
    • map

      public void map(org.glassfish.grizzly.http.util.DataChunk host, org.glassfish.grizzly.http.util.DataChunk uri, MappingData mappingData) throws Exception
      Map the specified host name and URI, mutating the given mapping data.
      Parameters:
      host - Virtual host name
      uri - URI
      mappingData - This structure will contain the result of the mapping operation
      Throws:
      Exception
    • map

      public void map(org.glassfish.grizzly.http.HttpRequestPacket requestPacket, org.glassfish.grizzly.http.util.DataChunk uri, MappingData mappingData) throws Exception
      Map the specified host name and URI, mutating the given mapping data.
      Parameters:
      requestPacket - the http request containing host name information used by the mapping process.
      uri - URI
      mappingData - This structure will contain the result of the mapping operation
      Throws:
      Exception
    • map

      public void map(org.glassfish.grizzly.http.util.MessageBytes uri, MappingData mappingData) throws Exception
      Map the specified URI relative to the context, mutating the given mapping data.
      Parameters:
      uri - URI
      mappingData - This structure will contain the result of the mapping operation
      Throws:
      Exception