Class AbstractHandlerMethodAdapter
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- org.springframework.web.servlet.support.WebContentGenerator
- org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter
- All Implemented Interfaces:
Aware
,ApplicationContextAware
,Ordered
,ServletContextAware
,HandlerAdapter
- Direct Known Subclasses:
RequestMappingHandlerAdapter
public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator implements HandlerAdapter, Ordered
Abstract base class forHandlerAdapter
implementations that support handlers of typeHandlerMethod
.- Since:
- 3.1
- Author:
- Arjen Poutsma
Field Summary
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
HEADER_CACHE_CONTROL, METHOD_GET, METHOD_HEAD, METHOD_POST
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor Summary
Constructors Constructor Description AbstractHandlerMethodAdapter()
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description long
getLastModified(HttpServletRequest request, Object handler)
This implementation expects the handler to be anHandlerMethod
.protected abstract long
getLastModifiedInternal(HttpServletRequest request, HandlerMethod handlerMethod)
Same contract as forHttpServlet.getLastModified(HttpServletRequest)
.int
getOrder()
Get the order value of this object.ModelAndView
handle(HttpServletRequest request, HttpServletResponse response, Object handler)
This implementation expects the handler to be anHandlerMethod
.protected abstract ModelAndView
handleInternal(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod)
Use the given handler method to handle the request.void
setOrder(int order)
Specify the order value for this HandlerAdapter bean.boolean
supports(Object handler)
This implementation expects the handler to be anHandlerMethod
.protected abstract boolean
supportsInternal(HandlerMethod handlerMethod)
Given a handler method, return whether or not this adapter can support it.Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheControl, applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, checkRequest, getAllowHeader, getCacheControl, getCacheSeconds, getSupportedMethods, getVaryByRequestHeaders, isAlwaysMustRevalidate, isRequireSession, isUseCacheControlHeader, isUseCacheControlNoStore, isUseExpiresHeader, prepareResponse, preventCaching, setAlwaysMustRevalidate, setCacheControl, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseCacheControlNoStore, setUseExpiresHeader, setVaryByRequestHeaders
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
Constructor Detail
AbstractHandlerMethodAdapter
public AbstractHandlerMethodAdapter()
Method Detail
setOrder
public void setOrder(int order)
Specify the order value for this HandlerAdapter bean.The default value is
Ordered.LOWEST_PRECEDENCE
, meaning non-ordered.- See Also:
Ordered.getOrder()
getOrder
public int getOrder()
Description copied from interface:Ordered
Get 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-startup
values).Same order values will result in arbitrary sort positions for the affected objects.
- Specified by:
getOrder
in interfaceOrdered
- Returns:
- the order value
- See Also:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
supports
public final boolean supports(Object handler)
This implementation expects the handler to be anHandlerMethod
.- Specified by:
supports
in interfaceHandlerAdapter
- Parameters:
handler
- the handler instance to check- Returns:
- whether or not this adapter can adapt the given handler
supportsInternal
protected abstract boolean supportsInternal(HandlerMethod handlerMethod)
Given a handler method, return whether or not this adapter can support it.- Parameters:
handlerMethod
- the handler method to check- Returns:
- whether or not this adapter can adapt the given method
handle
public final ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
This implementation expects the handler to be anHandlerMethod
.- Specified by:
handle
in interfaceHandlerAdapter
- Parameters:
request
- current HTTP requestresponse
- current HTTP responsehandler
- handler to use. This object must have previously been passed to thesupports
method of this interface, which must have returnedtrue
.- Returns:
- ModelAndView object with the name of the view and the required model data, or
null
if the request has been handled directly - Throws:
Exception
- in case of errors
handleInternal
protected abstract ModelAndView handleInternal(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod) throws Exception
Use the given handler method to handle the request.- Parameters:
request
- current HTTP requestresponse
- current HTTP responsehandlerMethod
- handler method to use. This object must have previously been passed to thesupportsInternal(HandlerMethod)
this interface, which must have returnedtrue
.- Returns:
- ModelAndView object with the name of the view and the required model data, or
null
if the request has been handled directly - Throws:
Exception
- in case of errors
getLastModified
public final long getLastModified(HttpServletRequest request, Object handler)
This implementation expects the handler to be anHandlerMethod
.- Specified by:
getLastModified
in interfaceHandlerAdapter
- Parameters:
request
- current HTTP requesthandler
- handler to use- Returns:
- the lastModified value for the given handler
- See Also:
HttpServlet.getLastModified(javax.servlet.http.HttpServletRequest)
,LastModified.getLastModified(javax.servlet.http.HttpServletRequest)
getLastModifiedInternal
protected abstract long getLastModifiedInternal(HttpServletRequest request, HandlerMethod handlerMethod)
Same contract as forHttpServlet.getLastModified(HttpServletRequest)
.- Parameters:
request
- current HTTP requesthandlerMethod
- handler method to use- Returns:
- the lastModified value for the given handler