From 500179e5c0c7892e21a6255314554f5919e8a4a5 Mon Sep 17 00:00:00 2001 From: Ryan Skow Date: Mon, 23 Feb 2015 13:25:11 -0600 Subject: [PATCH] Allow custom RequestMappingHandlerMapping Extract the creation of RequestMappingHandlerMapping into protected method to allow easier use of custom subclasses. Issue: SPR-12746 --- .../annotation/WebMvcConfigurationSupport.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 5f2c4e5a16..713ca69e78 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -223,7 +223,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv */ @Bean public RequestMappingHandlerMapping requestMappingHandlerMapping() { - RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping(); + RequestMappingHandlerMapping handlerMapping = createRequestMappingHandlerMapping(); handlerMapping.setOrder(0); handlerMapping.setInterceptors(getInterceptors()); handlerMapping.setContentNegotiationManager(mvcContentNegotiationManager()); @@ -248,6 +248,14 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv return handlerMapping; } + /** + * Protected method for plugging in a custom sub-class of + * {@link RequestMappingHandlerMapping}. + */ + protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { + return new RequestMappingHandlerMapping(); + } + /** * Provide access to the shared handler interceptors used to configure * {@link HandlerMapping} instances with. This method cannot be overridden, -- GitLab