org.riotfamily.common.web.mapping
Class AbstractReverseHandlerMapping

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.handler.AbstractHandlerMapping
              extended by org.riotfamily.common.web.mapping.AbstractReverseHandlerMapping
All Implemented Interfaces:
ReverseHandlerMapping, ApplicationContextAware, Ordered, ServletContextAware, HandlerMapping
Direct Known Subclasses:
AdvancedBeanNameHandlerMapping, PageHandlerMapping

public abstract class AbstractReverseHandlerMapping
extends AbstractHandlerMapping
implements ReverseHandlerMapping

Abstract base class for mappings that support reverse look-ups.

Since:
6.5
Author:
Felix Gnass [fgnass at neteye dot de]

Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.riotfamily.common.web.mapping.ReverseHandlerMapping
TOP_LEVEL_HANDLER_NAME_ATTRIBUTE
 
Fields inherited from interface org.springframework.web.servlet.HandlerMapping
PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
AbstractReverseHandlerMapping()
           
 
Method Summary
protected  String addServletMappingIfNecessary(String path, UrlResolverContext context)
           
protected  void exposeHandlerName(String beanName, HttpServletRequest request)
          Exposes the name of the matched handler as request attribute, unless the attribute is already present.
protected  Map<String,?> getDefaults(UrlResolverContext context)
          Returns a Map of default values that are used to build URLs.
protected  AttributePattern getPatternForHandler(String handlerName, String prefix, UrlResolverContext context)
          Returns the pattern for the handler with the given name.
protected  AttributePattern getPatternForHandler(String handlerName, String prefix, UrlResolverContext context, Map<String,Object> attributes, Map<String,?> defaults, int anonymousWildcards)
          Returns the pattern for the handler with the given name that contains all the given wildcards.
protected  List<AttributePattern> getPatternsForHandler(String handlerName, String prefix, UrlResolverContext context)
          Returns all patterns for the handler with the specified name that start with the given prefix.
protected abstract  List<AttributePattern> getPatternsForHandler(String beanName, UrlResolverContext context)
          Subclasses must implement this method and return all patterns for the handler with the specified name.
protected  String getUrlForHandler(String handlerName, String prefix, Object attributes, Map<String,?> defaults, UrlResolverContext context)
          Returns the URL of a mapped handler.
 String getUrlForHandler(String handlerName, String prefix, Object attributes, UrlResolverContext context)
          Returns the URL of a mapped handler.
static Map<String,Object> getWildcardAttributes(HttpServletRequest request)
           
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getHandlerInternal, getOrder, initApplicationContext, initInterceptors, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractReverseHandlerMapping

public AbstractReverseHandlerMapping()
Method Detail

getUrlForHandler

public String getUrlForHandler(String handlerName,
                               String prefix,
                               Object attributes,
                               UrlResolverContext context)
Returns the URL of a mapped handler.

Specified by:
getUrlForHandler in interface ReverseHandlerMapping
Parameters:
handlerName - The name of the handler
prefix - Optional prefix to sort out ambiguities
attributes - Optional attributes to fill out wildcards. Can either be null, a primitive wrapper, a Map or a bean.
request - The current request

getDefaults

protected Map<String,?> getDefaults(UrlResolverContext context)
Returns a Map of default values that are used to build URLs. The default implementation return null.


getUrlForHandler

protected String getUrlForHandler(String handlerName,
                                  String prefix,
                                  Object attributes,
                                  Map<String,?> defaults,
                                  UrlResolverContext context)
Returns the URL of a mapped handler.

Parameters:
handlerName - The name of the handler
prefix - Optional prefix to sort out ambiguities
attributes - Optional attributes to fill out wildcards. Can either be null, a primitive wrapper, a Map or a bean.
defaults - Optional Map of default values that are used when no attribute value was provided for a certain wildcard.
request - The current request

getPatternsForHandler

protected List<AttributePattern> getPatternsForHandler(String handlerName,
                                                       String prefix,
                                                       UrlResolverContext context)
Returns all patterns for the handler with the specified name that start with the given prefix.

Parameters:
handlerName - Name of the handler
prefix - Optional prefix to narrow the the result
request - The current request

getPatternsForHandler

protected abstract List<AttributePattern> getPatternsForHandler(String beanName,
                                                                UrlResolverContext context)
Subclasses must implement this method and return all patterns for the handler with the specified name.


addServletMappingIfNecessary

protected String addServletMappingIfNecessary(String path,
                                              UrlResolverContext context)

getPatternForHandler

protected AttributePattern getPatternForHandler(String handlerName,
                                                String prefix,
                                                UrlResolverContext context,
                                                Map<String,Object> attributes,
                                                Map<String,?> defaults,
                                                int anonymousWildcards)
Returns the pattern for the handler with the given name that contains all the given wildcards.

Throws:
IllegalArgumentException - if more than one mapping is registered

getPatternForHandler

protected AttributePattern getPatternForHandler(String handlerName,
                                                String prefix,
                                                UrlResolverContext context)
Returns the pattern for the handler with the given name.

Throws:
IllegalArgumentException - if more than one mapping is registered

exposeHandlerName

protected void exposeHandlerName(String beanName,
                                 HttpServletRequest request)
Exposes the name of the matched handler as request attribute, unless the attribute is already present.

See Also:
ReverseHandlerMapping.TOP_LEVEL_HANDLER_NAME_ATTRIBUTE

getWildcardAttributes

public static Map<String,Object> getWildcardAttributes(HttpServletRequest request)