Author: richard.opalka(a)jboss.com
Date: 2010-09-13 08:34:26 -0400 (Mon, 13 Sep 2010)
New Revision: 12961
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/ServiceRefBinderJAXWS.java
Log:
[JBWS-3122] since now @WebServiceRef respects @Addressing, @MTOM & @RespectBinding
annotations
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-13
12:31:24 UTC (rev 12960)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceObjectFactory.java 2010-09-13
12:34:26 UTC (rev 12961)
@@ -29,6 +29,8 @@
import java.lang.reflect.Method;
import java.net.URL;
import java.util.Hashtable;
+import java.util.LinkedList;
+import java.util.List;
import javax.naming.Context;
import javax.naming.Name;
@@ -37,9 +39,11 @@
import javax.naming.Reference;
import javax.naming.spi.ObjectFactory;
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 org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
@@ -138,13 +142,10 @@
if (Service.class.isAssignableFrom(serviceClass) == false)
throw new IllegalArgumentException("WebServiceRef type '" +
serviceClass + "' is not assignable to javax.xml.ws.Service");
- // Receives either a javax.xml.ws.Service or a dynamic proxy
- Object target;
-
- // configure addressing
- AddressingFeature addressingFeature = null;
+ List<WebServiceFeature> features = new
LinkedList<WebServiceFeature>();
+
+ // 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;
@@ -152,19 +153,31 @@
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 @RespectBinding 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[] {});
// Generic javax.xml.ws.Service
if (serviceClass == Service.class)
{
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);
}
@@ -179,9 +192,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 });
@@ -189,9 +202,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();
}
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-13
12:31:24 UTC (rev 12960)
+++
stack/cxf/trunk/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/ServiceRefBinderJAXWS.java 2010-09-13
12:34:26 UTC (rev 12961)
@@ -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;
@@ -67,17 +69,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)
{
@@ -88,22 +106,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)
{
Show replies by date