Top Description Inners Fields Constructors Methods
org.glassfish.grizzly.http.server.util

public Class Mapper

extends Object
Class Inheritance
Annotations
@SuppressWarnings:UnusedDeclaration
Imports
java.io.IOException, java.util.ArrayList, .HashMap, .List, .Map, java.util.logging.Level, .Logger, org.glassfish.grizzly.Grizzly, org.glassfish.grizzly.http.HttpRequestPacket, org.glassfish.grizzly.http.server.naming.DirContext, .NamingContext, .NamingException, org.glassfish.grizzly.http.util.Ascii, .CharChunk, .Constants, .DataChunk, .MessageBytes, org.glassfish.grizzly.utils.Charsets

Mapper, which implements the servlet API mapping rules (which are derived from the HTTP rules).

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
protected static class
protected static class
protected abstract static class
protected static class

Field Summary

Modifier and TypeField and Description
private static boolean
allowReplacement

Allow replacement of already added Host, Context and Wrapper

protected final Mapper.Context
context

Context associated with this wrapper, used for wrapper mapping.

private static final String
private final Map<String, String>
protected String
defaultHostName

Default host name.

protected Mapper.Host[]
hosts

Array containing the virtual hosts definitions.

private static final String
private static final Logger
private int
port

The port this Mapper is used

private static final CharChunk

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addContext(String
Virtual host name this context belongs to
hostName
,
String
Context path
path
,
Object
Context object
context
,
String[]
Welcome files defined for this context
welcomeResources
,
NamingContext
Static resources of the context
resources
)

Add a new Context to an existing Host.

public void
addContext(String
Virtual host name this context belongs to
hostName
,
String
Context path
path
,
Object
Context object
context
,
String[]
Welcome files defined for this context
welcomeResources
,
NamingContext
Static resources of the context
resources
,
List<AlternateDocBase>
the alternate docbases of the context
alternateDocBases
)

Add a new Context to an existing Host.

private void
addDefaultContext(Mapper.Host host, String defaultContextPath)

Configures the given virtual server with the given default context path.

public synchronized void
addHost(String
Virtual host name
name
,
String[] aliases, Object
Host object
host
)

Add a new host to the mapper.

public void
addWrapper(String
Virtual host name this wrapper belongs to
hostName
,
String
Context path this wrapper belongs to
contextPath
,
String
Wrapper mapping
path
,
Object
Wrapper object
wrapper
)

Add a new Wrapper to an existing Context.

public void
addWrapper(String
Virtual host name this wrapper belongs to
hostName
,
String
Context path this wrapper belongs to
contextPath
,
String
Wrapper mapping
path
,
Object
Wrapper object
wrapper
,
boolean
jsp wildcard
jspWildCard
)

Add a new Wrapper to an existing Context.

public void
addWrapper(String
Virtual host name this wrapper belongs to
hostName
,
String
Context path this wrapper belongs to
contextPath
,
String
Wrapper mapping
path
,
Object
Wrapper object
wrapper
,
boolean
jsp wildcard
jspWildCard
,
String
servlet name or null if unknown
servletName
,
boolean isEmptyPathSpecial)

Add a new Wrapper to an existing Context.

public void
addWrapper(String
Wrapper mapping
path
,
Object
The Wrapper object
wrapper
)

Add a wrapper to the context associated with this wrapper.

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

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

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

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

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

Adds a wrapper to the given context.

public static boolean
allowReplacement()

true if replacement of already added [@link Host}, Context and Wrapper when invoking addHost, addContext etc. Default is false

private static int
compare(CharChunk name, int start, int end, String compareTo)

Compare given char chunk with String.

private static int
compareIgnoreCase(CharChunk name, int start, int end, String compareTo)

Compare given char chunk with String ignoring case.

private static int
compareIgnoreCase(String name, String compareTo)

Compare given char chunk with String ignoring case.

private static int
find(Mapper.MapElement[] map, CharChunk name)

Find a map element given its name in a sorted array of map elements.

private static int
find(Mapper.MapElement[] map, CharChunk name, int start, int end)

Find a map element given its name in a sorted array of map elements.

private static int
find(final Mapper.MapElement[] map, final String name)

Find a map element given its name in a sorted array of map elements.

private static int
findIgnoreCase(Mapper.MapElement[] map, CharChunk name)

Find a map element given its name in a sorted array of map elements.

private static int
findIgnoreCase(Mapper.MapElement[] map, CharChunk name, int start, int end)

Find a map elemnt given its name in a sorted array of map elements.

private static int
findIgnoreCase(final Mapper.MapElement[] map, final String name)

Find a map elemnt given its name in a sorted array of map elements.

public String[]

Returns:

The context names
getContextNames
()

