Skip to content

Commit f9af332

Browse files
committed
Clarify how to apply advanced endpoint configuration
Closes gh-1209
1 parent 352801d commit f9af332

File tree

2 files changed

+64
-37
lines changed
  • spring-ws-core/src/main/java/org/springframework/ws/config/annotation
  • spring-ws-docs/src/docs/asciidoc

2 files changed

+64
-37
lines changed

spring-ws-core/src/main/java/org/springframework/ws/config/annotation/EnableWs.java

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,68 +22,70 @@
2222
import java.lang.annotation.RetentionPolicy;
2323
import java.lang.annotation.Target;
2424

25-
import org.springframework.context.annotation.Configuration;
2625
import org.springframework.context.annotation.Import;
2726

2827
/**
29-
* Add this annotation to an {@link Configuration @Configuration} class to have the Spring
30-
* Web Services configuration defined in {@link WsConfigurationSupport} imported. For
31-
* instance:
28+
* Adding this annotation to an {@code @Configuration} class imports the Spring Web
29+
* Services configuration from {@link WsConfigurationSupport}, for example:
3230
*
3331
* <pre><code class='java'>
3432
* &#064;Configuration
3533
* &#064;EnableWs
36-
* &#064;ComponentScan(basePackageClasses = { MyConfiguration.class })
37-
* public class MyWsConfiguration {
34+
* &#064;ComponentScan(basePackageClasses = MyConfiguration.class)
35+
* public class MyConfiguration {
3836
*
3937
* }</code></pre>
4038
* <p>
41-
* Customize the imported configuration by implementing the {@link WsConfigurer} interface
42-
* or more likely by extending the {@link WsConfigurerAdapter} base class and overriding
43-
* individual methods:
39+
* To customize the imported configuration, implement the {@link WsConfigurer} interface
40+
* or more likely extend the {@link WsConfigurerAdapter} base class and override individual methods, for example:
4441
*
4542
* <pre><code class='java'>
4643
* &#064;Configuration
4744
* &#064;EnableWs
48-
* &#064;ComponentScan(basePackageClasses = { MyConfiguration.class })
45+
* &#064;ComponentScan(basePackageClasses = MyConfiguration.class)
4946
* public class MyConfiguration extends WsConfigurerAdapter {
5047
*
51-
* &#064;Override
52-
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
53-
* interceptors.add(new MyInterceptor());
54-
* }
48+
* &#064;Override
49+
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
50+
* interceptors.add(new MyInterceptor());
51+
* }
5552
*
56-
* &#064;Override
57-
* public void addArgumentResolvers(List&lt;MethodArgumentResolver&gt; argumentResolvers) {
58-
* argumentResolvers.add(new MyArgumentResolver());
59-
* }
53+
* &#064;Override
54+
* public void addArgumentResolvers(List&lt;MethodArgumentResolver&gt; argumentResolvers) {
55+
* argumentResolvers.add(new MyArgumentResolver());
56+
* }
6057
*
61-
* // More overridden methods ...
6258
* }</code></pre>
6359
* <p>
64-
* If the customization options of {@link WsConfigurer} do not expose something you need
65-
* to configure, consider removing the {@code @EnableWs} annotation and extending directly
66-
* from {@link WsConfigurationSupport} overriding selected {@code @Bean} methods:
60+
* <strong>Note:</strong> only one {@code @Configuration} class may have the
61+
* {@code @EnableWs} annotation to import the Spring Web Services configuration. There can
62+
* however be multiple {@code @Configuration} classes implementing {@code WsConfigurer} in
63+
* order to customize the provided configuration.
64+
* <p>
65+
* If {@link WsConfigurer} does not expose some more advanced setting that needs to be
66+
* configured, consider removing the {@code @EnableWs} annotation and extending directly
67+
* from {@link WsConfigurationSupport} or {@link DelegatingWsConfiguration}, for example:
6768
*
6869
* <pre><code class='java'>
6970
* &#064;Configuration
7071
* &#064;ComponentScan(basePackageClasses = { MyConfiguration.class })
7172
* public class MyConfiguration extends WsConfigurationSupport {
7273
*
73-
* &#064;Override
74-
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
75-
* interceptors.add(new MyInterceptor());
76-
* }
74+
* &#064;Override
75+
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
76+
* interceptors.add(new MyInterceptor());
77+
* }
7778
*
78-
* &#064;Bean
79-
* &#064;Override
80-
* public DefaultMethodEndpointAdapter defaultMethodEndpointAdapter() {
81-
* // Create or delegate to "super" to create and
82-
* // customize properties of DefaultMethodEndpointAdapter
83-
* }
79+
* &#064;Bean
80+
* &#064;Override
81+
* public PayloadRootAnnotationMethodEndpointMapping payloadRootAnnotationMethodEndpointMapping() {
82+
* // Create or delegate to "super" to create and
83+
* // customize properties of PayloadRootAnnotationMethodEndpointMapping
84+
* }
8485
* }</code></pre>
8586
*
8687
* @author Arjen Poutsma
88+
* @author Stephane Nicoll
8789
* @since 2.2
8890
* @see WsConfigurer
8991
* @see WsConfigurerAdapter

spring-ws-docs/src/docs/asciidoc/server.adoc

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -633,14 +633,14 @@ public class EchoConfig {
633633
----
634634
====
635635

636-
To customize the `@EnableWs` configuration, you can implement `WsConfigurer` or, better yet, extend the `WsConfigurerAdapter`:
636+
To customize the `@EnableWs` configuration, you can implement `WsConfigurer` and override individual methods:
637637

638638
====
639639
[source,java]
640640
----
641641
@Configuration
642642
@EnableWs
643-
public class MyConfiguration extends WsConfigurerAdapter {
643+
public class EchoConfig extends WsConfigurerAdapter {
644644
645645
@Override
646646
public void addInterceptors(List<EndpointInterceptor> interceptors) {
@@ -652,7 +652,30 @@ public class MyConfiguration extends WsConfigurerAdapter {
652652
argumentResolvers.add(new MyArgumentResolver());
653653
}
654654
655-
// More overridden methods ...
655+
}
656+
----
657+
====
658+
659+
If `WsConfigurer` does not expose some more advanced setting that needs to be configured, consider removing `@EnableWs` and extending directly from `WsConfigurationSupport` or `DelegatingWsConfiguration`.
660+
661+
====
662+
[source,java]
663+
----
664+
@Configuration
665+
public class EchoConfig extends WsConfigurationSupport {
666+
667+
@Override
668+
public void addInterceptors(List<EndpointInterceptor> interceptors) {
669+
interceptors.add(new MyInterceptor());
670+
}
671+
672+
@Bean
673+
@Override
674+
public PayloadRootAnnotationMethodEndpointMapping payloadRootAnnotationMethodEndpointMapping() {
675+
// Create or delegate to "super" to create and
676+
// customize properties of PayloadRootAnnotationMethodEndpointMapping
677+
}
678+
656679
}
657680
----
658681
====
@@ -942,8 +965,8 @@ The concept of configurable endpoint mappings that can optionally contain interc
942965
A lot of supporting functionality can be built into custom `EndpointMapping` implementations.
943966
For example, a custom endpoint mapping could choose an endpoint based not only on the contents of a message but also on a specific SOAP header (or, indeed, multiple SOAP headers).
944967

945-
Most endpoint mappings inherit from the `AbstractEndpointMapping`, which offers an '`interceptors`' property, which is the list of interceptors to use. `EndpointInterceptors` are discussed in <<server-endpoint-interceptor>>.
946-
Additionally, there is the `defaultEndpoint`, which is the default endpoint to use when this endpoint mapping does not result in a matching endpoint.
968+
Most endpoint mappings inherit from the `AbstractEndpointMapping`, which offers an '`interceptors`' property, which is the list of interceptors to use.
969+
`EndpointInterceptors` are discussed in <<server-endpoint-interceptor>>.
947970

948971
As explained in <<server-endpoints>>, the `@Endpoint` style lets you handle multiple requests in one endpoint class.
949972
This is the responsibility of the `MethodEndpointMapping`.
@@ -957,6 +980,8 @@ Whenever a message comes in with this qualified name for the payload root elemen
957980
Alternatively, the `SoapActionAnnotationMethodEndpointMapping` uses the `@SoapAction` annotation to mark methods with a particular SOAP Action.
958981
Whenever a message comes in with this `SOAPAction` header, the method is invoked.
959982

983+
`AbstractEndpointMapping` implementations provides a `defaultEndpoint` property that configures the endpoint to use when a configured mapping does not result in a matching endpoint.
984+
960985
[[server-ws-addressing]]
961986
=== WS-Addressing
962987

0 commit comments

Comments
 (0)