Merge pull request #9340 from vpavic:improve-webmvc-registrations
* pr/9340: Replace `WebMvcRegistrationsAdapter` with default methods
This commit is contained in:
commit
1fcb5ec7f5
|
|
@ -40,20 +40,26 @@ public interface WebMvcRegistrations {
|
||||||
* processed by the MVC configuration.
|
* processed by the MVC configuration.
|
||||||
* @return the custom {@link RequestMappingHandlerMapping} instance
|
* @return the custom {@link RequestMappingHandlerMapping} instance
|
||||||
*/
|
*/
|
||||||
RequestMappingHandlerMapping getRequestMappingHandlerMapping();
|
default RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the custom {@link RequestMappingHandlerAdapter} that should be used and
|
* Return the custom {@link RequestMappingHandlerAdapter} that should be used and
|
||||||
* processed by the MVC configuration.
|
* processed by the MVC configuration.
|
||||||
* @return the custom {@link RequestMappingHandlerAdapter} instance
|
* @return the custom {@link RequestMappingHandlerAdapter} instance
|
||||||
*/
|
*/
|
||||||
RequestMappingHandlerAdapter getRequestMappingHandlerAdapter();
|
default RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the custom {@link ExceptionHandlerExceptionResolver} that should be used and
|
* Return the custom {@link ExceptionHandlerExceptionResolver} that should be used and
|
||||||
* processed by the MVC configuration.
|
* processed by the MVC configuration.
|
||||||
* @return the custom {@link ExceptionHandlerExceptionResolver} instance
|
* @return the custom {@link ExceptionHandlerExceptionResolver} instance
|
||||||
*/
|
*/
|
||||||
ExceptionHandlerExceptionResolver getExceptionHandlerExceptionResolver();
|
default ExceptionHandlerExceptionResolver getExceptionHandlerExceptionResolver() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,32 +16,16 @@
|
||||||
|
|
||||||
package org.springframework.boot.autoconfigure.web.servlet;
|
package org.springframework.boot.autoconfigure.web.servlet;
|
||||||
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver;
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter;
|
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link WebMvcRegistrations} with empty methods allowing
|
* An implementation of {@link WebMvcRegistrations} with empty methods allowing
|
||||||
* sub-classes to override only the methods they're interested in.
|
* sub-classes to override only the methods they're interested in.
|
||||||
*
|
*
|
||||||
* @author Brian Clozel
|
* @author Brian Clozel
|
||||||
* @since 1.4.0
|
* @since 1.4.0
|
||||||
|
* @deprecated as of 2.0.0 {@link WebMvcRegistrations} has default methods (made possible
|
||||||
|
* by a Java 8 baseline) and can be implemented directly without the need for this adapter
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public class WebMvcRegistrationsAdapter implements WebMvcRegistrations {
|
public class WebMvcRegistrationsAdapter implements WebMvcRegistrations {
|
||||||
|
|
||||||
@Override
|
|
||||||
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ExceptionHandlerExceptionResolver getExceptionHandlerExceptionResolver() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -899,8 +899,8 @@ public class WebMvcAutoConfigurationTests {
|
||||||
static class CustomRequestMappingHandlerMapping {
|
static class CustomRequestMappingHandlerMapping {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public WebMvcRegistrationsAdapter webMvcRegistrationsHandlerMapping() {
|
public WebMvcRegistrations webMvcRegistrationsHandlerMapping() {
|
||||||
return new WebMvcRegistrationsAdapter() {
|
return new WebMvcRegistrations() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
|
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
|
||||||
|
|
@ -921,8 +921,8 @@ public class WebMvcAutoConfigurationTests {
|
||||||
static class CustomRequestMappingHandlerAdapter {
|
static class CustomRequestMappingHandlerAdapter {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public WebMvcRegistrationsAdapter webMvcRegistrationsHandlerAdapter() {
|
public WebMvcRegistrations webMvcRegistrationsHandlerAdapter() {
|
||||||
return new WebMvcRegistrationsAdapter() {
|
return new WebMvcRegistrations() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
|
public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue