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  org.apache.commons.logging.Log logger
           
 
Constructor Summary
AbstractHandlerMapping()
           
 
Method Summary
protected  java.lang.Object getDefaultHandler()
          Return the default handler for this handler mapping.
 HandlerExecutionChain getHandler(javax.servlet.http.HttpServletRequest request)
          Look up a handler for the given request, falling back to the default handler if no specific one is found.
protected abstract  java.lang.Object getHandlerInternal(javax.servlet.http.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(java.lang.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, requiredContextClass
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.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(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.

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

getDefaultHandler

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

getHandlerInternal

protected abstract java.lang.Object getHandlerInternal(javax.servlet.http.HttpServletRequest request)
                                                throws java.lang.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:
java.lang.Exception - if there is an internal error


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