Return all contexts, in //HOST/PATH form

public String
getDefaultHostName()

Returns: Default host name

public String[]
public int
getPort()

Returns: the port this instance is used for mapping.

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

public String
private static Mapper.MapElement

Returns:

old MapElement with matching name (this is an indication that newElement has not been inserted), or null if oldMap did not contain any MapElement with matching name (this is an indication that newElement has been inserted)
insertMap
(Mapper.MapElement[] oldMap, Mapper.MapElement[] newMap, Mapper.MapElement newElement)

Insert into the right place in a sorted MapElement array, preventing duplicates.

private static Mapper.MapElement

Returns:

old MapElement with matching name (this is an indication that newElement has not been inserted), or null if oldMap did not contain any MapElement with matching name (this is an indication that newElement has been inserted)
insertMapIgnoreCase
(Mapper.MapElement[] oldMap, Mapper.MapElement[] newMap, Mapper.MapElement newElement)

Inserts the given MapElement at the appropriate place in the given, lexicograhically sorted, MapElement array, avoiding duplicates.

private void
internalMap(CharChunk host, CharChunk uri, MappingData mappingData)

Map the specified URI.

private void
internalMapExactWrapper(Mapper.Wrapper[] wrappers, CharChunk path, MappingData mappingData)

Exact mapping.

private void
internalMapExtensionWrapper(Mapper.Wrapper[] wrappers, CharChunk path, MappingData mappingData)

Extension mappings.

private void
internalMapWildcardWrapper(Mapper.Wrapper[] wrappers, int nesting, CharChunk path, MappingData mappingData)

Wildcard mapping.

private void
internalMapWrapper(Mapper.Context context, CharChunk path, MappingData mappingData)

Wrapper mapping.

private static int
lastSlash(CharChunk name)

Find the position of the last slash in the given char chunk.

public void
map(final DataChunk
Virtual host name
host
,
final DataChunk
URI
uri
,
final MappingData
This structure will contain the result of the mapping operation
mappingData
)

Map the specified host name and URI, mutating the given mapping data.

public void
map(final HttpRequestPacket
the http request containing host name information used by the mapping process.
requestPacket
,
final DataChunk
URI
uri
,
final MappingData
This structure will contain the result of the mapping operation
mappingData
)

Map the specified host name and URI, mutating the given mapping data.

public void
map(MessageBytes
URI
uri
,
MappingData
This structure will contain the result of the mapping operation
mappingData
)

Map the specified URI relative to the context, mutating the given mapping data.

public void
mapUriWithSemicolon(final HttpRequestPacket
the request packet containing the host information to be used by the mapping process.
requestPacket
,
final DataChunk
decoded URI
decodedURI
,
final MappingData
MappingData based on the URI.
mappingData
,
int
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.
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.

public void
mapUriWithSemicolon(final DataChunk
the server name as described by the Host header.
serverName
,
final DataChunk
decoded URI
decodedURI
,
final MappingData
MappingData based on the URI.
mappingData
,
int
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.
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.

private static int
nthSlash(CharChunk name, int n)

Find the position of the nth slash, in the given char chunk.

public void
removeContext(String
Virtual host name this context belongs to
hostName
,
String
Context path
path
)

Remove a context from an existing host.

public synchronized void
removeHost(String
Virtual host name
name
)

Remove a host from the mapper.

private static boolean
removeMap(Mapper.MapElement[] oldMap, Mapper.MapElement[] newMap, String name)

Removes from a sorted MapElement array.

private static boolean
removeMapIgnoreCase(Mapper.MapElement[] oldMap, Mapper.MapElement[] newMap, String name)

Removes the MapElement with the given name from the given, lexicographically sorted, MapElement array.

public void
removeWrapper(String
Wrapper mapping
path
)

Remove a wrapper from the context associated with this wrapper.

public void
removeWrapper(String
Virtual host name this wrapper belongs to
hostName
,
String
Context path this wrapper belongs to
contextPath
,
String
Wrapper mapping
path
)

Remove a wrapper from an existing context.

protected void
public static void
setAllowReplacement(boolean ar)

Allow replacement of already added Host, Context and Wrapper when invoking addHost, addContext etc. Default is false

public void
setContext(String path, String[]
Welcome files defined for this context
welcomeResources
,
NamingContext
Static resources of the context
resources
)

Set context, used for wrapper mapping (request dispatcher).

public void
setDefaultContextPath(String hostName, String defaultContextPath)

Configures the given virtual server with the given default context path.

public void
setDefaultHostName(String
Default host name
defaultHostName
)

Set default host.

public void
setPort(int port)

The Port this instance is used for mapping.

private static int
slashCount(String name)

Return the slash count in a given string.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait