Author: alessio.soldano(a)jboss.com
Date: 2009-01-15 11:25:19 -0500 (Thu, 15 Jan 2009)
New Revision: 9051
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java
Log:
[JBWS-2449] @RespectBinding and RespectBindingFeature support
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java 2009-01-15
16:15:20 UTC (rev 9050)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/core/jaxws/client/ClientFeatureProcessor.java 2009-01-15
16:25:19 UTC (rev 9051)
@@ -24,15 +24,26 @@
import java.util.List;
import javax.xml.ws.BindingProvider;
+import javax.xml.ws.RespectBindingFeature;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.handler.Handler;
import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.soap.MTOMFeature;
import javax.xml.ws.soap.SOAPBinding;
+import org.jboss.logging.Logger;
import org.jboss.ws.core.jaxws.binding.BindingExt;
import org.jboss.ws.extensions.addressing.jaxws.WSAddressingClientHandler;
import org.jboss.ws.metadata.umdm.EndpointMetaData;
+import org.jboss.ws.metadata.umdm.ServiceMetaData;
+import org.jboss.ws.metadata.wsdl.Extendable;
+import org.jboss.ws.metadata.wsdl.WSDLBinding;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
+import org.jboss.ws.metadata.wsdl.WSDLService;
+import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
/**
@@ -44,11 +55,14 @@
*/
public class ClientFeatureProcessor
{
+ private static Logger log = Logger.getLogger(ClientFeatureProcessor.class);
+
public static <T> void processFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
{
epMetaData.addFeature(feature);
processAddressingFeature(feature, epMetaData, stub);
processMTOMFeature(feature, epMetaData, stub);
+ processRespectBindingFeature(feature, epMetaData, stub);
}
@SuppressWarnings("unchecked")
@@ -71,5 +85,44 @@
binding.setMTOMEnabled(feature.isEnabled());
}
}
+
+ private static <T> void processRespectBindingFeature(WebServiceFeature feature,
EndpointMetaData epMetaData, T stub)
+ {
+ if (feature instanceof RespectBindingFeature && feature.isEnabled())
+ {
+ ServiceMetaData serviceMetaData = epMetaData.getServiceMetaData();
+ WSDLDefinitions wsdlDefinitions = serviceMetaData.getWsdlDefinitions();
+
+ WSDLService wsdlService =
wsdlDefinitions.getService(serviceMetaData.getServiceName());
+ if (wsdlService != null)
+ {
+ WSDLEndpoint wsdlEndpoint =
wsdlService.getEndpoint(epMetaData.getPortName());
+ if (wsdlEndpoint != null)
+ {
+ checkNotUnderstoodExtElements(wsdlEndpoint, epMetaData);
+ WSDLBinding wsdlBinding =
wsdlDefinitions.getBinding(wsdlEndpoint.getBinding());
+ checkNotUnderstoodExtElements(wsdlBinding, epMetaData);
+ }
+ else
+ {
+ log.warn("Cannot find port " + epMetaData.getPortName());
+ }
+ }
+ }
+ }
+
+ private static void checkNotUnderstoodExtElements(Extendable extendable,
EndpointMetaData epMetaData)
+ {
+ List<WSDLExtensibilityElement> notUnderstoodList =
extendable.getNotUnderstoodExtElements();
+ for (WSDLExtensibilityElement el : notUnderstoodList)
+ {
+ boolean disabledByFeature = false; //TODO
+ if (el.isRequired() && !disabledByFeature)
+ {
+ String s = DOMWriter.printNode(el.getElement(), true);
+ throw new WebServiceException("RespectBindingFeature enabled and a
required not understood element was found: " + s);
+ }
+ }
+ }
}
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java 2009-01-15
16:15:20 UTC (rev 9050)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/EndpointFeatureProcessor.java 2009-01-15
16:25:19 UTC (rev 9051)
@@ -24,7 +24,11 @@
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.net.URL;
+import java.util.List;
+import javax.xml.ws.RespectBinding;
+import javax.xml.ws.RespectBindingFeature;
+import javax.xml.ws.WebServiceException;
import javax.xml.ws.soap.Addressing;
import javax.xml.ws.soap.AddressingFeature;
import javax.xml.ws.soap.MTOM;
@@ -42,6 +46,15 @@
import org.jboss.ws.feature.SchemaValidationFeature;
import org.jboss.ws.metadata.umdm.HandlerMetaDataJAXWS;
import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
+import org.jboss.ws.metadata.umdm.ServiceMetaData;
+import org.jboss.ws.metadata.wsdl.Extendable;
+import org.jboss.ws.metadata.wsdl.WSDLBinding;
+import org.jboss.ws.metadata.wsdl.WSDLDefinitions;
+import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
+import org.jboss.ws.metadata.wsdl.WSDLExtensibilityElement;
+import org.jboss.ws.metadata.wsdl.WSDLService;
+import org.jboss.wsf.common.DOMUtils;
+import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Deployment;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
@@ -89,6 +102,12 @@
JsonEncodingFeature feature = new JsonEncodingFeature(anFeature.enabled());
sepMetaData.addFeature(feature);
}
+ else if (an.annotationType() == RespectBinding.class)
+ {
+ RespectBinding anFeature = sepClass.getAnnotation(RespectBinding.class);
+ RespectBindingFeature feature = new
RespectBindingFeature(anFeature.enabled());
+ sepMetaData.addFeature(feature);
+ }
}
}
@@ -96,6 +115,7 @@
{
setupAddressingFeature(sepMetaData);
setupMTOMFeature(sepMetaData);
+ setupRespectBindingFeature(sepMetaData); //this need to be processed last
}
private static void setupAddressingFeature(ServerEndpointMetaData sepMetaData)
@@ -131,6 +151,47 @@
}
}
}
+
+ private static void setupRespectBindingFeature(ServerEndpointMetaData sepMetaData)
+ {
+ RespectBindingFeature respectBindingFeature =
sepMetaData.getFeature(RespectBindingFeature.class);
+ if (respectBindingFeature != null && respectBindingFeature.isEnabled())
+ {
+ log.debug("RespectBindingFeature found, looking for required not understood
extensibility elements...");
+ ServiceMetaData serviceMetaData = sepMetaData.getServiceMetaData();
+ WSDLDefinitions wsdlDefinitions = serviceMetaData.getWsdlDefinitions();
+
+ WSDLService wsdlService =
wsdlDefinitions.getService(serviceMetaData.getServiceName());
+ if (wsdlService != null)
+ {
+ WSDLEndpoint wsdlEndpoint =
wsdlService.getEndpoint(sepMetaData.getPortName());
+ if (wsdlEndpoint != null)
+ {
+ checkNotUnderstoodExtElements(wsdlEndpoint, sepMetaData);
+ WSDLBinding wsdlBinding =
wsdlDefinitions.getBinding(wsdlEndpoint.getBinding());
+ checkNotUnderstoodExtElements(wsdlBinding, sepMetaData);
+ }
+ else
+ {
+ log.warn("Cannot find port " + sepMetaData.getPortName());
+ }
+ }
+ }
+ }
+
+ private static void checkNotUnderstoodExtElements(Extendable extendable,
ServerEndpointMetaData sepMetaData)
+ {
+ List<WSDLExtensibilityElement> notUnderstoodList =
extendable.getNotUnderstoodExtElements();
+ for (WSDLExtensibilityElement el : notUnderstoodList)
+ {
+ boolean disabledByFeature = false; //TODO
+ if (el.isRequired() && !disabledByFeature)
+ {
+ String s = DOMWriter.printNode(el.getElement(), true);
+ throw new WebServiceException("RespectBindingFeature enabled and a
required not understood element was found: " + s);
+ }
+ }
+ }
private void processSchemaValidation(Deployment dep, ServerEndpointMetaData
sepMetaData, Class<?> sepClass)
{
Modified:
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java
===================================================================
---
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java 2009-01-15
16:15:20 UTC (rev 9050)
+++
stack/native/branches/jaxws21/modules/core/src/main/java/org/jboss/ws/metadata/wsdl/Extendable.java 2009-01-15
16:25:19 UTC (rev 9051)
@@ -44,7 +44,7 @@
private Map features = new LinkedHashMap();
private Map properties = new LinkedHashMap();
private Map<String,List<WSDLExtensibilityElement>> extElements = new
LinkedHashMap<String,List<WSDLExtensibilityElement>>();
- private List<WSDLExtensibilityElement> notUnderstoodExtElement = new
LinkedList<WSDLExtensibilityElement>();
+ private List<WSDLExtensibilityElement> notUnderstoodExtElements = new
LinkedList<WSDLExtensibilityElement>();
public WSDLFeature[] getFeatures()
{
@@ -115,18 +115,18 @@
return list;
}
- public List<WSDLExtensibilityElement> getNotUnderstoodExtElement()
+ public List<WSDLExtensibilityElement> getNotUnderstoodExtElements()
{
- return notUnderstoodExtElement;
+ return notUnderstoodExtElements;
}
- public void setNotUnderstoodExtElement(List<WSDLExtensibilityElement>
notUnderstoodExtElement)
+ public void setNotUnderstoodExtElements(List<WSDLExtensibilityElement>
notUnderstoodExtElement)
{
- this.notUnderstoodExtElement = notUnderstoodExtElement;
+ this.notUnderstoodExtElements = notUnderstoodExtElement;
}
public void addNotUnderstoodExtElement(WSDLExtensibilityElement element)
{
- notUnderstoodExtElement.add(element);
+ notUnderstoodExtElements.add(element);
}
}
Modified:
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java
===================================================================
---
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java 2009-01-15
16:15:20 UTC (rev 9050)
+++
stack/native/branches/jaxws21/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/wsdl11/WSDLExtensElemTestCase.java 2009-01-15
16:25:19 UTC (rev 9051)
@@ -60,7 +60,7 @@
assertNotNull(extPortList);
assertEquals(extPortList.size(),1);
assertPolicyRef(extPortList.get(0),"uselessPortPolicy");
- List<WSDLExtensibilityElement> portNotUnderstoodList =
wsdlEndpoint.getNotUnderstoodExtElement();
+ List<WSDLExtensibilityElement> portNotUnderstoodList =
wsdlEndpoint.getNotUnderstoodExtElements();
assertNotNull(portNotUnderstoodList);
assertEquals(0, portNotUnderstoodList.size());
@@ -71,7 +71,7 @@
assertEquals(extBinding.size(),2);
assertPolicyRef(extBinding.get(0),"RmPolicy");
assertPolicyRef(extBinding.get(1),"X509EndpointPolicy");
- List<WSDLExtensibilityElement> bindingNotUnderstoodList =
wsdlBinding.getNotUnderstoodExtElement();
+ List<WSDLExtensibilityElement> bindingNotUnderstoodList =
wsdlBinding.getNotUnderstoodExtElements();
assertNotNull(bindingNotUnderstoodList);
assertEquals(0, bindingNotUnderstoodList.size());
}
@@ -91,7 +91,7 @@
assertNotNull(extPortList);
assertEquals(extPortList.size(),1);
assertPolicyRef(extPortList.get(0),"uselessPortPolicy");
- List<WSDLExtensibilityElement> portNotUnderstoodList =
wsdlEndpoint.getNotUnderstoodExtElement();
+ List<WSDLExtensibilityElement> portNotUnderstoodList =
wsdlEndpoint.getNotUnderstoodExtElements();
assertNotNull(portNotUnderstoodList);
assertEquals(1, portNotUnderstoodList.size());
assertUnknownExtElem(portNotUnderstoodList.get(0), "foo1",
"http://foo.org/foo1", "bar", true);
@@ -103,7 +103,7 @@
assertEquals(extBinding.size(),2);
assertPolicyRef(extBinding.get(0),"RmPolicy");
assertPolicyRef(extBinding.get(1),"X509EndpointPolicy");
- List<WSDLExtensibilityElement> bindingNotUnderstoodList =
wsdlBinding.getNotUnderstoodExtElement();
+ List<WSDLExtensibilityElement> bindingNotUnderstoodList =
wsdlBinding.getNotUnderstoodExtElements();
assertNotNull(bindingNotUnderstoodList);
assertEquals(2, bindingNotUnderstoodList.size());
assertUnknownExtElem(bindingNotUnderstoodList.get(0), "foo1",
"http://foo.org/foo1", "bar", false);
@@ -124,5 +124,6 @@
QName qName = new QName(el.getNamespaceURI(),el.getLocalName(),el.getPrefix());
assertEquals(qName, new QName(namespaceURI, localName, prefix));
assertEquals(required,
"true".equals(el.getAttributeNS(Constants.NS_WSDL11, "required")));
+ assertEquals(required, extEl.isRequired());
}
}