[jbossws-commits] JBossWS SVN: r12931 - in stack/cxf/trunk/modules/client: src/main/java/org/jboss/wsf/stack/cxf/client and 1 other directory.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Wed Sep 8 06:20:14 EDT 2010


Author: richard.opalka at jboss.com
Date: 2010-09-08 06:20:13 -0400 (Wed, 08 Sep 2010)
New Revision: 12931

Modified:
   stack/cxf/trunk/modules/client/pom.xml
   stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
   stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
Log:
[JBWS-3122] implementing @WebServiceRef with @Addressing feature

Modified: stack/cxf/trunk/modules/client/pom.xml
===================================================================
--- stack/cxf/trunk/modules/client/pom.xml	2010-09-08 09:58:59 UTC (rev 12930)
+++ stack/cxf/trunk/modules/client/pom.xml	2010-09-08 10:20:13 UTC (rev 12931)
@@ -231,6 +231,37 @@
   <build>
     <plugins>
       <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <showDeprecation>false</showDeprecation>
+          <compilerArguments>
+            <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
+          </compilerArguments>
+        </configuration>
+      </plugin>
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>generate-sources</phase>
+            <goals>
+              <goal>copy</goal>
+            </goals>
+            <configuration>
+              <artifactItems>
+                <artifactItem>
+                  <groupId>org.jboss.spec.javax.xml.ws</groupId>
+                  <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
+                  <type>jar</type>
+                  <overWrite>true</overWrite>
+                  <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+                </artifactItem>
+              </artifactItems>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
         <artifactId>maven-jar-plugin</artifactId>
         <dependencies>
            <dependency>

Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java	2010-09-08 09:58:59 UTC (rev 12930)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java	2010-09-08 10:20:13 UTC (rev 12931)
@@ -38,6 +38,8 @@
 import javax.naming.spi.ObjectFactory;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceFeature;
+import javax.xml.ws.soap.AddressingFeature;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
@@ -139,6 +141,20 @@
          // Receives either a javax.xml.ws.Service or a dynamic proxy
          Object target;
 
+         // configure addressing
+         AddressingFeature addressingFeature = null;
+         if (serviceRef.isAddressingEnabled()) {
+            final boolean enabled = serviceRef.isAddressingEnabled();
+            final boolean required = serviceRef.isAddressingRequired();
+            final String refResponses = serviceRef.getAddressingResponses();
+            AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
+            if ("ANONYMOUS".equals(refResponses))
+               responses = AddressingFeature.Responses.ANONYMOUS;
+            if ("NON_ANONYMOUS".equals(refResponses))
+               responses = AddressingFeature.Responses.NON_ANONYMOUS;
+            addressingFeature = new AddressingFeature(enabled, required, responses);
+         }
+
          // Get the URL to the wsdl
          URL wsdlURL = serviceRef.getWsdlLocation();
 
@@ -147,7 +163,11 @@
          {
             if (wsdlURL != null)
             {
-               target = Service.create(wsdlURL, serviceQName);
+               if (addressingFeature != null) {
+                  target = Service.create(wsdlURL, serviceQName, new WebServiceFeature[] { addressingFeature });
+               } else {
+                  target = Service.create(wsdlURL, serviceQName);
+               }
             }
             else
             {
@@ -159,12 +179,22 @@
          {
             if (wsdlURL != null)
             {
-               Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class, QName.class });
-               target = ctor.newInstance(new Object[] { wsdlURL, serviceQName });
+               if (addressingFeature != null) {
+                  Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class, QName.class, WebServiceFeature[].class });
+                  target = ctor.newInstance(new Object[] { wsdlURL, serviceQName, new WebServiceFeature[] { addressingFeature } });
+               } else {
+                  Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class, QName.class });
+                  target = ctor.newInstance(new Object[] { wsdlURL, serviceQName });
+               }
             }
             else
             {
-               target = (Service)serviceClass.newInstance();
+               if (addressingFeature != null) {
+                  Constructor ctor = serviceClass.getConstructor(new Class[] { WebServiceFeature[].class });
+                  target = ctor.newInstance(new Object[] { new WebServiceFeature[] { addressingFeature } });
+               } else {
+                  target = (Service)serviceClass.newInstance();
+               }
             }
          }
 

Modified: stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java
===================================================================
--- stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java	2010-09-08 09:58:59 UTC (rev 12930)
+++ stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java	2010-09-08 10:20:13 UTC (rev 12931)
@@ -39,6 +39,8 @@
 import javax.xml.ws.WebServiceClient;
 import javax.xml.ws.WebServiceRef;
 import javax.xml.ws.WebServiceRefs;
+import javax.xml.ws.soap.Addressing;
+import javax.xml.ws.soap.AddressingFeature;
 
 import org.jboss.logging.Logger;
 import org.jboss.util.naming.Util;
@@ -65,11 +67,15 @@
 
       // Build the list of @WebServiceRef relevant annotations
       List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
+      Addressing addressing = null;
 
       if (anElement != null)
       {
          for (Annotation an : anElement.getAnnotations())
          {
+            if (an instanceof Addressing)
+               addressing = (Addressing)an;
+            
             if (an instanceof WebServiceRef)
                wsrefList.add((WebServiceRef)an);
 
@@ -82,6 +88,22 @@
          }
       }
 
+      if (addressing != null)
+      {
+         if (addressing.enabled())
+            serviceRef.setAddressingEnabled();
+         
+         if (addressing.required())
+            serviceRef.setAddressingRequired();
+         
+         if (addressing.responses() == AddressingFeature.Responses.ANONYMOUS)
+            serviceRef.setAddressingResponses("ANONYMOUS");
+         else if (addressing.responses() == AddressingFeature.Responses.NON_ANONYMOUS)
+            serviceRef.setAddressingResponses("NON_ANONYMOUS");
+         else 
+            serviceRef.setAddressingResponses("ALL");
+      }
+
       // Use the single @WebServiceRef
       if (wsrefList.size() == 1)
       {
@@ -121,7 +143,7 @@
       String serviceImplClass = null;
 
       // #1 Use the explicit @WebServiceRef.value
-      if (wsref != null && wsref.value() != Object.class && wsref.value() != Service.class)
+      if (wsref != null && wsref.value() != Service.class)
          serviceImplClass = wsref.value().getName();
 
       // #2 Use the target ref type



More information about the jbossws-commits mailing list