|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.handler.AbstractHandlerMapping
org.resthub.web.springmvc.router.RouterHandlerMapping
public class RouterHandlerMapping
Implementation of the HandlerMapping
interface that maps handlers based on HTTP routes defined in a route
configuration file.
RouterHandlerMapping is not the default HandlerMapping registered in
DispatcherServlet in SpringMVC. You
need to declare and configure it in your DispatcherServlet context, by adding
a RouterHandlerMapping bean explicitly. RouterHandlerMapping needs the name
of the route configuration file (available in the application classpath); it
also allows for registering custom interceptors:
<bean class="org.resthub.web.springmvc.router.RouterHandlerMapping"> <property name="routeFiles"> <list> <value>routes.conf</value> <value>addroutes.conf</value> </list> </property> <property name="servletPrefix" value="/myservlet" /> <property name="interceptors" > ... </property> </bean>
Annotated controllers should be marked with the Controller
stereotype at the type level. This is not strictly necessary because the
methodeInvoker will try to map the Controller.invoker anyway using the
current ApplicationContext. The RequestMapping is not taken into
account here.
RouterHandlerMapping loads routes configuration from a file for route
configuration syntax (the Router implementation is adapted from Play!
Framework http://www.playframework.org/documentation/1.0.3/routes#syntax).
Example:
GET /home PageController.showPage(id:'home') GET
/page/{id} PageController.showPage POST /customer/{<[0-9]+>customerid}
CustomerController.createCustomer
The RouterHandlerAdapter is responsible for choosing and
invoking the right controller method, as mapped by this HandlerMapping.
AbstractHandlerMapping| Field Summary |
|---|
| Fields inherited from interface org.springframework.web.servlet.HandlerMapping |
|---|
BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE |
| Fields inherited from interface org.springframework.core.Ordered |
|---|
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE |
| Constructor Summary | |
|---|---|
RouterHandlerMapping()
|
|
| Method Summary | |
|---|---|
protected Object |
getHandlerInternal(javax.servlet.http.HttpServletRequest request)
Resolves a HandlerMethod (of type RouterHandler) given the current HTTP request, using the Router instance. |
List<String> |
getRouteFiles()
Routes configuration Files names< Injected by bean configuration (in servlet.xml) |
String |
getServletPrefix()
Servlet Prefix to be added in front of all routes Injected by bean configuration (in servlet.xml) |
protected void |
initApplicationContext()
Inits Routes from route configuration file |
void |
reloadRoutesConfiguration()
Reload routes configuration at runtime. |
void |
setRouteFiles(List<String> routeFiles)
|
void |
setServletPrefix(String servletPrefix)
|
| Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping |
|---|
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initInterceptors, setAlwaysUseFullPath, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setUrlDecode, setUrlPathHelper |
| Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport |
|---|
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext |
| 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 RouterHandlerMapping()
| Method Detail |
|---|
public String getServletPrefix()
public void setServletPrefix(String servletPrefix)
public List<String> getRouteFiles()
public void setRouteFiles(List<String> routeFiles)
public void reloadRoutesConfiguration()
protected void initApplicationContext()
throws org.springframework.beans.BeansException
initApplicationContext in class org.springframework.web.servlet.handler.AbstractHandlerMappingorg.springframework.beans.BeansException
protected Object getHandlerInternal(javax.servlet.http.HttpServletRequest request)
throws Exception
getHandlerInternal in class org.springframework.web.servlet.handler.AbstractHandlerMappingrequest - the HTTP Servlet request
Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||