-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
cemo koc opened SPR-11541 and commented
We are heavily using Spring MVC and currently we had to duplicated a fair amount codes to provide necessary functionalities. We are providing redirection mappings by database. At runtime we periodically checking for any kind of operation such deletion or insertion and want to register them by RequestMappingHandlerMapping.
Spring's RequestMapping is nice but does not provide easy way to provide addition or deletion of RequestMapping's. In order to add a new mapping, RequestMappingHandlerMapping has to be extended as this:
public class RequestMappingInfoAppendableHandlerMapping extends RequestMappingHandlerMapping {
@Override
@Override
public void registerHandlerMethod(Object handler, Method method, RequestMappingInfo mapping) {
super.registerHandlerMethod(handler, method, mapping);
}
}
I still did not find a beautiful way to unregistering mappings. What I am suggesting:
Please provide necessary util classes and public methods to registering and unregistering request mappings.
By the way I have already tried other HandlerMapping implementations but I do not want to change priority because of the performance cost. Also a custom HandlerMapping after RequestMappingHandlerMapping is not capable of handling because of our mappings at RequestMappingHandlerMapping.
Edit:
I had also implemented a very basic utility function for creating new MappingInfo's. I believe that such convenient methods will be very useful. A Builder can be great as well.
public final class RequestMappingInfoUtils {
public static RequestMappingInfo newInstance(String[] urls){
return newInstance(urls, RequestMethod.GET);
}
public static RequestMappingInfo newInstance(String[] urls, RequestMethod requestMethod){
return new RequestMappingInfo(new PatternsRequestCondition(urls),
new RequestMethodsRequestCondition(requestMethod),
null,
null,
null,
null,
null);
}
}
Affects: 3.2.8, 4.0.2
Issue Links:
- INT-3713 Fix RequestMapping logic according latest Spring MVC changes ("is depended on by")
- Pointcut evaluation fails against AbstractHandlerMethodMapping$MappingRegistry with AspectJ 1.8.10 [SPR-15019] #19586 Pointcut evaluation fails against AbstractHandlerMethodMapping$MappingRegistry with AspectJ 1.8.10
- Add protected method to StandaloneMockMvcBuilder to register additional MVC infrastructure components [SPR-17520] #22052 Add protected method to StandaloneMockMvcBuilder to register additional MVC infrastructure components
0 votes, 6 watchers