1616
1717package org .springframework .ws .config .annotation ;
1818
19+ import java .util .Collections ;
1920import java .util .List ;
21+ import java .util .function .Supplier ;
22+ import java .util .stream .Stream ;
2023
24+ import org .springframework .beans .factory .ObjectProvider ;
2125import org .springframework .beans .factory .annotation .Autowired ;
2226import org .springframework .context .annotation .Configuration ;
2327import org .springframework .ws .server .EndpointInterceptor ;
2428import org .springframework .ws .server .endpoint .adapter .method .MethodArgumentResolver ;
2529import org .springframework .ws .server .endpoint .adapter .method .MethodReturnValueHandler ;
2630
2731/**
28- * A sub-class of {@code WsConfigurationSupport} that detects and delegates to all beans
29- * of type {@link WsConfigurer} allowing them to customize the configuration provided by
32+ * A subclass of {@code WsConfigurationSupport} that detects and delegates to all beans of
33+ * type {@link WsConfigurer} allowing them to customize the configuration provided by
3034 * {@code WsConfigurationSupport}. This is the class actually imported by
3135 * {@link EnableWs @EnableWs}.
3236 *
3640@ Configuration
3741public class DelegatingWsConfiguration extends WsConfigurationSupport {
3842
39- private final WsConfigurerComposite configurers = new WsConfigurerComposite ( );
43+ private WsConfigurers configurers = new WsConfigurers ( Collections . emptyList () );
4044
41- @ Autowired ( required = false )
45+ @ Deprecated ( since = "4.0.12" , forRemoval = true )
4246 public void setConfigurers (List <WsConfigurer > configurers ) {
4347 if (configurers != null && !configurers .isEmpty ()) {
44- this .configurers . addWsConfigurers (configurers );
48+ this .configurers = new WsConfigurers (configurers );
4549 }
4650 }
4751
52+ @ Autowired
53+ public void setConfigurers (ObjectProvider <WsConfigurer > configurers ) {
54+ this .configurers = new WsConfigurers (configurers );
55+ }
56+
4857 @ Override
4958 protected void addInterceptors (List <EndpointInterceptor > interceptors ) {
5059 this .configurers .addInterceptors (interceptors );
@@ -60,4 +69,33 @@ protected void addReturnValueHandlers(List<MethodReturnValueHandler> returnValue
6069 this .configurers .addReturnValueHandlers (returnValueHandlers );
6170 }
6271
72+ private static class WsConfigurers implements WsConfigurer {
73+
74+ private final Supplier <Stream <WsConfigurer >> delegates ;
75+
76+ WsConfigurers (ObjectProvider <WsConfigurer > wsConfigurers ) {
77+ this .delegates = wsConfigurers ::stream ;
78+ }
79+
80+ WsConfigurers (List <WsConfigurer > wsConfigurers ) {
81+ this .delegates = wsConfigurers ::stream ;
82+ }
83+
84+ @ Override
85+ public void addInterceptors (List <EndpointInterceptor > interceptors ) {
86+ this .delegates .get ().forEach (configurer -> configurer .addInterceptors (interceptors ));
87+ }
88+
89+ @ Override
90+ public void addArgumentResolvers (List <MethodArgumentResolver > argumentResolvers ) {
91+ this .delegates .get ().forEach (configurer -> configurer .addArgumentResolvers (argumentResolvers ));
92+ }
93+
94+ @ Override
95+ public void addReturnValueHandlers (List <MethodReturnValueHandler > returnValueHandlers ) {
96+ this .delegates .get ().forEach (configurer -> configurer .addReturnValueHandlers (returnValueHandlers ));
97+ }
98+
99+ }
100+
63101}
0 commit comments