simple.http.load
Interface Mapper

All Known Implementing Classes:
PatternMapper, PrefixMapper

public interface Mapper

The Mapper is intended to provide a mapping from a URI path to a service. This enables objects to be referenced when a specific path format is used. The encoding of the path is known by the implementation so that it can parse and extract a fully qualified package name for a Java class.

The format of the path is specific to the implementation. The object is responsible for its own format, which could be, for example, a format similar to one of the following.


    /ServiceObject.class/path/index.html
    /prefix/file.html
    /path/bin/index.extension

 
The getName method is required to take a full URI path, this cannot include the URI query, domain or port of a URI. This should use a normalized path such as the path retrieved from Context.getRequestPath methods. This method will return the instance name for the service. The getClass method is required to take the service instance name and produce the fully qualified class name for the service that is to be loaded.

Author:
Niall Gallagher
See Also:
MapperEngine

Method Summary
 java.lang.String getClass(java.lang.String name)
          This method is used to acquire 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 determine the normalized path of the issued URI path.
 

Method Detail

getPath

java.lang.String getPath(java.lang.String path)
This method is used to determine the normalized path of the issued URI path. Encoding a class name into the request path means that the path will have to be modified in some way. To ensure that the modified paths can be used to reference local resources this method can be used to extract the normalized path from the URI path.

Parameters:
path - this is the path that is to be converted
Returns:
returns the normalized resolved URI path part

getName

java.lang.String getName(java.lang.String path)
This method is used to transform a path to a service name. If the path cannot be converted to a service name then a null is returned. The returned service name can then be used to acquire the class name of the service object.

Parameters:
path - this is the path that is to be converted
Returns:
name of the service instance mapped to the path

getConfiguration

Configuration getConfiguration(java.lang.String name)
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 should be an empty map rather than a null object.

Parameters:
name - this is the name of the service instance
Returns:
returns a properties object for configuration

getClass

java.lang.String getClass(java.lang.String name)
This method is used to acquire the fully qualified class name from the service instance name. This method is used only when the service instance cannot be previously loaded and therfore needs to be instantiated using the fully qualified class name for the service object.

Parameters:
name - this is the name of the service instance
Returns:
a fully qualified class name, null otherwise