[jbossws-commits] JBossWS SVN: r12962 - stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client.

jbossws-commits at lists.jboss.org jbossws-commits at lists.jboss.org
Mon Sep 13 08:35:37 EDT 2010


Author: richard.opalka at jboss.com
Date: 2010-09-13 08:35:37 -0400 (Mon, 13 Sep 2010)
New Revision: 12962

Modified:
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
   stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java
Log:
[JBWS-3122] since now @WebServiceRef respects @Addressing, @MTOM & @RespectBinding annotations

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java	2010-09-13 12:34:26 UTC (rev 12961)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/NativeServiceRefBinderJAXWS.java	2010-09-13 12:35:37 UTC (rev 12962)
@@ -35,12 +35,14 @@
 import javax.naming.NamingException;
 import javax.naming.Referenceable;
 import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBinding;
 import javax.xml.ws.Service;
 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 javax.xml.ws.soap.MTOM;
 
 import org.jboss.logging.Logger;
 import org.jboss.util.naming.Util;
@@ -68,17 +70,33 @@
 
       // Build the list of @WebServiceRef relevant annotations
       List<WebServiceRef> wsrefList = new ArrayList<WebServiceRef>();
-      Addressing addressing = null;
+      Addressing addressingAnnotation = null;
+      MTOM mtomAnnotation = null;
+      RespectBinding respectBindingAnnotation = null;
 
       if (anElement != null)
       {
          for (Annotation an : anElement.getAnnotations())
          {
-            if (an instanceof Addressing)
-               addressing = (Addressing)an;
+            if (an instanceof Addressing) {
+               addressingAnnotation = (Addressing)an;
+               continue;
+            }
             
-            if (an instanceof WebServiceRef)
+            if (an instanceof MTOM) {
+               mtomAnnotation = (MTOM)an;
+               continue;
+            }
+            
+            if (an instanceof RespectBinding) {
+               respectBindingAnnotation = (RespectBinding)an;
+               continue;
+            }
+            
+            if (an instanceof WebServiceRef) {
                wsrefList.add((WebServiceRef)an);
+               continue;
+            }
 
             if (an instanceof WebServiceRefs)
             {
@@ -89,22 +107,31 @@
          }
       }
       
-      if (addressing != null)
+      if (addressingAnnotation != null)
       {
-         if (addressing.enabled())
+         if (addressingAnnotation.enabled())
             serviceRef.setAddressingEnabled();
          
-         if (addressing.required())
+         if (addressingAnnotation.required())
             serviceRef.setAddressingRequired();
          
-         if (addressing.responses() == AddressingFeature.Responses.ANONYMOUS)
+         if (addressingAnnotation.responses() == AddressingFeature.Responses.ANONYMOUS)
             serviceRef.setAddressingResponses("ANONYMOUS");
-         else if (addressing.responses() == AddressingFeature.Responses.NON_ANONYMOUS)
+         else if (addressingAnnotation.responses() == AddressingFeature.Responses.NON_ANONYMOUS)
             serviceRef.setAddressingResponses("NON_ANONYMOUS");
          else 
             serviceRef.setAddressingResponses("ALL");
       }
+      
+      if ((mtomAnnotation != null) && mtomAnnotation.enabled()) {
+         serviceRef.setMtomEnabled();
+         serviceRef.setMtomThreshold(mtomAnnotation.threshold());
+      }
 
+      if ((respectBindingAnnotation != null) && respectBindingAnnotation.enabled()) {
+         serviceRef.setRespectBindingEnabled();
+      }
+
       // Use the single @WebServiceRef
       if (wsrefList.size() == 1)
       {

Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java	2010-09-13 12:34:26 UTC (rev 12961)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ServiceObjectFactoryJAXWS.java	2010-09-13 12:35:37 UTC (rev 12962)
@@ -29,9 +29,11 @@
 
 import javax.naming.*;
 import javax.xml.namespace.QName;
+import javax.xml.ws.RespectBindingFeature;
 import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.MTOMFeature;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -41,6 +43,8 @@
 import java.lang.reflect.Method;
 import java.net.URL;
 import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
 
 /**
  * This ServiceObjectFactory reconstructs a javax.xml.ws.Service
@@ -113,13 +117,10 @@
          if (log.isDebugEnabled())
             log.debug("Loaded Service '" + serviceClass.getName() + "' from: " + serviceClass.getProtectionDomain().getCodeSource());
 
-         // Receives either a javax.xml.ws.Service or a dynamic proxy
-         Object target;
+         List<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
          
-         // configure addressing
-         AddressingFeature addressingFeature = null;
+         // configure addressing feature
          if (serviceRef.isAddressingEnabled()) {
-            final boolean enabled = serviceRef.isAddressingEnabled();
             final boolean required = serviceRef.isAddressingRequired();
             final String refResponses = serviceRef.getAddressingResponses();
             AddressingFeature.Responses responses = AddressingFeature.Responses.ALL;
@@ -127,11 +128,24 @@
                responses = AddressingFeature.Responses.ANONYMOUS;
             if ("NON_ANONYMOUS".equals(refResponses))
                responses = AddressingFeature.Responses.NON_ANONYMOUS;
-            addressingFeature = new AddressingFeature(enabled, required, responses);
+            
+            features.add(new AddressingFeature(true, required, responses));
          }
 
-         // Get the URL to the wsdl
+         // configure MTOM feature
+         if (serviceRef.isMtomEnabled()) {
+            features.add(new MTOMFeature(true, serviceRef.getMtomThreshold()));
+         }
+
+         // configure respect binding feature
+         if (serviceRef.isRespectBindingEnabled()) {
+            features.add(new RespectBindingFeature(true));
+         }
+
+         // Receives either a javax.xml.ws.Service or a dynamic proxy
+         Object target;
          URL wsdlURL = serviceRef.getWsdlLocation();
+         WebServiceFeature[] wsFeatures = features.size() == 0 ? null : features.toArray(new WebServiceFeature[] {});
          try
          {
             // Associate the ServiceRefMetaData with this thread
@@ -142,8 +156,8 @@
             {
                if (wsdlURL != null)
                {
-                  if (addressingFeature != null) {
-                     target = Service.create(wsdlURL, serviceQName, new WebServiceFeature[] { addressingFeature });
+                  if (wsFeatures != null) {
+                     target = Service.create(wsdlURL, serviceQName, wsFeatures);
                   } else {
                      target = Service.create(wsdlURL, serviceQName);
                   }
@@ -158,9 +172,9 @@
             {
                if (wsdlURL != null)
                {
-                  if (addressingFeature != null) {
+                  if (wsFeatures != null) {
                      Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class, QName.class, WebServiceFeature[].class });
-                     target = ctor.newInstance(new Object[] { wsdlURL, serviceQName, new WebServiceFeature[] { addressingFeature } });
+                     target = ctor.newInstance(new Object[] { wsdlURL, serviceQName, wsFeatures });
                   } else {
                      Constructor ctor = serviceClass.getConstructor(new Class[] { URL.class, QName.class });
                      target = ctor.newInstance(new Object[] { wsdlURL, serviceQName });
@@ -168,9 +182,9 @@
                }
                else
                {
-                  if (addressingFeature != null) {
+                  if (wsFeatures != null) {
                      Constructor ctor = serviceClass.getConstructor(new Class[] { WebServiceFeature[].class });
-                     target = ctor.newInstance(new Object[] { new WebServiceFeature[] { addressingFeature } });
+                     target = ctor.newInstance(new Object[] { wsFeatures });
                   } else {
                      target = (Service)serviceClass.newInstance();
                   }



More information about the jbossws-commits mailing list