public class UrlBindingFactory extends Object
Provides access to UrlBinding objects. Bindings are used in two contexts:
UrlBinding,
UrlBindingParameter| Constructor and Description |
|---|
UrlBindingFactory() |
| Modifier and Type | Method and Description |
|---|---|
void |
addBinding(Class<? extends ActionBean> beanType,
UrlBinding binding)
Map an
ActionBean to a URL. |
protected void |
cachePath(String path,
UrlBinding binding)
Map a path directly to a binding.
|
protected void |
cachePrefix(String prefix,
UrlBinding binding)
Add a binding to the set of bindings associated with a prefix.
|
Collection<Class<? extends ActionBean>> |
getActionBeanClasses()
Get all the classes implementing
ActionBean |
UrlBinding |
getBinding(HttpServletRequest request)
Examines a servlet request and returns the associated binding, if any.
|
UrlBinding |
getBinding(String uri)
Examines a URI (as returned by
HttpUtil.getRequestedPath(HttpServletRequest)) and
returns the associated binding, if any. |
UrlBinding |
getBindingPrototype(Class<? extends ActionBean> type)
Get the
UrlBinding prototype associated with the given ActionBean type. |
UrlBinding |
getBindingPrototype(HttpServletRequest request)
Examines a servlet request and returns the associated binding prototype, if any.
|
UrlBinding |
getBindingPrototype(String uri)
Examines a URI (as returned by
HttpUtil.getRequestedPath(HttpServletRequest)) and
returns the associated binding prototype, if any. |
protected Set<String> |
getCachedPaths(UrlBinding binding)
Get a list of the request paths that will be wired directly to an ActionBean.
|
protected Set<String> |
getCachedPrefixes(UrlBinding binding)
Get a list of the request path prefixes that could map to an ActionBean.
|
HashMap<String,Class<? extends ActionBean>> |
getPathMap()
Get all the
ActionBeans classes that have been found. |
static UrlBinding |
parseUrlBinding(Class<? extends ActionBean> beanType)
Look for a binding pattern for the given
ActionBean class, specified by the
UrlBinding annotation. |
static UrlBinding |
parseUrlBinding(Class<? extends ActionBean> beanType,
String pattern)
Parse the binding pattern and create a
UrlBinding object for the ActionBean
class. |
static UrlBindingParameter |
parseUrlBindingParameter(Class<? extends ActionBean> beanClass,
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(Class<? extends ActionBean> beanType)
Removes an
ActionBean's URL binding. |
String |
toString() |
protected String |
trimContextPath(HttpServletRequest request)
Deprecated.
Use
HttpUtil.getRequestedPath(HttpServletRequest) instead. |
public Collection<Class<? extends ActionBean>> getActionBeanClasses()
ActionBeanpublic UrlBinding getBindingPrototype(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 ActionBeanpublic UrlBinding getBindingPrototype(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(HttpServletRequest request)
request - a servlet requestpublic UrlBinding getBinding(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(HttpServletRequest request)
UrlBindingParameter objects returned by
UrlBinding.getParameters() will contain the values that are present in the request.request - a servlet requestpublic HashMap<String,Class<? extends ActionBean>> getPathMap()
ActionBeans classes that have been found.ActionBean classespublic void addBinding(Class<? extends ActionBean> beanType, UrlBinding binding)
ActionBean to a URL.beanType - the ActionBean classbinding - the URL bindingpublic void removeBinding(Class<? extends ActionBean> beanType)
ActionBean's URL binding.beanType - the ActionBean classprotected Set<String> getCachedPaths(UrlBinding binding)
protected Set<String> getCachedPrefixes(UrlBinding binding)
protected void cachePath(String path, UrlBinding binding)
path - The path to cachebinding - The binding to which the path should mapprotected void cachePrefix(String prefix, UrlBinding binding)
prefix - The prefix to cachebinding - The binding to map to the prefixpublic static UrlBinding parseUrlBinding(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(Class<? extends ActionBean> beanType, String pattern)
UrlBinding object for the ActionBean
class. If pattern is null, 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 nullParseException - If the pattern cannot be parsedpublic static UrlBindingParameter parseUrlBindingParameter(Class<? extends ActionBean> beanClass, 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 String trimContextPath(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 request© Copyright 2005-2006, Stripes Development Team.