org.springframework.web.servlet.handler
Class AbstractHandlerMapping

java.lang.Object
  extended byorg.springframework.context.support.ApplicationObjectSupport
      extended byorg.springframework.web.context.support.WebApplicationObjectSupport
          extended byorg.springframework.web.servlet.handler.AbstractHandlerMapping
All Implemented Interfaces:
ApplicationContextAware, HandlerMapping, Ordered
Direct Known Subclasses:
AbstractUrlHandlerMapping

public abstract class AbstractHandlerMapping
extends WebApplicationObjectSupport
implements HandlerMapping, Ordered

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

Since:
07.04.2003
Author:
Juergen Hoeller
See Also:
getHandlerInternal(javax.servlet.http.HttpServletRequest), HandlerInterceptor

Field Summary
protected  Log logger
           
 
Constructor Summary
AbstractHandlerMapping()
           
 
Method Summary
protected  Object getDefaultHandler()
          Return the default handler for this handler mapping.
 HandlerExecutionChain getHandler(HttpServletRequest request)
          Look up a handler for the given request, falling back to the default handler if no specific one is found.
protected abstract  Object getHandlerInternal(HttpServletRequest request)
          Lookup a handler for the given request, returning null if no specific one is found.
 int getOrder()
          Return the order value of this object, higher value meaning greater in terms of sorting.
 void setDefaultHandler(Object defaultHandler)
          Set the default handler for this handler mapping.
 void setInterceptors(HandlerInterceptor[] interceptors)
          Set the handler interceptors to apply for all handlers mapped by this handler mapping.
 void setOrder(int order)
           
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Constructor Detail

AbstractHandlerMapping

public AbstractHandlerMapping()
Method Detail

setOrder

public final void setOrder(int order)

getOrder

public final int getOrder()
Description copied from interface: Ordered
Return the order value of this object, higher value meaning greater in terms of sorting. Normally starting with 0 or 1, Integer.MAX_VALUE indicating greatest. Same order values will result in arbitrary positions for the affected objects.

Higher value can be interpreted as lower priority, consequently the first object has highest priority (somewhat analogous to Servlet "load-on-startup" values).

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

setDefaultHandler

public final 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.

Parameters:
defaultHandler - default handler instance, or null if none

getDefaultHandler

protected final Object getDefaultHandler()
Return the default handler for this handler mapping.

Returns:
the default handler instance, or null if none

setInterceptors

public final void setInterceptors(HandlerInterceptor[] interceptors)
Set the handler interceptors to apply for all handlers mapped by this handler mapping.

Parameters:
interceptors - array of handler interceptors, or null if none

getHandler

public final HandlerExecutionChain getHandler(HttpServletRequest request)
                                       throws 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 HTTP request
Returns:
the looked up handler instance, or the default handler
Throws:
Exception - if there is an internal error
See Also:
getHandlerInternal(javax.servlet.http.HttpServletRequest)

getHandlerInternal

protected abstract Object getHandlerInternal(HttpServletRequest request)
                                      throws Exception
Lookup a handler for the given request, returning null if no specific one is found. This method is called by getHandler, a null return value will lead to the default handler, if one is set.

Parameters:
request - current HTTP request
Returns:
the looked up handler instance, or null
Throws:
Exception - if there is an internal error


Copyright (C) 2003-2004 The Spring Framework Project.