|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsimple.http.load.PatternMapper
public class PatternMapper
The PatternMapper
provides a mapper that is used
to perform mapping using patterns. This provides a scheme like
the Servlet wild card mapping scheme. This Mapper
allows arbitrary path configurations to be mapped directly to
a service name, which can be autoloaded to serve content.
This uses the wild card characters '*' and '?' to specify the patterns used for URI path to service name matching. For example take the pattern "*.html", this will match any URI path that ends with ".html", such as "/index.html" or "/example.html". If the '?' character is used with '*' in the formation '*?' then the match will be all characters up to the first occurance of the following character. For instance "/*?/*.html" will match the path "/pub/index.html" but not "/pub/bin/index.html".
The specification of wild card patterns to service names is
done using the XML configuration file Mapper.xml
.
This must be used by a MapperEngine
to resolve
services to be loaded by resolving the service instance name.
<resolve> <match path="/*" name="file"/> <match path="/*?/*.txt" name="text"/> <match path="/???/*" name="three"/> </resolve>Taking the above example mappings as entries within the XML configuration file loaded, matches for all URI paths can match the pattern "/*", which signifies anything. However the matches for the "/*?/*.txt" pattern will only match URI paths that end in ".txt" and have only a single path segment, like "/path/README.txt". Any number of wild card characters can be specified and the order they appear in the configuration file is signifigant. The first pattern has the lowest priority and the last has the highest. So taking the above specification, a URI path such as "/1234/README.txt" will match the "/*?/*.txt" pattern, as it is resolved before "/*" pattern. Also "/???/*" matches an initial path segment with only three characters.
MapperEngine
,
Resolver
Constructor Summary | |
---|---|
PatternMapper(Context context)
Constructor for the PatternMapper . |
Method Summary | |
---|---|
java.lang.String |
getClass(java.lang.String name)
This method is used to retrieve the fully qualified class name from the service instance name. |
Configuration |
getConfiguration(java.lang.String name)
This method is used retrieve properties for a service by using the service name. |
java.lang.String |
getName(java.lang.String path)
This method is used to transform a path to a service name. |
java.lang.String |
getPath(java.lang.String path)
This method is used to acquire a path given the unmodified URI path. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PatternMapper(Context context)
PatternMapper
. This is used
to create a Mapper
that can be used to resolve
service instance names given an arbitrary URI path. This uses
a configuration file located using the Context
object supplied with the context. This configuration file is
used to acquire the mappings for URI path to service names.
context
- used to find the mapping configuration fileMethod Detail |
---|
public java.lang.String getPath(java.lang.String path)
*.jsp
and context
mapping such as /context/
. When these are
used together determining the getPathInfo
is
not intuitive. So this will simply return the path as is.
getPath
in interface Mapper
path
- the URI path to extract a relative path with
public java.lang.String getName(java.lang.String path)
Mapper
getName
in interface Mapper
path
- this is the path that is to be converted
public Configuration getConfiguration(java.lang.String name)
getConfiguration
in interface Mapper
name
- this is the name of the service instance
public java.lang.String getClass(java.lang.String name)
getClass
in interface Mapper
name
- this is the service instance being queried
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |