アノテーションインターフェース EnableWs
@RetentionSE(RUNTIMESE)
@TargetSE(TYPESE)
@DocumentedSE
@Import(DelegatingWsConfiguration.class)
public @interface EnableWs
このアノテーションを
@Configuration クラスに追加すると、WsConfigurationSupport から Spring Web Services 構成がインポートされます。例:@Configuration
@EnableWs
@ComponentScan(basePackageClasses = MyConfiguration.class)
public class MyConfiguration {
} インポートした設定をカスタマイズするには、WsConfigurer インターフェースを実装し、個々のメソッドをオーバーライドします。
@Configuration
@EnableWs
@ComponentScan(basePackageClasses = MyConfiguration.class)
public class MyConfiguration implements WsConfigurer {
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {
interceptors.add(new MyInterceptor());
}
@Override
public void addArgumentResolvers(List<MethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new MyArgumentResolver());
}
} 注意 : Spring Web Services 設定をインポートするために、@EnableWs アノテーションを持つことができる @Configuration クラスは 1 つだけです。ただし、提供された設定をカスタマイズするために、WsConfigurer を実装した @Configuration クラスは複数存在できます。
WsConfigurer が、構成する必要があるより高度な設定を公開していない場合は、@EnableWs アノテーションを削除し、WsConfigurationSupport または DelegatingWsConfiguration から直接拡張することを検討してください。例:
@Configuration
@ComponentScan(basePackageClasses = { MyConfiguration.class })
public class MyConfiguration extends WsConfigurationSupport {
@Override
public void addInterceptors(List<EndpointInterceptor> interceptors) {
interceptors.add(new MyInterceptor());
}
@Bean
@Override
public PayloadRootAnnotationMethodEndpointMapping payloadRootAnnotationMethodEndpointMapping() {
// Create or delegate to "super" to create and
// customize properties of PayloadRootAnnotationMethodEndpointMapping
}
}- 導入:
- 2.2
- 関連事項: