diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java index d2116be6..d84568c9 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/DelegatingWsConfiguration.java @@ -16,8 +16,12 @@ package org.springframework.ws.config.annotation; +import java.util.Collections; import java.util.List; +import java.util.function.Supplier; +import java.util.stream.Stream; +import org.springframework.beans.factory.ObjectProvider; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.ws.server.EndpointInterceptor; @@ -25,8 +29,8 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodArgumentResol import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHandler; /** - * A sub-class of {@code WsConfigurationSupport} that detects and delegates to all beans - * of type {@link WsConfigurer} allowing them to customize the configuration provided by + * A subclass of {@code WsConfigurationSupport} that detects and delegates to all beans of + * type {@link WsConfigurer} allowing them to customize the configuration provided by * {@code WsConfigurationSupport}. This is the class actually imported by * {@link EnableWs @EnableWs}. * @@ -36,15 +40,20 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHa @Configuration public class DelegatingWsConfiguration extends WsConfigurationSupport { - private final WsConfigurerComposite configurers = new WsConfigurerComposite(); + private WsConfigurers configurers = new WsConfigurers(Collections.emptyList()); - @Autowired(required = false) + @Deprecated(since = "4.0.12", forRemoval = true) public void setConfigurers(List configurers) { if (configurers != null && !configurers.isEmpty()) { - this.configurers.addWsConfigurers(configurers); + this.configurers = new WsConfigurers(configurers); } } + @Autowired + public void setConfigurers(ObjectProvider configurers) { + this.configurers = new WsConfigurers(configurers); + } + @Override protected void addInterceptors(List interceptors) { this.configurers.addInterceptors(interceptors); @@ -60,4 +69,33 @@ public class DelegatingWsConfiguration extends WsConfigurationSupport { this.configurers.addReturnValueHandlers(returnValueHandlers); } + private static class WsConfigurers implements WsConfigurer { + + private final Supplier> delegates; + + WsConfigurers(ObjectProvider wsConfigurers) { + this.delegates = wsConfigurers::stream; + } + + WsConfigurers(List wsConfigurers) { + this.delegates = wsConfigurers::stream; + } + + @Override + public void addInterceptors(List interceptors) { + this.delegates.get().forEach(configurer -> configurer.addInterceptors(interceptors)); + } + + @Override + public void addArgumentResolvers(List argumentResolvers) { + this.delegates.get().forEach(configurer -> configurer.addArgumentResolvers(argumentResolvers)); + } + + @Override + public void addReturnValueHandlers(List returnValueHandlers) { + this.delegates.get().forEach(configurer -> configurer.addReturnValueHandlers(returnValueHandlers)); + } + + } + } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java index 8659c8fd..bd32ad52 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/config/annotation/WsConfigurerComposite.java @@ -29,7 +29,9 @@ import org.springframework.ws.server.endpoint.adapter.method.MethodReturnValueHa * * @author Arjen Poutsma * @since 2.2 + * @deprecated since 4.0.12 with no replacement */ +@Deprecated(since = "4.0.12", forRemoval = true) public class WsConfigurerComposite implements WsConfigurer { private List delegates = new ArrayList<>();