Spring Framework

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<javax.portlet.PortletMode>
              extended by org.springframework.web.portlet.handler.PortletModeHandlerMapping
All Implemented Interfaces:
Aware, ApplicationContextAware, Ordered, HandlerMapping

public class PortletModeHandlerMapping
extends AbstractMapBasedHandlerMapping<javax.portlet.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  javax.portlet.PortletMode getLookupKey(javax.portlet.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(java.util.Map<java.lang.String,java.lang.Object> portletModeMap)
          Register all handlers specified in the Portlet mode map for the corresponding modes.
 void setMappings(java.util.Properties mappings)
          Set PortletMode to handler bean name mappings from a Properties object.
 void setPortletModeMap(java.util.Map<java.lang.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(java.util.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(java.util.Map<java.lang.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(java.util.Map<java.lang.String,java.lang.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 javax.portlet.PortletMode getLookupKey(javax.portlet.PortletRequest request)
                                          throws java.lang.Exception
Uses the current PortletMode as lookup key.

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

Spring Framework