From 04aab9f6b02abf27fb9d461aae7fb5e8c41938a8 Mon Sep 17 00:00:00 2001 From: Arjen Poutsma Date: Tue, 22 Mar 2011 12:00:30 +0000 Subject: [PATCH] SWS-691 - Annotation-driven tag does not support ws-addressing @Action --- .../AnnotationDrivenBeanDefinitionParser.java | 6 +++++ .../AbstractAddressingEndpointMapping.java | 26 ++++++++++++++++--- .../AnnotationActionEndpointMapping.java | 12 ++++----- ...otationDrivenBeanDefinitionParserTest.java | 4 ++- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java b/core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java index f0df99a0..ff85422b 100644 --- a/core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java +++ b/core/src/main/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParser.java @@ -39,6 +39,7 @@ import org.springframework.ws.server.endpoint.adapter.method.dom.XomPayloadMetho import org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPayloadMethodProcessor; import org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor; import org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping; +import org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping; import org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver; import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping; @@ -92,6 +93,11 @@ class AnnotationDrivenBeanDefinitionParser implements BeanDefinitionParser { createBeanDefinition(SoapActionAnnotationMethodEndpointMapping.class, source); soapActionMappingDef.getPropertyValues().add("order", 1); parserContext.getReaderContext().registerWithGeneratedName(soapActionMappingDef); + + RootBeanDefinition annActionMappingDef = + createBeanDefinition(AnnotationActionEndpointMapping.class, source); + annActionMappingDef.getPropertyValues().add("order", 2); + parserContext.getReaderContext().registerWithGeneratedName(annActionMappingDef); } private void registerEndpointAdapters(Element element, Object source, ParserContext parserContext) { diff --git a/core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java b/core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java index 3dd6dea1..208c0e87 100644 --- a/core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java +++ b/core/src/main/java/org/springframework/ws/soap/addressing/server/AbstractAddressingEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -22,6 +22,7 @@ import java.util.Iterator; import javax.xml.transform.TransformerException; import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.Ordered; import org.springframework.util.Assert; import org.springframework.ws.context.MessageContext; import org.springframework.ws.server.EndpointInterceptor; @@ -63,7 +64,7 @@ import org.springframework.xml.transform.TransformerObjectSupport; * @since 1.5.0 */ public abstract class AbstractAddressingEndpointMapping extends TransformerObjectSupport - implements SoapEndpointMapping, InitializingBean { + implements SoapEndpointMapping, InitializingBean, Ordered { private String[] actorsOrRoles; @@ -79,6 +80,9 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec private EndpointInterceptor[] postInterceptors = new EndpointInterceptor[0]; + private int order = Integer.MAX_VALUE; // default: same as non-Ordered + + /** Protected constructor. Initializes the default settings. */ protected AbstractAddressingEndpointMapping() { initDefaultStrategies(); @@ -108,6 +112,22 @@ public abstract class AbstractAddressingEndpointMapping extends TransformerObjec this.isUltimateReceiver = ultimateReceiver; } + public final int getOrder() { + return order; + } + + /** + * Specify the order value for this mapping. + *

+ * Default value is {@link Integer#MAX_VALUE}, meaning that it's non-ordered. + * + * @see org.springframework.core.Ordered#getOrder() + */ + public final void setOrder(int order) { + this.order = order; + } + + /** * Set additional interceptors to be applied before the implicit WS-Addressing interceptor, e.g. * XwsSecurityInterceptor. diff --git a/core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java b/core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java index 97a4233f..dd9a3a87 100644 --- a/core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java +++ b/core/src/main/java/org/springframework/ws/soap/addressing/server/AnnotationActionEndpointMapping.java @@ -1,11 +1,11 @@ /* - * Copyright 2005-2010 the original author or authors. + * Copyright 2005-2011 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -33,8 +33,8 @@ import org.springframework.ws.soap.addressing.server.annotation.Action; import org.springframework.ws.soap.addressing.server.annotation.Address; /** - * Implementation of the {@link org.springframework.ws.server.EndpointMapping} interface that uses the {@link Action} - * annotation to map methods to a WS-Addressing Action header. + * Implementation of the {@link org.springframework.ws.server.EndpointMapping} interface that uses the + * {@link Action @Action} annotation to map methods to a WS-Addressing {@code Action} header. *

* Endpoints typically have the following form: *

@@ -48,9 +48,9 @@ import org.springframework.ws.soap.addressing.server.annotation.Address;
  * }
  * 
*

- * If set, the {@link Address} annotation on the endpoint class should be equal to the {@link + * If set, the {@link Address @Address} annotation on the endpoint class should be equal to the {@link * org.springframework.ws.soap.addressing.core.MessageAddressingProperties#getTo() destination} property of the - * incominging message. + * incoming message. * * @author Arjen Poutsma * @see Action diff --git a/core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java b/core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java index 5c3596b5..23c4c1a0 100644 --- a/core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java +++ b/core/src/test/java/org/springframework/ws/config/AnnotationDrivenBeanDefinitionParserTest.java @@ -38,6 +38,7 @@ import org.springframework.ws.server.endpoint.adapter.method.dom.XomPayloadMetho import org.springframework.ws.server.endpoint.adapter.method.jaxb.JaxbElementPayloadMethodProcessor; import org.springframework.ws.server.endpoint.adapter.method.jaxb.XmlRootElementPayloadMethodProcessor; import org.springframework.ws.server.endpoint.mapping.PayloadRootAnnotationMethodEndpointMapping; +import org.springframework.ws.soap.addressing.server.AnnotationActionEndpointMapping; import org.springframework.ws.soap.server.endpoint.adapter.method.SoapMethodArgumentResolver; import org.springframework.ws.soap.server.endpoint.mapping.SoapActionAnnotationMethodEndpointMapping; @@ -63,9 +64,10 @@ public class AnnotationDrivenBeanDefinitionParserTest { @Test public void endpointMappings() { Map result = applicationContext.getBeansOfType(EndpointMapping.class); - assertEquals("invalid amount of endpoint mappings found", 2, result.size()); + assertEquals("invalid amount of endpoint mappings found", 3, result.size()); assertContainsInstanceOf(result.values(), PayloadRootAnnotationMethodEndpointMapping.class); assertContainsInstanceOf(result.values(), SoapActionAnnotationMethodEndpointMapping.class); + assertContainsInstanceOf(result.values(), AnnotationActionEndpointMapping.class); } @Test