Skip to content

Replace WebMvcRegistrationsAdapter with default methods #9340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,26 @@ public interface WebMvcRegistrations {
* processed by the MVC configuration.
* @return the custom {@link RequestMappingHandlerMapping} instance
*/
RequestMappingHandlerMapping getRequestMappingHandlerMapping();
default RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
return null;
}

/**
* Return the custom {@link RequestMappingHandlerAdapter} that should be used and
* processed by the MVC configuration.
* @return the custom {@link RequestMappingHandlerAdapter} instance
*/
RequestMappingHandlerAdapter getRequestMappingHandlerAdapter();
default RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
return null;
}

/**
* Return the custom {@link ExceptionHandlerExceptionResolver} that should be used and
* processed by the MVC configuration.
* @return the custom {@link ExceptionHandlerExceptionResolver} instance
*/
ExceptionHandlerExceptionResolver getExceptionHandlerExceptionResolver();
default ExceptionHandlerExceptionResolver getExceptionHandlerExceptionResolver() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,16 @@

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
* sub-classes to override only the methods they're interested in.
*
* @author Brian Clozel
* @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 {

@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
return null;
}

@Override
public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
return null;
}

@Override
public ExceptionHandlerExceptionResolver getExceptionHandlerExceptionResolver() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -899,8 +899,8 @@ public HttpPutFormContentFilter customHttpPutFormContentFilter() {
static class CustomRequestMappingHandlerMapping {

@Bean
public WebMvcRegistrationsAdapter webMvcRegistrationsHandlerMapping() {
return new WebMvcRegistrationsAdapter() {
public WebMvcRegistrations webMvcRegistrationsHandlerMapping() {
return new WebMvcRegistrations() {

@Override
public RequestMappingHandlerMapping getRequestMappingHandlerMapping() {
Expand All @@ -921,8 +921,8 @@ private static class MyRequestMappingHandlerMapping
static class CustomRequestMappingHandlerAdapter {

@Bean
public WebMvcRegistrationsAdapter webMvcRegistrationsHandlerAdapter() {
return new WebMvcRegistrationsAdapter() {
public WebMvcRegistrations webMvcRegistrationsHandlerAdapter() {
return new WebMvcRegistrations() {

@Override
public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() {
Expand Down