com.interface21.web.servlet.mvc.multiaction
Class PropertiesMethodNameResolver

java.lang.Object
  |
  +--com.interface21.web.servlet.mvc.multiaction.PropertiesMethodNameResolver
All Implemented Interfaces:
InitializingBean, MethodNameResolver

public class PropertiesMethodNameResolver
extends java.lang.Object
implements MethodNameResolver, InitializingBean

The most sophisticated and useful framework implementation of the MethodNameResolver interface. Uses java.util.Properties defining the mapping between the URL of incoming requests and 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.

Author:
Rod Johnson

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
PropertiesMethodNameResolver()
          Create a new PropertiesMethodNameResolver.
PropertiesMethodNameResolver(java.util.Properties mappings)
          Create a new PropertiesMethodNameResolver, fully configuring this class by passing in properties.
 
Method Summary
 void afterPropertiesSet()
          Invoked by a BeanFactory after it has set all bean properties supplied.
 java.lang.String getHandlerMethodName(javax.servlet.http.HttpServletRequest request)
          Return a method name that can handle this request.
 void setAlwaysUseFullPath(boolean alwaysUseFullPath)
          Set if URL lookup should always use full path within current servlet context.
 void setMappings(java.util.Properties mappings)
          Set the mapping properties configuring this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

PropertiesMethodNameResolver

public PropertiesMethodNameResolver()
Create a new PropertiesMethodNameResolver. The mappings property must be set before use.

PropertiesMethodNameResolver

public PropertiesMethodNameResolver(java.util.Properties mappings)
Create a new PropertiesMethodNameResolver, fully configuring this class by passing in properties.
Parameters:
mappings - property mapping
Method Detail

setAlwaysUseFullPath

public void setAlwaysUseFullPath(boolean alwaysUseFullPath)
Set if URL lookup should always use full path within current servlet context. Else, the path within the current servlet mapping is used if applicable (i.e. in the case of a ".../*" servlet mapping in web.xml). Default is false.

setMappings

public void setMappings(java.util.Properties mappings)
Set the mapping properties configuring this class.

afterPropertiesSet

public void afterPropertiesSet()
Description copied from interface: InitializingBean
Invoked by a BeanFactory after it has set all bean properties supplied.
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
Following copied from interface: com.interface21.beans.factory.InitializingBean
Throws:
java.lang.Exception - in the event of misconfiguration (such as failure to set an essential property) or if initialization fails.

getHandlerMethodName

public java.lang.String getHandlerMethodName(javax.servlet.http.HttpServletRequest request)
                                      throws NoSuchRequestHandlingMethodException
Description copied from interface: MethodNameResolver
Return a method name that can handle this request. Such mappings are typically, but not necessarily, based on URL.
Specified by:
getHandlerMethodName in interface MethodNameResolver
Following copied from interface: com.interface21.web.servlet.mvc.multiaction.MethodNameResolver
Returns:
a method name that can handle this request. Never returns null; throws exception
Throws:
NoSuchRequestHandlingMethodException - if no method can be found for this URL


Rod Johnson and Spring contributors 2001-2003.