Skip to content

Commit 5d5bd57

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

File tree

2 files changed

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

2 files changed

+65
-37
lines changed

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

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,68 +22,71 @@
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
41+
* individual methods, for example:
4442
*
4543
* <pre><code class='java'>
4644
* &#064;Configuration
4745
* &#064;EnableWs
48-
* &#064;ComponentScan(basePackageClasses = { MyConfiguration.class })
46+
* &#064;ComponentScan(basePackageClasses = MyConfiguration.class)
4947
* public class MyConfiguration extends WsConfigurerAdapter {
5048
*
51-
* &#064;Override
52-
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
53-
* interceptors.add(new MyInterceptor());
54-
* }
49+
* &#064;Override
50+
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
51+
* interceptors.add(new MyInterceptor());
52+
* }
5553
*
56-
* &#064;Override
57-
* public void addArgumentResolvers(List&lt;MethodArgumentResolver&gt; argumentResolvers) {
58-
* argumentResolvers.add(new MyArgumentResolver());
59-
* }
54+
* &#064;Override
55+
* public void addArgumentResolvers(List&lt;MethodArgumentResolver&gt; argumentResolvers) {
56+
* argumentResolvers.add(new MyArgumentResolver());
57+
* }
6058
*
61-
* // More overridden methods ...
6259
* }</code></pre>
6360
* <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:
61+
* <strong>Note:</strong> only one {@code @Configuration} class may have the
62+
* {@code @EnableWs} annotation to import the Spring Web Services configuration. There can
63+
* however be multiple {@code @Configuration} classes implementing {@code WsConfigurer} in
64+
* order to customize the provided configuration.
65+
* <p>
66+
* If {@link WsConfigurer} does not expose some more advanced setting that needs to be
67+
* configured, consider removing the {@code @EnableWs} annotation and extending directly
68+
* from {@link WsConfigurationSupport} or {@link DelegatingWsConfiguration}, for example:
6769
*
6870
* <pre><code class='java'>
6971
* &#064;Configuration
7072
* &#064;ComponentScan(basePackageClasses = { MyConfiguration.class })
7173
* public class MyConfiguration extends WsConfigurationSupport {
7274
*
73-
* &#064;Override
74-
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
75-
* interceptors.add(new MyInterceptor());
76-
* }
75+
* &#064;Override
76+
* public void addInterceptors(List&lt;EndpointInterceptor&gt; interceptors) {
77+
* interceptors.add(new MyInterceptor());
78+
* }
7779
*
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-
* }
80+
* &#064;Bean
81+
* &#064;Override
82+
* public PayloadRootAnnotationMethodEndpointMapping payloadRootAnnotationMethodEndpointMapping() {
83+
* // Create or delegate to "super" to create and
84+
* // customize properties of PayloadRootAnnotationMethodEndpointMapping
85+
* }
8486
* }</code></pre>
8587
*
8688
* @author Arjen Poutsma
89+
* @author Stephane Nicoll
8790
* @since 2.2
8891
* @see WsConfigurer
8992
* @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)