| org.springframework.web.servlet.handler.AbstractUrlHandlerMapping org.springframework.web.servlet.handler.metadata.AbstractPathMapHandlerMapping
All known Subclasses: org.springframework.web.servlet.handler.metadata.CommonsPathMapHandlerMapping,
AbstractPathMapHandlerMapping | abstract public class AbstractPathMapHandlerMapping extends AbstractUrlHandlerMapping (Code) | | 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 author: Juergen Hoeller |
Method Summary | |
protected void | detectAndCreateHandlers(ConfigurableListableBeanFactory beanFactory) 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. | abstract protected Class[] | getClassesWithPathMapAttributes() Use an attribute index to get a Collection of Class objects
with the required PathMap attribute. | abstract protected PathMap[] | getPathMapAttributes(Class handlerClass) Use Attributes API to find PathMap attributes for the given handler class. | public void | initApplicationContext() Calls the detectAndCreateHandlers method in addition
to the superclass's initialization. | protected void | registerHandler(PathMap[] pathMaps, Object handler) Register the given handler for the URL paths indicated by the given PathMaps. | public void | setAutowireMode(int autowireMode) Set the autowire mode for handlers. | public void | setAutowireModeName(String constantName) Set the autowire mode for handlers, by the name of the corresponding constant
in the AutowireCapableBeanFactory interface, e.g. | public void | setDependencyCheck(boolean dependencyCheck) Set whether to perform a dependency check for objects on autowired handlers. |
getClassesWithPathMapAttributes | abstract protected Class[] getClassesWithPathMapAttributes() throws Exception(Code) | | Use an attribute index to get a Collection of Class objects
with the required PathMap attribute.
a array of Class objects |
getPathMapAttributes | abstract protected PathMap[] getPathMapAttributes(Class handlerClass) throws Exception(Code) | | 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 an array of PathMap objects |
registerHandler | protected void registerHandler(PathMap[] pathMaps, Object handler) throws BeansException, IllegalStateException(Code) | | Register the given handler for the URL paths indicated by the given PathMaps.
Parameters: pathMaps - the PathMap attributes for the handler class Parameters: handler - the handler instance throws: BeansException - if the handler couldn't be registered throws: IllegalStateException - if there is a conflicting handler registered |
setDependencyCheck | public void setDependencyCheck(boolean dependencyCheck)(Code) | | Set whether to perform a dependency check for objects on autowired handlers.
Not applicable to autowiring a constructor, thus ignored there.
Default is "true".
|
|
|