org.springframework.web.servlet.handler.metadata
Class AbstractPathMapHandlerMapping

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

public abstract class AbstractPathMapHandlerMapping
extends AbstractUrlHandlerMapping

Abstract implementation of the HandlerMapping interface that recognizes metadata attributes of type PathMap on application Controllers and automatically wires them into the current servlet's WebApplicationContext.

The path must be mapped to the relevant Spring DispatcherServlet in /WEB-INF/web.xml. It's possible to have multiple PathMap attributes on the one controller class.

Controllers instantiated by this class may have dependencies on middle tier objects, expressed via JavaBean properties or constructor arguments. These will be resolved automatically.

You will normally use this HandlerMapping with at most one DispatcherServlet in your web application. Otherwise you'll end with one instance of the mapped controller for each DispatcherServlet's context. You might want this -- for example, if one's using a .pdf mapping and a PDF view, and another a JSP view, or if using different middle tier objects, but should understand the implications. All Controllers with attributes will be picked up by each DispatcherServlet's context.

Author:
Rod Johnson, Juergen Hoeller

Field Summary
 
Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
logger
 
Constructor Summary
AbstractPathMapHandlerMapping()
           
 
Method Summary
protected abstract  java.lang.Class[] getClassesWithPathMapAttributes()
          Use an attribute index to get a Collection of Class objects with the required PathMap attribute.
protected abstract  PathMap[] getPathMapAttributes(java.lang.Class handlerClass)
          Use Attributes API to find PathMap attributes for the given handler class.
 void initApplicationContext()
          Look for all classes with a PathMap class attribute, instantiate them in the owning ApplicationContext and register them as MVC handlers usable by the current DispatcherServlet.
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
getHandlerInternal, lookupHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setUrlDecode, setUrlPathHelper
 
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
getDefaultHandler, getHandler, getOrder, setDefaultHandler, setInterceptors, setOrder
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPathMapHandlerMapping

public AbstractPathMapHandlerMapping()
Method Detail

initApplicationContext

public void initApplicationContext()
                            throws BeansException
Look for all classes with a PathMap class attribute, instantiate them in the owning ApplicationContext and register them as MVC handlers usable by the current DispatcherServlet.

Overrides:
initApplicationContext in class ApplicationObjectSupport
Throws:
BeansException - if thrown by application context methods
See Also:
ApplicationObjectSupport.initApplicationContext()

getClassesWithPathMapAttributes

protected abstract java.lang.Class[] getClassesWithPathMapAttributes()
                                                              throws java.lang.Exception
Use an attribute index to get a Collection of Class objects with the required PathMap attribute.

Returns:
a array of Class objects
Throws:
java.lang.Exception

getPathMapAttributes

protected abstract PathMap[] getPathMapAttributes(java.lang.Class handlerClass)
                                           throws java.lang.Exception
Use Attributes API to find PathMap attributes for the given handler class. We know there's at least one, as the getClassNamesWithPathMapAttributes method return this class name.

Parameters:
handlerClass - the handler class to look for
Returns:
an array of PathMap objects
Throws:
java.lang.Exception


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