public class UrlBindingFactory
extends java.lang.Object
Provides access to UrlBinding
objects. Bindings are used in two contexts:
UrlBinding
,
UrlBindingParameter
Modifier | Constructor and Description |
---|---|
protected |
UrlBindingFactory()
Don't want the constructor to be public
|
Modifier and Type | Method and Description |
---|---|
void |
addBinding(java.lang.Class<? extends ActionBean> beanType,
UrlBinding binding)
Map an
ActionBean to a URL. |
protected void |
cachePath(java.lang.String path,
UrlBinding binding)
Map a path directly to a binding.
|
protected void |
cachePrefix(java.lang.String prefix,
UrlBinding binding)
Add a binding to the set of bindings associated with a prefix.
|
java.util.Collection<java.lang.Class<? extends ActionBean>> |
getActionBeanClasses()
Get all the classes implementing
ActionBean |
UrlBinding |
getBinding(javax.servlet.http.HttpServletRequest request)
Examines a servlet request and returns the associated binding, if any.
|
UrlBinding |
getBinding(java.lang.String uri)
Examines a URI (as returned by
HttpUtil.getRequestedPath(HttpServletRequest) ) and
returns the associated binding, if any. |
UrlBinding |
getBindingPrototype(java.lang.Class<? extends ActionBean> type)
Get the
UrlBinding prototype associated with the given ActionBean type. |
UrlBinding |
getBindingPrototype(javax.servlet.http.HttpServletRequest request)
Examines a servlet request and returns the associated binding prototype, if any.
|
UrlBinding |
getBindingPrototype(java.lang.String uri)
Examines a URI (as returned by
HttpUtil.getRequestedPath(HttpServletRequest) ) and
returns the associated binding prototype, if any. |
protected java.util.Set<java.lang.String> |
getCachedPaths(UrlBinding binding)
Get a list of the request paths that will be wired directly to an ActionBean.
|
protected java.util.Set<java.lang.String> |
getCachedPrefixes(UrlBinding binding)
Get a list of the request path prefixes that could map to an ActionBean.
|
static UrlBindingFactory |
getInstance()
Get the singleton instance.
|
java.util.HashMap<java.lang.String,java.lang.Class<? extends ActionBean>> |
getPathMap()
Get all the
ActionBean s classes that have been found. |
static UrlBinding |
parseUrlBinding(java.lang.Class<? extends ActionBean> beanType)
Look for a binding pattern for the given
ActionBean class, specified by the
UrlBinding annotation. |
static UrlBinding |
parseUrlBinding(java.lang.Class<? extends ActionBean> beanType,
java.lang.String pattern)
Parse the binding pattern and create a
UrlBinding object for the ActionBean
class. |
static UrlBindingParameter |
parseUrlBindingParameter(java.lang.Class<? extends ActionBean> beanClass,
java.lang.String string)
Parses a parameter specification into name and default value and returns a
UrlBindingParameter with the corresponding name and default value properties set
accordingly. |
void |
removeBinding(java.lang.Class<? extends ActionBean> beanType)
Removes an
ActionBean 's URL binding. |
java.lang.String |
toString() |
protected java.lang.String |
trimContextPath(javax.servlet.http.HttpServletRequest request)
Deprecated.
Use
HttpUtil.getRequestedPath(HttpServletRequest) instead. |
protected UrlBindingFactory()
public static UrlBindingFactory getInstance()
public java.util.Collection<java.lang.Class<? extends ActionBean>> getActionBeanClasses()
ActionBean
public UrlBinding getBindingPrototype(java.lang.Class<? extends ActionBean> type)
UrlBinding
prototype associated with the given ActionBean
type. This
method may return null if no binding is associated with the given type.type
- a class that implements ActionBean
public UrlBinding getBindingPrototype(java.lang.String uri)
HttpUtil.getRequestedPath(HttpServletRequest)
) and
returns the associated binding prototype, if any. No attempt is made to extract parameter
values from the URI. This is intended as a fast means to get static information associated
with a given request URI.uri
- a request URIpublic UrlBinding getBindingPrototype(javax.servlet.http.HttpServletRequest request)
request
- a servlet requestpublic UrlBinding getBinding(java.lang.String uri)
HttpUtil.getRequestedPath(HttpServletRequest)
) and
returns the associated binding, if any. Parameters will be extracted from the URI, and the
UrlBindingParameter
objects returned by UrlBinding.getParameters()
will
contain the values that are present in the URI.uri
- a request URIpublic UrlBinding getBinding(javax.servlet.http.HttpServletRequest request)
UrlBindingParameter
objects returned by
UrlBinding.getParameters()
will contain the values that are present in the request.request
- a servlet requestpublic java.util.HashMap<java.lang.String,java.lang.Class<? extends ActionBean>> getPathMap()
ActionBean
s classes that have been found.ActionBean
classespublic void addBinding(java.lang.Class<? extends ActionBean> beanType, UrlBinding binding)
ActionBean
to a URL.beanType
- the ActionBean
classbinding
- the URL bindingpublic void removeBinding(java.lang.Class<? extends ActionBean> beanType)
ActionBean
's URL binding.beanType
- the ActionBean
classprotected java.util.Set<java.lang.String> getCachedPaths(UrlBinding binding)
protected java.util.Set<java.lang.String> getCachedPrefixes(UrlBinding binding)
protected void cachePath(java.lang.String path, UrlBinding binding)
path
- The path to cachebinding
- The binding to which the path should mapprotected void cachePrefix(java.lang.String prefix, UrlBinding binding)
prefix
- The prefix to cachebinding
- The binding to map to the prefixpublic static UrlBinding parseUrlBinding(java.lang.Class<? extends ActionBean> beanType)
ActionBean
class, specified by the
UrlBinding
annotation. If the annotation is found,
create and return a UrlBinding
object for the class. Otherwise, return null.beanType
- The ActionBean
type whose binding is to be parsedUrlBinding
if one is specified, or null if not.ParseException
- If the pattern cannot be parsedpublic static UrlBinding parseUrlBinding(java.lang.Class<? extends ActionBean> beanType, java.lang.String pattern)
UrlBinding
object for the ActionBean
class. If pattern is null or zero-length, then return null.beanType
- The ActionBean
type to be mapped to the pattern.pattern
- The URL binding pattern to parse.UrlBinding
or null if the pattern is null or zero-lengthParseException
- If the pattern cannot be parsedpublic static UrlBindingParameter parseUrlBindingParameter(java.lang.Class<? extends ActionBean> beanClass, java.lang.String string)
UrlBindingParameter
with the corresponding name and default value properties set
accordingly.beanClass
- the bean class to which the binding appliesstring
- the parameter stringParseException
- if the pattern cannot be parsed@Deprecated protected java.lang.String trimContextPath(javax.servlet.http.HttpServletRequest request)
HttpUtil.getRequestedPath(HttpServletRequest)
instead.request
with the context path trimmed from the
beginning. I.e., the request URI relative to the context.request
- a servlet requestpublic java.lang.String toString()
toString
in class java.lang.Object
? Copyright 2005-2006, Stripes Development Team.