| |
|
| java.lang.Object simple.util.xml.Traverser simple.http.load.PrefixResolver
PrefixResolver | public class PrefixResolver extends Traverser (Code) | | The PrefixResolver is used to extract service names
and types from an XML configuration file. Each service name can
be associated with match and prepare XML elements, which can be
used to determine the URI targets used to locate the services
and the properties that are be used to initialize the service.
This is used to implement a scheme similar to the Java Servlet
context path mapping scheme. In this scheme a prefix path is
used to resolve a Servlet, and the remaining path part is then
used to acquire a resource relative the the Servlet context.
author: Niall Gallagher |
Method Summary | |
protected void | commit(Node node) This is used to commit any data that has been collected during
the processing of an element node. | protected void | finish() Used to prepare the prefix paths so that they can be matched
with relative URI paths quickly. | public String | getClass(String name) Used to resolve the class name using a service name. | public Configuration | getConfiguration(String name) This method is used retrieve properties for a service by
using the service name. | public String | getName(String prefix) Used to resolve the service name using a path prefix. | public String | getPath(String normal) Used to acquire the path relative to the prefix. | public String | getPrefix(String normal) Used to get the prefix path for the given relative URI path,
which must be normalized. | protected void | process(Node node) This is used to process a element node extracted from the XML
document. | protected void | start() This method is used to initialize this resolver. |
PrefixResolver | public PrefixResolver(Locator lookup)(Code) | | Constructor for the PrefixResolver . This uses
a configuration file located with the Locator
object supplied. Once the configuration file is located the
service names can be resolved for arbitrary URI paths.
Parameters: lookup - the locator used to find the configuration |
PrefixResolver | public PrefixResolver(Locator lookup, int max)(Code) | | Constructor for the PrefixResolver . This uses
a configuration file located with the Locator
object supplied. Once the configuration file is located the
service names can be resolved for arbitrary URI paths.
This includes a parameter that enables a maximum expected
path length to be entered. This helps to optimize the
resolution of a path prefix. This should typically be at
least big enough to include the maximum possible path.
Parameters: lookup - the object used to perform configuration Parameters: max - this is the maximum path length expected |
commit | protected void commit(Node node)(Code) | | This is used to commit any data that has been collected during
the processing of an element node. The elements of interest to
this method are the "service" and "property" elements. This
will save the properties collected for each "service" element.
Parameters: node - this is the node to be committed by this method |
finish | protected void finish()(Code) | | Used to prepare the prefix paths so that they can be matched
with relative URI paths quickly. The XML configuration file
used to specify the prefix paths with the service and class
names will be loaded unordered into a HashMap .
This ensures the acquired keys are sorted for searching.
|
getClass | public String getClass(String name)(Code) | | Used to resolve the class name using a service name. This is
required to resolve the class name once the service name has
been acquired from the getName method. If there
is no match for the service name then null is returned.
Parameters: name - this is the service name to get a class name for the class name that matches the service name given |
getConfiguration | public Configuration getConfiguration(String name)(Code) | | This method is used retrieve properties for a service by
using the service name. This will acquire the properties
if any for the named service instance. The properties will
contain zero or more name value pairs. If no properties
are associated with the service the instance returned
will be an empty map rather than a null object.
Parameters: name - this is the name of the service instance returns a properties object for configuration |
getName | public String getName(String prefix)(Code) | | Used to resolve the service name using a path prefix. This is
required to resolve the service name once the prefix of the
path is acquired from the getPrefix method. If
there is no match for the prefix then null is returned.
Parameters: prefix - the path prefix to acquire a service name for the service name that matches the prefix path given |
getPath | public String getPath(String normal)(Code) | | Used to acquire the path relative to the prefix. This will
return the path as it is relative to the prefix resolved
for the given normalized path. This will remove the start
of the given normalized path if it matches a prefix path.
Parameters: normal - the normalized URI path to get a path for the full path once its prefix has been removed |
getPrefix | public String getPrefix(String normal)(Code) | | Used to get the prefix path for the given relative URI path,
which must be normalized. This will attempt to match the
start of the given path to the highest directory path. For
example, given the URI path /pub/bin/README ,
the start of the path will be compared for a prefix. So it
should match /pub/bin/ , /bin/ ,
and finally / in that order.
Parameters: normal - the normalized URI path to get a prefix for the highest matched directory for the given path |
process | protected void process(Node node)(Code) | | This is used to process a element node extracted from the XML
document. It will be given each element that exists within
the document. The elements of interest to this implementation
are the "property", "match", "section", and "service" elements.
Parameters: node - this is the node to be evaluated by this method |
start | protected void start()(Code) | | This method is used to initialize this resolver. This will
clear out all data structures used in the parsing process.
It is invoked before the process method is used.
to evaluate the element nodes extracted from the XML document.
|
|
|
|