类 AbstractHandlerMapping
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.portlet.handler.AbstractHandlerMapping
- 所有已实现的接口:
Aware,ApplicationContextAware,Ordered,HandlerMapping
public abstract class AbstractHandlerMapping extends ApplicationObjectSupport implements HandlerMapping, Ordered
Abstract base class forHandlerMappingimplementations. Supports ordering, a default handler, and handler interceptors.- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, John A. Lewis
- 另请参阅:
getHandlerInternal(javax.portlet.PortletRequest),setDefaultHandler(java.lang.Object),setInterceptors(java.lang.Object[]),HandlerInterceptor
字段概要
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 AbstractHandlerMapping()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected HandlerInterceptoradaptInterceptor(Object interceptor)Adapt the given interceptor object to the HandlerInterceptor interface.protected voidextendInterceptors(List<?> interceptors)Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (seesetInterceptors(java.lang.Object[])).protected HandlerInterceptor[]getAdaptedInterceptors()Return the adapted interceptors as HandlerInterceptor array.ObjectgetDefaultHandler()Return the default handler for this handler mapping, ornullif none.HandlerExecutionChaingetHandler(PortletRequest request)Look up a handler for the given request, falling back to the default handler if no specific one is found.protected HandlerExecutionChaingetHandlerExecutionChain(Object handler, PortletRequest request)Build a HandlerExecutionChain for the given handler, including applicable interceptors.protected abstract ObjectgetHandlerInternal(PortletRequest request)Look up a handler for the given request, returningnullif no specific one is found.intgetOrder()Get the order value of this object.protected voidinitApplicationContext()Initializes the interceptors.protected voidinitInterceptors()Initialize the specified interceptors, adapting them where necessary.voidsetApplyWebRequestInterceptorsToRenderPhaseOnly(boolean applyWebRequestInterceptorsToRenderPhaseOnly)Specify whether to apply WebRequestInterceptors to the Portlet render phase only ("true", or whether to apply them to the Portlet action phase as well ("false").voidsetDefaultHandler(Object defaultHandler)Set the default handler for this handler mapping.voidsetInterceptors(Object[] interceptors)Set the interceptors to apply for all handlers mapped by this handler mapping.voidsetOrder(int order)Specify the order value for this HandlerMapping bean.从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, isContextRequired, requiredContextClass, setApplicationContext
构造器详细资料
AbstractHandlerMapping
public AbstractHandlerMapping()
方法详细资料
setOrder
public final void setOrder(int order)
Specify the order value for this HandlerMapping bean.Default value is
Integer.MAX_VALUE, meaning that it's non-ordered.- 另请参阅:
Ordered.getOrder()
getOrder
public final int getOrder()
从接口复制的说明:OrderedGet the order value of this object.Higher values are interpreted as lower priority. As a consequence, the object with the lowest value has the highest priority (somewhat analogous to Servlet
load-on-startupvalues).Same order values will result in arbitrary sort positions for the affected objects.
- 指定者:
getOrder在接口中Ordered- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE,Ordered.LOWEST_PRECEDENCE
setDefaultHandler
public void setDefaultHandler(Object defaultHandler)
Set the default handler for this handler mapping. This handler will be returned if no specific mapping was found.Default is
null, indicating no default handler.
getDefaultHandler
public Object getDefaultHandler()
Return the default handler for this handler mapping, ornullif none.
setInterceptors
public void setInterceptors(Object[] interceptors)
Set the interceptors to apply for all handlers mapped by this handler mapping.Supported interceptor types are HandlerInterceptor and WebRequestInterceptor. Each given WebRequestInterceptor will be wrapped in a WebRequestHandlerInterceptorAdapter.
- 参数:
interceptors- array of handler interceptors, ornullif none- 另请参阅:
adaptInterceptor(java.lang.Object),HandlerInterceptor,WebRequestInterceptor
setApplyWebRequestInterceptorsToRenderPhaseOnly
public void setApplyWebRequestInterceptorsToRenderPhaseOnly(boolean applyWebRequestInterceptorsToRenderPhaseOnly)
Specify whether to apply WebRequestInterceptors to the Portlet render phase only ("true", or whether to apply them to the Portlet action phase as well ("false").Default is "true", since WebRequestInterceptors are usually built for MVC-style handler execution plus rendering process (which is, for example, the primary target scenario for "Open Session in View" interceptors, offering lazy loading of persistent objects during view rendering). Set this to "false" to have WebRequestInterceptors apply to the action phase as well (for example, in case of an "Open Session in View" interceptor, to allow for lazy loading outside of a transaction during the action phase).
initApplicationContext
protected void initApplicationContext() throws BeansException
Initializes the interceptors.- 覆盖:
initApplicationContext在类中ApplicationObjectSupport- 抛出:
ApplicationContextException- in case of initialization errorsBeansException- if thrown by ApplicationContext methods- 另请参阅:
extendInterceptors(java.util.List),initInterceptors()
extendInterceptors
protected void extendInterceptors(List<?> interceptors)
Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (seesetInterceptors(java.lang.Object[])).Will be invoked before
initInterceptors()adapts the specified interceptors intoHandlerInterceptorinstances.The default implementation is empty.
- 参数:
interceptors- the configured interceptor List (nevernull), allowing to add further interceptors before as well as after the existing interceptors
initInterceptors
protected void initInterceptors()
Initialize the specified interceptors, adapting them where necessary.
adaptInterceptor
protected HandlerInterceptor adaptInterceptor(Object interceptor)
Adapt the given interceptor object to the HandlerInterceptor interface.Supported interceptor types are HandlerInterceptor and WebRequestInterceptor. Each given WebRequestInterceptor will be wrapped in a WebRequestHandlerInterceptorAdapter. Can be overridden in subclasses.
- 参数:
interceptor- the specified interceptor object- 返回:
- the interceptor wrapped as HandlerInterceptor
- 另请参阅:
setApplyWebRequestInterceptorsToRenderPhaseOnly(boolean),HandlerInterceptor,WebRequestInterceptor,WebRequestHandlerInterceptorAdapter
getAdaptedInterceptors
protected final HandlerInterceptor[] getAdaptedInterceptors()
Return the adapted interceptors as HandlerInterceptor array.- 返回:
- the array of HandlerInterceptors, or
nullif none
getHandler
public final HandlerExecutionChain getHandler(PortletRequest request) throws Exception
Look up a handler for the given request, falling back to the default handler if no specific one is found.- 指定者:
getHandler在接口中HandlerMapping- 参数:
request- current portlet request- 返回:
- the corresponding handler instance, or the default handler
- 抛出:
Exception- if there is an internal error- 另请参阅:
getHandlerInternal(javax.portlet.PortletRequest)
getHandlerInternal
protected abstract Object getHandlerInternal(PortletRequest request) throws Exception
Look up a handler for the given request, returningnullif no specific one is found. This method is called bygetHandler(javax.portlet.PortletRequest); anullreturn value will lead to the default handler, if one is set.Note: This method may also return a pre-built
HandlerExecutionChain, combining a handler object with dynamically determined interceptors. Statically specified interceptors will get merged into such an existing chain.- 参数:
request- current portlet request- 返回:
- the corresponding handler instance, or
nullif none found - 抛出:
Exception- if there is an internal error- 另请参阅:
getHandler(javax.portlet.PortletRequest)
getHandlerExecutionChain
protected HandlerExecutionChain getHandlerExecutionChain(Object handler, PortletRequest request)
Build a HandlerExecutionChain for the given handler, including applicable interceptors.The default implementation simply builds a standard HandlerExecutionChain with the given handler and this handler mapping's common interceptors. Subclasses may override this in order to extend/rearrange the list of interceptors.
NOTE: The passed-in handler object may be a raw handler or a pre-built HandlerExecutionChain. This method should handle those two cases explicitly, either building a new HandlerExecutionChain or extending the existing chain.
For simply adding an interceptor, consider calling
super.getHandlerExecutionChainand invokingHandlerExecutionChain.addInterceptor(org.springframework.web.portlet.HandlerInterceptor)on the returned chain object.- 参数:
handler- the resolved handler instance (nevernull)request- current portlet request- 返回:
- the HandlerExecutionChain (never
null) - 另请参阅:
getAdaptedInterceptors()