public class DefaultAnnotationHandlerMapping extends AbstractMapBasedHandlerMapping<javax.portlet.PortletMode>
HandlerMapping
interface that maps handlers based on
portlet modes expressed through the RequestMapping
annotation at the type or method level.
Registered by default in DispatcherPortlet
. NOTE: If you define
custom HandlerMapping beans in your DispatcherPortlet context, you need to add a DefaultAnnotationHandlerMapping bean
explicitly, since custom HandlerMapping beans replace the default mapping strategies. Defining a
DefaultAnnotationHandlerMapping also allows for registering custom interceptors:
<bean class="com.liferay.portletmvc4spring.mvc.annotation.DefaultAnnotationHandlerMapping"> <property name="interceptors"> ... </property> </bean>Annotated controllers are usually marked with the
Controller
stereotype at the type level. This is not
strictly necessary when RequestMapping
is applied at the type level (since such a handler usually implements
the Controller
interface). However, Controller
is required for
detecting RequestMapping
annotations at the method level.
NOTE: Method-level mappings are only allowed to narrow the mapping expressed at the class level (if any). A portlet mode in combination with specific parameter conditions needs to uniquely map onto one specific handler bean, not spread across multiple handler beans. It is strongly recommended to co-locate related handler methods into the same bean.
The AnnotationMethodHandlerAdapter
is responsible for processing annotated handler methods, as mapped by
this HandlerMapping. For RequestMapping
at the type level, specific HandlerAdapters such as SimpleControllerHandlerAdapter
apply.
RequestMapping
,
AnnotationMethodHandlerAdapter
AbstractMapBasedHandlerMapping.PortletRequestMappingPredicate
logger
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
DefaultAnnotationHandlerMapping() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
detectHandlerMethods(Class<?> handlerType,
String beanName,
RequestMapping typeMapping)
Derive portlet mode mappings from the handler's method-level mappings.
|
protected void |
detectHandlers()
Register all handlers specified in the Portlet mode map for the corresponding modes.
|
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. |
getHandlerInternal, registerHandler, registerHandler, registerHandlers, setLazyInitHandlers
adaptInterceptor, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getOrder, initInterceptors, setApplyWebRequestInterceptorsToRenderPhaseOnly, setDefaultHandler, setInterceptors, setOrder
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, obtainApplicationContext, requiredContextClass, setApplicationContext
public void initApplicationContext() throws BeansException
registerHandlers
method in addition to the superclass's initialization.initApplicationContext
in class AbstractHandlerMapping
BeansException
detectHandlers()
protected boolean detectHandlerMethods(Class<?> handlerType, String beanName, RequestMapping typeMapping)
handlerType
- the handler type to introspectbeanName
- the name of the bean introspectedtypeMapping
- the type level mapping (if any)true
if at least 1 handler method has been registered; false
otherwiseprotected void detectHandlers() throws BeansException
BeansException
- if the handler couldn't be registeredprotected javax.portlet.PortletMode getLookupKey(javax.portlet.PortletRequest request) throws Exception
getLookupKey
in class AbstractMapBasedHandlerMapping<javax.portlet.PortletMode>
request
- current portlet requestnull
)Exception
- if key computation failedCopyright © 2019 Liferay, Inc.. All rights reserved.