The Spring Framework

org.springframework.web.servlet.mvc.multiaction
Class PropertiesMethodNameResolver

java.lang.Object
  extended by org.springframework.web.servlet.mvc.multiaction.AbstractUrlMethodNameResolver
      extended by org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver
All Implemented Interfaces:
InitializingBean, MethodNameResolver

public class PropertiesMethodNameResolver
extends AbstractUrlMethodNameResolver
implements InitializingBean

The most flexible out-of-the-box implementation of the MethodNameResolver interface. Uses java.util.Properties to define the mapping between the URL of incoming requests and the corresponding method name. Such properties can be held in an XML document.

Properties format is /welcome.html=displayGenresPage Note that method overloading isn't allowed, so there's no need to specify arguments.

Supports direct matches, e.g. a registered "/test" matches "/test", and a various Ant-style pattern matches, e.g. a registered "/t*" matches both "/test" and "/team". For details, see the AntPathMatcher javadoc.

Author:
Rod Johnson, Juergen Hoeller
See Also:
Properties, AntPathMatcher

Field Summary
 
Fields inherited from class org.springframework.web.servlet.mvc.multiaction.AbstractUrlMethodNameResolver
logger
 
Constructor Summary
PropertiesMethodNameResolver()
           
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).
protected  String getHandlerMethodNameForUrlPath(String urlPath)
          Return a method name that can handle this request, based on the given lookup path.
 void setMappings(Properties mappings)
          Set explicit URL to method name mappings through a Properties object.
 void setPathMatcher(PathMatcher pathMatcher)
          Set the PathMatcher implementation to use for matching URL paths against registered URL patterns.
 
Methods inherited from class org.springframework.web.servlet.mvc.multiaction.AbstractUrlMethodNameResolver
getHandlerMethodName, setAlwaysUseFullPath, setUrlDecode, setUrlPathHelper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesMethodNameResolver

public PropertiesMethodNameResolver()
Method Detail

setMappings

public void setMappings(Properties mappings)
Set explicit URL to method name mappings through a Properties object.

Parameters:
mappings - Properties with URL as key and method name as value

setPathMatcher

public void setPathMatcher(PathMatcher pathMatcher)
Set the PathMatcher implementation to use for matching URL paths against registered URL patterns. Default is AntPathMatcher.

See Also:
AntPathMatcher

afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware).

This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.

Specified by:
afterPropertiesSet in interface InitializingBean

getHandlerMethodNameForUrlPath

protected String getHandlerMethodNameForUrlPath(String urlPath)
Description copied from class: AbstractUrlMethodNameResolver
Return a method name that can handle this request, based on the given lookup path. Called by getHandlerMethodName.

Specified by:
getHandlerMethodNameForUrlPath in class AbstractUrlMethodNameResolver
Parameters:
urlPath - the URL path to use for lookup, according to the settings in this class
Returns:
a method name that can handle this request. Should return null if no matching method found.
See Also:
AbstractUrlMethodNameResolver.getHandlerMethodName(javax.servlet.http.HttpServletRequest), AbstractUrlMethodNameResolver.setAlwaysUseFullPath(boolean), AbstractUrlMethodNameResolver.setUrlDecode(boolean)

The Spring Framework

Copyright © 2002-2007 The Spring Framework.