Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.portlet.handler
Class AbstractHandlerMapping

    java.lang.Object
      org.springframework.context.support.ApplicationObjectSupport
          org.springframework.web.portlet.handler.AbstractHandlerMapping

All Implemented Interfaces:
  Aware, ApplicationContextAware, Ordered, HandlerMapping

Direct Known Subclasses:
  AbstractMapBasedHandlerMapping

    public abstract class AbstractHandlerMapping

extends ApplicationObjectSupport
implements HandlerMapping, Ordered

Abstract base class for `HandlerMapping` implementations. Supports ordering, a default handler, and handler interceptors.

Since:
  2.0
Author:
  Juergen Hoeller, John A. Lewis
See Also:
  `getHandlerInternal(javax.portlet.PortletRequest)`, `setDefaultHandler(java.lang.Object)`, `setInterceptors(java.lang.Object[])`, `HandlerInterceptor`

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
`AbstractHandlerMapping()`

Method Summary
`protected HandlerInterceptor` | `adaptInterceptor(java.lang.Object interceptor)` Adapt the given interceptor object to the HandlerInterceptor interface.
`protected void` | `extendInterceptors(java.util.List interceptors)` Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (see `setInterceptors(java.lang.Object[])`).
`protected HandlerInterceptor[]` | `getAdaptedInterceptors()` Return the adapted interceptors as HandlerInterceptor array.
`java.lang.Object` | `getDefaultHandler()` Return the default handler for this handler mapping, or `null` if none.
`HandlerExecutionChain` | `getHandler(javax.portlet.PortletRequest request)` Look up a handler for the given request, falling back to the default handler if no specific one is found.
`protected HandlerExecutionChain` | `getHandlerExecutionChain(java.lang.Object handler, javax.portlet.PortletRequest request)` Build a HandlerExecutionChain for the given handler, including applicable interceptors.
`protected abstract java.lang.Object` | `getHandlerInternal(javax.portlet.PortletRequest request)` Look up a handler for the given request, returning `null` if no specific one is found.
`int` | `getOrder()` Return the order value of this object, with a higher value meaning greater in terms of sorting.
`protected void` | `initApplicationContext()` Initializes the interceptors.
`protected void` | `initInterceptors()` Initialize the specified interceptors, adapting them where necessary.
`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").
`void` | `setDefaultHandler(java.lang.Object defaultHandler)` Set the default handler for this handler mapping.
`void` | `setInterceptors(java.lang.Object[] interceptors)` Set the interceptors to apply for all handlers mapped by this handler mapping.
`void` | `setOrder(int order)` Specify the order value for this HandlerMapping bean.

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

### AbstractHandlerMapping

    public AbstractHandlerMapping()

Method Detail

### 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.

  See Also:
    `Ordered.getOrder()`

### getOrder

    public final int getOrder()

  Description copied from interface: `Ordered`
  Return the order value of this object, with a higher value meaning greater in terms of sorting.

  Normally starting with 0, with `Integer.MAX_VALUE` indicating the greatest value. Same order values will result in arbitrary positions for the affected objects.

  Higher values can be interpreted as lower priority. As a consequence, the object with the lowest value has highest priority (somewhat analogous to Servlet "load-on-startup" values).

  Specified by:
    `getOrder` in interface `Ordered`
  Returns:
    the order value

### setDefaultHandler

    public void setDefaultHandler(java.lang.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 java.lang.Object getDefaultHandler()

  Return the default handler for this handler mapping, or `null` if none.

### setInterceptors

    public void setInterceptors(java.lang.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.

  Parameters:
    `interceptors` - array of handler interceptors, or `null` if none
  See Also:
    `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).

  See Also:
    `setInterceptors(java.lang.Object[])`, `WebRequestInterceptor`, `WebRequestHandlerInterceptorAdapter.WebRequestHandlerInterceptorAdapter(WebRequestInterceptor, boolean)`, `OpenSessionInViewInterceptor`

### initApplicationContext

    protected void initApplicationContext()
                                   throws BeansException

  Initializes the interceptors.

  Overrides:
    `initApplicationContext` in class `ApplicationObjectSupport`
  Throws:
    `ApplicationContextException` - in case of initialization errors
    `BeansException` - if thrown by ApplicationContext methods
  See Also:
    `extendInterceptors(java.util.List)`, `initInterceptors()`

### extendInterceptors

    protected void extendInterceptors(java.util.List interceptors)

  Extension hook that subclasses can override to register additional interceptors, given the configured interceptors (see `setInterceptors(java.lang.Object[])`).

  Will be invoked before `initInterceptors()` adapts the specified interceptors into `HandlerInterceptor` instances.

  The default implementation is empty.

  Parameters:
    `interceptors` - the configured interceptor List (never `null`), 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.

  See Also:
    `setInterceptors(java.lang.Object[])`, `adaptInterceptor(java.lang.Object)`

### adaptInterceptor

    protected HandlerInterceptor adaptInterceptor(java.lang.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.

  Parameters:
    `interceptor` - the specified interceptor object
  Returns:
    the interceptor wrapped as HandlerInterceptor
  See Also:
    `setApplyWebRequestInterceptorsToRenderPhaseOnly(boolean)`, `HandlerInterceptor`, `WebRequestInterceptor`, `WebRequestHandlerInterceptorAdapter`

### getAdaptedInterceptors

    protected final HandlerInterceptor[] getAdaptedInterceptors()

  Return the adapted interceptors as HandlerInterceptor array.

  Returns:
    the array of HandlerInterceptors, or `null` if none

### getHandler

    public final HandlerExecutionChain getHandler(javax.portlet.PortletRequest request)
                                           throws java.lang.Exception

  Look up a handler for the given request, falling back to the default handler if no specific one is found.

  Specified by:
    `getHandler` in interface `HandlerMapping`
  Parameters:
    `request` - current portlet request
  Returns:
    the corresponding handler instance, or the default handler
  Throws:
    `java.lang.Exception` - if there is an internal error
  See Also:
    `getHandlerInternal(javax.portlet.PortletRequest)`

### getHandlerInternal

    protected abstract java.lang.Object getHandlerInternal(javax.portlet.PortletRequest request)
                                                    throws java.lang.Exception

  Look up a handler for the given request, returning `null` if no specific one is found. This method is called by `getHandler(javax.portlet.PortletRequest)`; a `null` return 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.

  Parameters:
    `request` - current portlet request
  Returns:
    the corresponding handler instance, or `null` if none found
  Throws:
    `java.lang.Exception` - if there is an internal error
  See Also:
    `getHandler(javax.portlet.PortletRequest)`

### getHandlerExecutionChain

    protected HandlerExecutionChain getHandlerExecutionChain(java.lang.Object handler,
                                                             javax.portlet.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.getHandlerExecutionChain` and invoking `HandlerExecutionChain.addInterceptor(org.springframework.web.portlet.HandlerInterceptor)` on the returned chain object.

  Parameters:
    `handler` - the resolved handler instance (never `null`)
    `request` - current HTTP request
  Returns:
    the HandlerExecutionChain (never `null`)
  See Also:
    `getAdaptedInterceptors()`

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD