public abstract class AbstractMapBasedHandlerMapping<K> extends AbstractHandlerMapping
HandlerMapping
implementations that rely on a map which caches handler objects per lookup key.
Supports arbitrary lookup keys, and automatically resolves handler bean names
into handler bean instances.#getLookupKey(javax.portlet.PortletRequest)
,
registerHandler(Object, Object)
Modifier and Type | Class and Description |
---|---|
protected static interface |
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate
Predicate interface for determining a match with a given request.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<K,java.lang.Object> |
handlerMap |
private boolean |
lazyInitHandlers |
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
AbstractMapBasedHandlerMapping() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Object |
getHandlerInternal(PortletRequest request)
Determines a handler for the computed lookup key for the given request.
|
protected abstract K |
getLookupKey(PortletRequest request)
Build a lookup key for the given request.
|
protected void |
registerHandler(K lookupKey,
java.lang.Object handler)
Register the given handler instance for the given parameter value.
|
protected void |
registerHandler(K lookupKey,
java.lang.Object handler,
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate predicate)
Register the given handler instance for the given parameter value.
|
protected void |
registerHandlers(java.util.Map<K,?> handlerMap)
Register all handlers specified in the Portlet mode map for the corresponding modes.
|
void |
setLazyInitHandlers(boolean lazyInitHandlers)
Set whether to lazily initialize handlers.
|
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initApplicationContext, initInterceptors, setApplyWebRequestInterceptorsToRenderPhaseOnly, setDefaultHandler, setInterceptors, setOrder
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
private boolean lazyInitHandlers
private final java.util.Map<K,java.lang.Object> handlerMap
public void setLazyInitHandlers(boolean lazyInitHandlers)
If you want to allow your handlers to be lazily initialized, make them "lazy-init" and set this flag to true. Just making them "lazy-init" will not work, as they are initialized through the references from the handler mapping in this case.
protected java.lang.Object getHandlerInternal(PortletRequest request) throws java.lang.Exception
getHandlerInternal
in class AbstractHandlerMapping
request
- current portlet requestnull
if none foundjava.lang.Exception
- if there is an internal errorgetLookupKey(PortletRequest)
protected abstract K getLookupKey(PortletRequest request) throws java.lang.Exception
request
- current portlet requestnull
)java.lang.Exception
- if key computation failedprotected void registerHandlers(java.util.Map<K,?> handlerMap) throws BeansException
handlerMap
- Map with lookup keys as keys and handler beans or bean names as valuesBeansException
- if the handler couldn't be registeredprotected void registerHandler(K lookupKey, java.lang.Object handler) throws BeansException, java.lang.IllegalStateException
lookupKey
- the key to map the handler ontohandler
- the handler instance or handler bean name String
(a bean name will automatically be resolved into the corresponding handler bean)BeansException
- if the handler couldn't be registeredjava.lang.IllegalStateException
- if there is a conflicting handler registeredprotected void registerHandler(K lookupKey, java.lang.Object handler, AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate predicate) throws BeansException, java.lang.IllegalStateException
lookupKey
- the key to map the handler ontohandler
- the handler instance or handler bean name String
(a bean name will automatically be resolved into the corresponding handler bean)predicate
- a predicate object for this handler (may be null
),
determining a match with the primary lookup keyBeansException
- if the handler couldn't be registeredjava.lang.IllegalStateException
- if there is a conflicting handler registered