Class Mapper
- 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).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classMapper.Contextprotected static classMapper.ContextListprotected static classMapper.Hostprotected static classMapper.MapElementprotected static classMapper.Wrapper
-
Field Summary
Fields Modifier and Type Field Description protected Mapper.ContextcontextContext associated with this wrapper, used for wrapper mapping.protected StringdefaultHostNameDefault host name.protected Mapper.Host[]hostsArray containing the virtual hosts definitions.
-
Constructor Summary
Constructors Constructor Description Mapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddContext(String hostName, String path, Object context, String[] welcomeResources, NamingContext resources)Add a new Context to an existing Host.voidaddContext(String hostName, String path, Object context, String[] welcomeResources, NamingContext resources, List<AlternateDocBase> alternateDocBases)Add a new Context to an existing Host.voidaddHost(String name, String[] aliases, Object host)Add a new host to the mapper.voidaddWrapper(String path, Object wrapper)Add a wrapper to the context associated with this wrapper.voidaddWrapper(String path, Object wrapper, boolean jspWildCard, boolean isEmptyPathSpecial)voidaddWrapper(String path, Object wrapper, boolean jspWildCard, String servletName, boolean isEmptyPathSpecial)voidaddWrapper(String hostName, String contextPath, String path, Object wrapper)Add a new Wrapper to an existing Context.voidaddWrapper(String hostName, String contextPath, String path, Object wrapper, boolean jspWildCard)Add a new Wrapper to an existing Context.voidaddWrapper(String hostName, String contextPath, String path, Object wrapper, boolean jspWildCard, String servletName, boolean isEmptyPathSpecial)Add a new Wrapper to an existing Context.protected voidaddWrapper(Mapper.Context context, String path, Object wrapper)protected voidaddWrapper(Mapper.Context context, String path, Object wrapper, boolean jspWildCard, boolean isEmptyPathSpecial)protected voidaddWrapper(Mapper.Context context, String path, Object wrapper, boolean jspWildCard, String servletName, boolean isEmptyPathSpecial)Adds a wrapper to the given context.static booleanallowReplacement()true if replacement of already added [@link Host},Mapper.ContextandMapper.Wrapperwhen invokingaddHost(java.lang.String, java.lang.String[], java.lang.Object),addContext(java.lang.String, java.lang.String, java.lang.Object, java.lang.String[], org.glassfish.grizzly.http.server.naming.NamingContext)etc.String[]getContextNames()Return all contexts, in //HOST/PATH formStringgetDefaultHostName()String[]getHosts()intgetPort()String[]getWrapperNames(String host, String context)StringgetWrappersString(String host, String context)voidmap(org.glassfish.grizzly.http.HttpRequestPacket requestPacket, org.glassfish.grizzly.http.util.DataChunk uri, MappingData mappingData)Map the specified host name and URI, mutating the given mapping data.voidmap(org.glassfish.grizzly.http.util.DataChunk host, org.glassfish.grizzly.http.util.DataChunk uri, MappingData mappingData)Map the specified host name and URI, mutating the given mapping data.voidmap(org.glassfish.grizzly.http.util.MessageBytes uri, MappingData mappingData)Map the specified URI relative to the context, mutating the given mapping data.voidmapUriWithSemicolon(org.glassfish.grizzly.http.HttpRequestPacket requestPacket, org.glassfish.grizzly.http.util.DataChunk decodedURI, MappingData mappingData, int semicolonPos)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.voidmapUriWithSemicolon(org.glassfish.grizzly.http.util.DataChunk serverName, org.glassfish.grizzly.http.util.DataChunk decodedURI, MappingData mappingData, int semicolonPos)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.voidremoveContext(String hostName, String path)Remove a context from an existing host.voidremoveHost(String name)Remove a host from the mapper.voidremoveWrapper(String path)Remove a wrapper from the context associated with this wrapper.voidremoveWrapper(String hostName, String contextPath, String path)Remove a wrapper from an existing context.protected voidremoveWrapper(Mapper.Context context, String path)static voidsetAllowReplacement(boolean ar)Allow replacement of already addedMapper.Host,Mapper.ContextandMapper.Wrapperwhen invokingaddHost(java.lang.String, java.lang.String[], java.lang.Object),addContext(java.lang.String, java.lang.String, java.lang.Object, java.lang.String[], org.glassfish.grizzly.http.server.naming.NamingContext)etc.voidsetContext(String path, String[] welcomeResources, NamingContext resources)Set context, used for wrapper mapping (request dispatcher).voidsetDefaultContextPath(String hostName, String defaultContextPath)Configures the given virtual server with the given default context path.voidsetDefaultHostName(String defaultHostName)Set default host.voidsetPort(int port)The Port this instance is used for mapping.
-
-
-
Field Detail
-
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.
-
-
Method Detail
-
setAllowReplacement
public static void setAllowReplacement(boolean ar)
Allow replacement of already addedMapper.Host,Mapper.ContextandMapper.Wrapperwhen invokingaddHost(java.lang.String, java.lang.String[], java.lang.Object),addContext(java.lang.String, java.lang.String, java.lang.Object, java.lang.String[], org.glassfish.grizzly.http.server.naming.NamingContext)etc. Default is false
-
allowReplacement
public static boolean allowReplacement()
true if replacement of already added [@link Host},Mapper.ContextandMapper.Wrapperwhen invokingaddHost(java.lang.String, java.lang.String[], java.lang.Object),addContext(java.lang.String, java.lang.String, java.lang.Object, java.lang.String[], org.glassfish.grizzly.http.server.naming.NamingContext)etc. Default is false
-
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 namehost- 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 contextresources- 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 topath- Context pathcontext- Context objectwelcomeResources- Welcome files defined for this contextresources- 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 topath- Context pathcontext- Context objectwelcomeResources- Welcome files defined for this contextresources- Static resources of the contextalternateDocBases- 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 topath- 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 tocontextPath- Context path this wrapper belongs topath- Wrapper mappingwrapper- 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 tocontextPath- Context path this wrapper belongs topath- Wrapper mappingwrapper- Wrapper objectjspWildCard- 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 tocontextPath- Context path this wrapper belongs topath- Wrapper mappingwrapper- Wrapper objectjspWildCard- jsp wildcardservletName- 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 mappingwrapper- The Wrapper object
-
addWrapper
public void addWrapper(String path, Object wrapper, boolean jspWildCard, boolean isEmptyPathSpecial)
-
addWrapper
public void addWrapper(String path, Object wrapper, boolean jspWildCard, String servletName, 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 wrapperpath- Wrapper mappingwrapper- The Wrapper objectjspWildCard- true if the wrapper corresponds to the JspServlet and the mapping path contains a wildcard; false otherwiseservletName- 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 tocontextPath- Context path this wrapper belongs topath- Wrapper mapping
-
removeWrapper
protected void removeWrapper(Mapper.Context context, String path)
-
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 ExceptionMaps 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 URImappingData-MappingDatabased 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 ExceptionMaps 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 URImappingData-MappingDatabased 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 ExceptionMap the specified host name and URI, mutating the given mapping data.- Parameters:
host- Virtual host nameuri- URImappingData- 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 ExceptionMap 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- URImappingData- 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 ExceptionMap the specified URI relative to the context, mutating the given mapping data.- Parameters:
uri- URImappingData- This structure will contain the result of the mapping operation- Throws:
Exception
-
-