Deprecate WsConfigurerAdapter

Closes gh-1480
This commit is contained in:
Stéphane Nicoll
2025-03-10 08:13:12 +01:00
parent 945b3306f5
commit d5a4c9219b
6 changed files with 23 additions and 22 deletions

View File

@@ -38,15 +38,12 @@ import org.springframework.context.annotation.Import;
*
* }</code></pre>
* <p>
* Customize the imported configuration by implementing the {@link WsConfigurer} interface
* or more likely by extending the {@link WsConfigurerAdapter} base class and overriding
* individual methods:
*
* <pre><code class='java'>
* Customize the imported configuration by implementing the {@link WsConfigurer}
* interface: <pre><code class='java'>
* &#064;Configuration
* &#064;EnableWs
* &#064;ComponentScan(basePackageClasses = { MyConfiguration.class })
* public class MyConfiguration extends WsConfigurerAdapter {
* public class MyConfiguration implements WsConfigurer {
*
* &#064;Override
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
@@ -86,7 +83,6 @@ import org.springframework.context.annotation.Import;
* @author Arjen Poutsma
* @since 2.2
* @see WsConfigurer
* @see WsConfigurerAdapter
* @see WsConfigurationSupport
*/
@Retention(RetentionPolicy.RUNTIME)

View File

@@ -75,7 +75,6 @@ import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationM
* @since 2.2
* @see EnableWs
* @see WsConfigurer
* @see WsConfigurerAdapter
*/
public class WsConfigurationSupport {

View File

@@ -27,9 +27,7 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHa
* Services enabled via {@link EnableWs @EnableWs}.
* <p>
* {@code @EnableWs}-annotated configuration classes may implement this interface to be
* called back and given a chance to customize the default configuration. Consider
* extending {@link WsConfigurerAdapter}, which provides a stub implementation of all
* interface methods.
* called back and given a chance to customize the default configuration.
*
* @author Arjen Poutsma
* @since 2.2
@@ -40,13 +38,17 @@ public interface WsConfigurer {
* Add {@link EndpointInterceptor}s for pre- and post-processing of endpoint method
* invocations.
*/
void addInterceptors(List<EndpointInterceptor> interceptors);
default void addInterceptors(List<EndpointInterceptor> interceptors) {
}
/**
* Add resolvers to support custom endpoint method argument types.
* @param argumentResolvers initially an empty list
*/
void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers);
default void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
}
/**
* Add handlers to support custom controller method return value types.
@@ -56,6 +58,8 @@ public interface WsConfigurer {
* RequestMappingHandlerAdapter directly.
* @param returnValueHandlers initially an empty list
*/
void addReturnValueHandlers(List<MethodReturnValueHandler> returnValueHandlers);
default void addReturnValueHandlers(List<MethodReturnValueHandler> returnValueHandlers) {
}
}

View File

@@ -28,7 +28,9 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHa
*
* @author Arjen Poutsma
* @since 2.2
* @deprecated as of 4.1.0 in favor of implementing {@link WsConfigurer} directly
*/
@Deprecated(since = "4.1.0", forRemoval = true)
public class WsConfigurerAdapter implements WsConfigurer {
/**

View File

@@ -100,7 +100,7 @@ public class WsConfigurerAdapterTest {
@Configuration
@EnableWs
public static class TestConfig extends WsConfigurerAdapter {
public static class TestConfig implements WsConfigurer {
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {

View File

@@ -617,14 +617,14 @@ public class EchoConfig {
----
====
To customize the `@EnableWs` configuration, you can implement `WsConfigurer` or, better yet, extend the `WsConfigurerAdapter`:
To customize the `@EnableWs` configuration, you can implement `WsConfigurer`:
====
[source,java]
----
@Configuration
@EnableWs
public class MyConfiguration extends WsConfigurerAdapter {
public class MyConfiguration implements WsConfigurer {
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {
@@ -1067,14 +1067,14 @@ Finally, we define two interceptors that apply when the message has a `http://ww
Notice how the second interceptor is actually a reference to a bean definition outside the `<interceptors>` element.
You can use bean references anywhere inside the `<interceptors>` element.
When you use `@Configuration` classes, you can extend from `WsConfigurerAdapter` to add interceptors:
When you use `@Configuration` classes, you can implement `WsConfigurer` to add interceptors:
====
[source,java]
----
@Configuration
@EnableWs
public class MyWsConfiguration extends WsConfigurerAdapter {
public class MyWsConfiguration implements WsConfigurer {
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {
@@ -1119,7 +1119,7 @@ The following example shows how to define the `PayloadLoggingInterceptor` in an
Both of these interceptors have two properties, `logRequest` and `logResponse`, which can be set to `false` to disable logging for either request or response messages.
You could use the `WsConfigurerAdapter` approach, as described earlier, for the `PayloadLoggingInterceptor` as well.
You could use the `WsConfigurer` approach, as described earlier, for the `PayloadLoggingInterceptor` as well.
==== `PayloadValidatingInterceptor`
@@ -1152,7 +1152,7 @@ Note that the `PayloadValidatingInterceptor` can also accept multiple schemas by
----
====
Of course, you could use the `WsConfigurerAdapter` approach, as described earlier, for the `PayloadValidatingInterceptor` as well.
Of course, you could use the `WsConfigurer` approach, as described earlier, for the `PayloadValidatingInterceptor` as well.
==== Using `PayloadTransformingInterceptor`
@@ -1175,7 +1175,7 @@ In the preceding example, we transform requests by using `/WEB-INF/oldRequests.x
Note that, since endpoint interceptors are registered at the endpoint-mapping level, you can create an endpoint mapping that applies to the "`old style`" messages and add the interceptor to that mapping.
Hence, the transformation applies only to these "`old style`" message.
You could use the `WsConfigurerAdapter` approach, as described earlier, for the `PayloadTransformingInterceptor` as well.
You could use the `WsConfigurer` approach, as described earlier, for the `PayloadTransformingInterceptor` as well.
[[server-endpoint-exception-resolver]]
== Handling Exceptions