org.springframework.web.portlet.handler
Class PortletModeHandlerMapping

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.portlet.handler.AbstractHandlerMapping
          extended by org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping<PortletMode>
              extended by org.springframework.web.portlet.handler.PortletModeHandlerMapping
All Implemented Interfaces:
Aware, ApplicationContextAware, Ordered, HandlerMapping

public class PortletModeHandlerMapping
extends AbstractMapBasedHandlerMapping<PortletMode>

Implementation of the HandlerMapping interface to map from the current PortletMode to request handler beans.

The bean configuration for this mapping will look something like this:

        <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping">
                <property name="portletModeMap">
                        <map>
                                <entry key="view"><ref bean="viewHandler"/></entry>
                                <entry key="edit"><ref bean="editHandler"/></entry>
                                <entry key="help"><ref bean="helpHandler"/></entry>
                        </map>
                </property>
        </bean>
 

Since:
2.0
Author:
William G. Thompson, Jr., John A. Lewis

Nested Class Summary
 
Nested classes/interfaces inherited from class org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate
 
Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
PortletModeHandlerMapping()
           
 
Method Summary
protected  PortletMode getLookupKey(PortletRequest request)
          Uses the current PortletMode as lookup key.
 void initApplicationContext()
          Calls the registerHandlers method in addition to the superclass's initialization.
protected  void registerHandlersByMode(Map<String,Object> portletModeMap)
          Register all handlers specified in the Portlet mode map for the corresponding modes.
 void setMappings(Properties mappings)
          Set PortletMode to handler bean name mappings from a Properties object.
 void setPortletModeMap(Map<String,?> portletModeMap)
          Set a Map with PortletModes as keys and handler beans as values.
 
Methods inherited from class org.springframework.web.portlet.handler.AbstractMapBasedHandlerMapping
getHandlerInternal, registerHandler, registerHandler, registerHandlers, setLazyInitHandlers
 
Methods inherited from class org.springframework.web.portlet.handler.AbstractHandlerMapping
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initInterceptors, setApplyWebRequestInterceptorsToRenderPhaseOnly, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PortletModeHandlerMapping

public PortletModeHandlerMapping()
Method Detail

setMappings

public void setMappings(Properties mappings)
Set PortletMode to handler bean name mappings from a Properties object.

Parameters:
mappings - properties with PortletMode names as keys and bean names as values

setPortletModeMap

public void setPortletModeMap(Map<String,?> portletModeMap)
Set a Map with PortletModes as keys and handler beans as values. Convenient for population with bean references.

Parameters:
portletModeMap - map with PortletMode names as keys and beans or bean names as values

initApplicationContext

public void initApplicationContext()
                            throws BeansException
Calls the registerHandlers method in addition to the superclass's initialization.

Overrides:
initApplicationContext in class AbstractHandlerMapping
Throws:
ApplicationContextException - in case of initialization errors
BeansException - if thrown by ApplicationContext methods
See Also:
AbstractMapBasedHandlerMapping.registerHandlers(java.util.Map)

registerHandlersByMode

protected void registerHandlersByMode(Map<String,Object> portletModeMap)
Register all handlers specified in the Portlet mode map for the corresponding modes.

Parameters:
portletModeMap - Map with mode names as keys and handler beans or bean names as values

getLookupKey

protected PortletMode getLookupKey(PortletRequest request)
                            throws Exception
Uses the current PortletMode as lookup key.

Specified by:
getLookupKey in class AbstractMapBasedHandlerMapping<PortletMode>
Parameters:
request - current portlet request
Returns:
the lookup key (never null)
Throws:
Exception - if key computation failed