Author: barrettj
Date: Thu Apr 22 21:24:25 2010
New Revision: 937071
URL: http://svn.apache.org/viewvc?rev=937071&view=rev
Log:
Add support for JAXWS 2.2 Addressing.responses annotation attribute. Add
associated TDD tests. Modify pom.xml to pickup annotations from JAXWS 2.2 jar
instead of the JAXWS 2.1 classes in the JDK.
Modified:
axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml
axis/axis2/java/core/trunk/modules/metadata/pom.xml
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/server/config/AddressingConfigurator.java
axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/feature/AddressingFeatureTests.java
Modified: axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml?rev=937071&r1=937070&r2=937071&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/jaxws-integration/pom.xml Thu Apr 22
21:24:25 2010
@@ -34,6 +34,10 @@
<dependencies>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxws_2.2_spec</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.0_spec</artifactId>
</dependency>
<dependency>
@@ -114,6 +118,28 @@
</testResources>
<plugins>
<plugin>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+
<groupId>org.apache.geronimo.specs</groupId>
+
<artifactId>geronimo-jaxws_2.2_spec</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+
<outputDirectory>target/endorsed</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
@@ -1360,7 +1386,7 @@
<inherited>true</inherited>
<configuration>
<forkMode>pertest</forkMode>
- <argLine>-Xms256m -Xmx512m</argLine>
+ <argLine>-Xms256m -Xmx512m
-Xbootclasspath/p:${basedir}/target/endorsed/geronimo-jaxws_2.2_spec-1.0-SNAPSHOT.jar</argLine>
<!-- Enable the next 2 lines if you want to attach a
debugger
<argLine>-Xdebug -Xnoagent -Djava.compiler=NONE
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006</argLine>-->
<includes>
Modified: axis/axis2/java/core/trunk/modules/metadata/pom.xml
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/pom.xml?rev=937071&r1=937070&r2=937071&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/metadata/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/metadata/pom.xml Thu Apr 22 21:24:25 2010
@@ -143,15 +143,15 @@
<goal>copy</goal>
</goals>
<configuration>
- <artifactItems>
- <artifactItem>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaxws_2.2_spec</artifactId>
- <type>jar</type>
- <overWrite>true</overWrite>
- <outputDirectory>target/endorsed</outputDirectory>
- </artifactItem>
- </artifactItems>
+ <artifactItems>
+ <artifactItem>
+
<groupId>org.apache.geronimo.specs</groupId>
+
<artifactId>geronimo-jaxws_2.2_spec</artifactId>
+ <type>jar</type>
+ <overWrite>true</overWrite>
+
<outputDirectory>target/endorsed</outputDirectory>
+ </artifactItem>
+ </artifactItems>
</configuration>
</execution>
</executions>
@@ -257,6 +257,9 @@
<artifactId>maven-surefire-plugin</artifactId>
<inherited>true</inherited>
<configuration>
+ <argLine>
+
-Xbootclasspath/p:${basedir}/target/endorsed/geronimo-jaxws_2.2_spec-1.0-SNAPSHOT.jar
+ </argLine>
<includes>
<include>**/*Tests.java</include>
</includes>
Modified:
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/server/config/AddressingConfigurator.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/server/config/AddressingConfigurator.java?rev=937071&r1=937070&r2=937071&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/server/config/AddressingConfigurator.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/server/config/AddressingConfigurator.java
Thu Apr 22 21:24:25 2010
@@ -38,6 +38,7 @@ import org.apache.axis2.util.Utils;
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.AddressingFeature.Responses;
/**
* This class will enable/disable WS-Addressing for a JAX-WS 2.1 web service
@@ -62,6 +63,7 @@ public class AddressingConfigurator impl
Parameter namespace = new
Parameter(AddressingConstants.WS_ADDRESSING_VERSION, null);
Parameter disabled = new
Parameter(AddressingConstants.DISABLE_ADDRESSING_FOR_IN_MESSAGES, "false");
Parameter required = new
Parameter(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER,
AddressingConstants.ADDRESSING_UNSPECIFIED);
+ Parameter responses = null;
if (addressing != null && submissionAddressing != null) {
//Both annotations must have been specified.
@@ -127,11 +129,21 @@ public class AddressingConfigurator impl
Messages.getMessage("NoWSAddressingFeatures"));
}
+ // If the Addressing annotation was used, then get the responses value
from it and map it to the
+ // value the addressing handler expects
+ if (addressing != null) {
+ responses = new
Parameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME,
+ mapResponseAttributeToAddressing(addressing.responses()));
+ }
+
try {
AxisService service = endpointDescription.getAxisService();
service.addParameter(namespace);
service.addParameter(disabled);
service.addParameter(required);
+ if (responses != null) {
+ service.addParameter(responses);
+ }
String value = Utils.getParameterValue(disabled);
if (JavaUtils.isFalseExplicitly(value)) {
@@ -147,6 +159,29 @@ public class AddressingConfigurator impl
}
}
+ /**
+ * Given a value for the Addressing.responses annotation attribute, map it
to the corresponding
+ * Addressing constant to be set on the AxisSservice
+ *
+ * @param responses Enum value from the Addressing.responses annotation
attribute
+ * @return String from AddressingContstants corresponding to the responses
value.
+ */
+ static private String mapResponseAttributeToAddressing(Responses
responses) {
+ String addressingType = null;
+ switch (responses) {
+ case ALL:
+ addressingType =
AddressingConstants.WSAM_INVOCATION_PATTERN_BOTH;
+ break;
+ case ANONYMOUS:
+ addressingType =
AddressingConstants.WSAM_INVOCATION_PATTERN_SYNCHRONOUS;
+ break;
+ case NON_ANONYMOUS:
+ addressingType =
AddressingConstants.WSAM_INVOCATION_PATTERN_ASYNCHRONOUS;
+ break;
+ }
+ return addressingType;
+ }
+
/*
* (non-Javadoc)
* @see
org.apache.axis2.jaxws.feature.ServerConfigurator#supports(java.lang.String)
Modified:
axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/feature/AddressingFeatureTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/feature/AddressingFeatureTests.java?rev=937071&r1=937070&r2=937071&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/feature/AddressingFeatureTests.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/test/org/apache/axis2/jaxws/description/feature/AddressingFeatureTests.java
Thu Apr 22 21:24:25 2010
@@ -21,6 +21,7 @@ package org.apache.axis2.jaxws.descripti
import junit.framework.TestCase;
import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.jaxws.addressing.SubmissionAddressing;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.Parameter;
import org.apache.axis2.jaxws.description.DescriptionFactory;
@@ -31,6 +32,7 @@ import org.apache.axis2.util.Utils;
import javax.jws.WebService;
import javax.xml.namespace.QName;
import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.AddressingFeature.Responses;
public class AddressingFeatureTests extends TestCase {
@@ -40,6 +42,10 @@ public class AddressingFeatureTests exte
private static final String plainServicePortName = "PlainServicePort";
private static final String disabledServicePortName =
"DisabledServicePort";
private static final String requiredServicePortName =
"RequiredServicePort";
+ private static final String responsesALLServicePortName =
"ResponsesALLServicePort";
+ private static final String responsesANONServicePortName =
"ResponsesANONServicePort";
+ private static final String responsesNONANONServicePortName =
"ResponsesNONANONServicePort";
+ private static final String responsesNoAddressingServicePortName =
"ResponsesNoAddressingServicePort";
public void testNoAnnotation() {
ServiceDescription sd =
DescriptionFactory.createServiceDescription(DefaultService.class);
@@ -113,6 +119,84 @@ public class AddressingFeatureTests exte
assertEquals(AddressingConstants.ADDRESSING_REQUIRED, required);
}
+ /**
+ * Validate that annotation value Addressing.responses=ALL is set
correctly on the AxisService
+ */
+ public void testResponsesALL() {
+ ServiceDescription sd =
DescriptionFactory.createServiceDescription(ResponsesALLService.class);
+ EndpointDescription ed = sd.getEndpointDescription(new QName(ns,
responsesALLServicePortName));
+ assertNotNull(ed);
+
+ AxisService axisService = ed.getAxisService();
+ Parameter responsesParam =
axisService.getParameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME);
+ assertNotNull("Responses parameter not set", responsesParam);
+
+ String responsesType = Utils.getParameterValue(responsesParam);
+ assertEquals("Wrong type of responses returned",
AddressingConstants.WSAM_INVOCATION_PATTERN_BOTH, responsesType);
+ }
+
+ /**
+ * Validate that annotation value Addressing.responses=ANONYMOUS is set
correctly on the AxisService
+ */
+ public void testResponsesANON() {
+ ServiceDescription sd =
DescriptionFactory.createServiceDescription(ResponsesANONService.class);
+ EndpointDescription ed = sd.getEndpointDescription(new QName(ns,
responsesANONServicePortName));
+ assertNotNull(ed);
+
+ AxisService axisService = ed.getAxisService();
+ Parameter responsesParam =
axisService.getParameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME);
+ assertNotNull("Responses parameter not set", responsesParam);
+
+ String responsesType = Utils.getParameterValue(responsesParam);
+ assertEquals("Wrong type of responses returned",
AddressingConstants.WSAM_INVOCATION_PATTERN_SYNCHRONOUS, responsesType);
+ }
+
+ /**
+ * Validate that annotation value Addressing.responses=NON_ANONYMOUS is
set correctly on the AxisService
+ */
+ public void testResponsesNONANON() {
+ ServiceDescription sd =
DescriptionFactory.createServiceDescription(ResponsesNONANONService.class);
+ EndpointDescription ed = sd.getEndpointDescription(new QName(ns,
responsesNONANONServicePortName));
+ assertNotNull(ed);
+
+ AxisService axisService = ed.getAxisService();
+ Parameter responsesParam =
axisService.getParameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME);
+ assertNotNull("Responses parameter not set", responsesParam);
+
+ String responsesType = Utils.getParameterValue(responsesParam);
+ assertEquals("Wrong type of responses returned",
AddressingConstants.WSAM_INVOCATION_PATTERN_ASYNCHRONOUS, responsesType);
+ }
+
+ /**
+ * Validate that no annotation for Addressing does not set the associated
addressing parameter on the AxisService
+ */
+ public void testResponsesNoAddressing() {
+ ServiceDescription sd =
DescriptionFactory.createServiceDescription(ResponsesNoAddressingService.class);
+ EndpointDescription ed = sd.getEndpointDescription(new QName(ns,
responsesNoAddressingServicePortName));
+ assertNotNull(ed);
+
+ AxisService axisService = ed.getAxisService();
+ Parameter responsesParam =
axisService.getParameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME);
+ assertNull("Responses parameter was set", responsesParam);
+
+ }
+
+ /**
+ * Validate that annotation Addressing with no responses attribute
explicitly set gets the correct default on the AxisService
+ */
+ public void testResponsesDefault() {
+ ServiceDescription sd =
DescriptionFactory.createServiceDescription(PlainService.class);
+ EndpointDescription ed = sd.getEndpointDescription(new QName(ns,
plainServicePortName));
+ assertNotNull(ed);
+
+ AxisService axisService = ed.getAxisService();
+ Parameter responsesParam =
axisService.getParameter(AddressingConstants.WSAM_INVOCATION_PATTERN_PARAMETER_NAME);
+ assertNotNull("Responses parameter not set", responsesParam);
+
+ String responsesType = Utils.getParameterValue(responsesParam);
+ assertEquals("Wrong type of responses returned",
AddressingConstants.WSAM_INVOCATION_PATTERN_BOTH, responsesType);
+ }
+
@WebService(targetNamespace=ns, portName=defaultServicePortName)
class DefaultService {
public double getQuote(String symbol) {
@@ -143,4 +227,36 @@ public class AddressingFeatureTests exte
return 101.01;
}
}
+
+ @WebService(targetNamespace=ns, portName=responsesALLServicePortName)
+ @Addressing(required=true, responses=Responses.ALL)
+ class ResponsesALLService {
+ public double getQuote(String symbol) {
+ return 101.01;
+ }
+ }
+
+ @WebService(targetNamespace=ns, portName=responsesANONServicePortName)
+ @Addressing(required=true, responses=Responses.ANONYMOUS)
+ class ResponsesANONService {
+ public double getQuote(String symbol) {
+ return 101.01;
+ }
+ }
+
+ @WebService(targetNamespace=ns, portName=responsesNONANONServicePortName)
+ @Addressing(required=true, responses=Responses.NON_ANONYMOUS)
+ class ResponsesNONANONService {
+ public double getQuote(String symbol) {
+ return 101.01;
+ }
+ }
+
+ @WebService(targetNamespace=ns,
portName=responsesNoAddressingServicePortName)
+ @SubmissionAddressing(required=true)
+ class ResponsesNoAddressingService {
+ public double getQuote(String symbol) {
+ return 101.01;
+ }
+ }
}