|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.context.support.ApplicationObjectSupport org.springframework.web.context.support.WebApplicationObjectSupport org.springframework.web.servlet.handler.AbstractHandlerMapping org.springframework.web.servlet.handler.AbstractUrlHandlerMapping org.springframework.web.servlet.handler.metadata.AbstractPathMapHandlerMapping
public abstract class AbstractPathMapHandlerMapping
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.
Field Summary |
---|
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport |
---|
logger |
Constructor Summary | |
---|---|
AbstractPathMapHandlerMapping()
|
Method Summary | |
---|---|
protected abstract Class[] |
getClassesWithPathMapAttributes()
Use an attribute index to get a Collection of Class objects with the required PathMap attribute. |
protected abstract PathMap[] |
getPathMapAttributes(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. |
void |
setAutowireMode(int autowireMode)
Set the autowire mode for handlers. |
void |
setAutowireModeName(String constantName)
Set the autowire mode for handlers, by the name of the corresponding constant in the AutowireCapableBeanFactory interface, e.g. |
void |
setDependencyCheck(boolean dependencyCheck)
Set whether to perform a dependency check for objects on autowired handlers. |
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping |
---|
getHandlerInternal, getHandlerMap, lookupHandler, registerHandler, setAlwaysUseFullPath, setLazyInitHandlers, setPathMatcher, 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, isContextRequired |
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 |
---|
public AbstractPathMapHandlerMapping()
Method Detail |
---|
public void setAutowireModeName(String constantName) throws IllegalArgumentException
constantName
- name of the constant
IllegalArgumentException
- if an invalid constant was specifiedsetAutowireMode(int)
,
AutowireCapableBeanFactory.AUTOWIRE_BY_NAME
,
AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE
,
AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR
,
AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT
public void setAutowireMode(int autowireMode)
Default is AUTOWIRE_AUTODETECT, which means either constructor autowiring or autowiring by type (depending on the constructors available in the class).
autowireMode
- the autowire mode to set.
Must be one of the constants defined in the AutowireCapableBeanFactory interface.AutowireCapableBeanFactory.AUTOWIRE_BY_NAME
,
AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE
,
AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR
,
AutowireCapableBeanFactory.AUTOWIRE_AUTODETECT
public void setDependencyCheck(boolean dependencyCheck)
Default is "true".
public void initApplicationContext() throws BeansException
initApplicationContext
in class ApplicationObjectSupport
ApplicationContextException
- in case of initialization errors
BeansException
- if thrown by ApplicationContext methodsPathMap
protected abstract Class[] getClassesWithPathMapAttributes() throws Exception
Exception
protected abstract PathMap[] getPathMapAttributes(Class handlerClass) throws Exception
handlerClass
- the handler class to look for
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |