|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectTemplatedURLFormatter
public abstract class TemplatedURLFormatter
Used by URLRewriterService to apply any relevant templates to a URL, after all other rewriting has been done on the URL.
Offers a mechanism for formatting URLs based on templates from a URL template config file. A template is chosen from a reference group based on the template type (key).
This class also contains the collection of known and required tokens it expects within URL templates it handles.
In general, an implementation of this abstract class should be thread-safe,
not having state. If it is used as per-webapp default TemplatedURLFormatter
,
defined in beehive-netui-config.xml (with a class name),
URLRewriterService.getTemplatedURL()
will share the same instance (from the ServletContext - see
getTemplatedURLFormatter(javax.servlet.ServletContext)
) for multiple simultaneous requests.
Field Summary | |
---|---|
protected List |
_knownTokens
|
static String |
DEFAULT_TEMPLATE_REF
The default name for a reference group. |
static String |
DOMAIN_TOKEN
|
static String |
FRAGMENT_TOKEN
|
static String |
PATH_TOKEN
|
static String |
PORT_TOKEN
|
static String |
QUERY_STRING_TOKEN
|
protected List |
requiredTokens
|
static String |
SCHEME_TOKEN
|
Constructor Summary | |
---|---|
TemplatedURLFormatter()
|
Method Summary | |
---|---|
List |
getKnownTokens()
Returns the list of the known tokens (strings) that this URL template formatter handles. |
List |
getRequiredTokens()
Returns the list of the tokens (strings) that this URL template requires when formatting a URL with a template. |
abstract String |
getTemplatedURL(ServletContext servletContext,
ServletRequest request,
MutableURI uri,
String key,
URIContext uriContext)
Format the given URL using a URL template, if defined in a URL template config file. |
static TemplatedURLFormatter |
getTemplatedURLFormatter(ServletContext servletContext)
Gets the TemplatedURLFormatter instance attribute of the ServletContext. |
static void |
initServletContext(ServletContext servletContext,
TemplatedURLFormatter formatter)
Adds a given TemplatedURLFormatter instance as an attribute of the ServletContext. |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_TEMPLATE_REF
public static final String SCHEME_TOKEN
public static final String DOMAIN_TOKEN
public static final String PORT_TOKEN
public static final String PATH_TOKEN
public static final String QUERY_STRING_TOKEN
public static final String FRAGMENT_TOKEN
protected List _knownTokens
protected List requiredTokens
Constructor Detail |
---|
public TemplatedURLFormatter()
Method Detail |
---|
public static TemplatedURLFormatter getTemplatedURLFormatter(ServletContext servletContext)
servletContext
- the current ServletContext.
public static void initServletContext(ServletContext servletContext, TemplatedURLFormatter formatter)
servletContext
- the current ServletContext.formatter
- the TemplatedURLFormatter instance to add as an attribute of the contextpublic List getKnownTokens()
public List getRequiredTokens()
public abstract String getTemplatedURL(ServletContext servletContext, ServletRequest request, MutableURI uri, String key, URIContext uriContext)
URIContext
encapsulates some additional data needed to write out the string form.
E.g. It defines if the "&" entity or the
'&' character should be used to separate quary parameters.
servletContext
- the current ServletContext.request
- the current ServletRequest.uri
- the MutableURI to be formatted into a String.key
- key for the URL template type to use for formatting the URIuriContext
- data required to write out the string form.
String
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |