You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by da...@apache.org on 2008/09/04 16:06:21 UTC
svn commit: r692024 - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/ jaxws/test/org/apache/axis2/jaxws/spi/
metadata/src/org/apache/axis2/jaxws/description/
metadata/src/org/apache/axis2/jaxws/description/builder/ metadata/...
Author: damrhei
Date: Thu Sep 4 07:06:19 2008
New Revision: 692024
URL: http://svn.apache.org/viewvc?rev=692024&view=rev
Log:
Changes to allow BindingProvider properties to be specified via the properties bag on the sparse composite
Modified:
webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataPortTest.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?rev=692024&r1=692023&r2=692024&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java Thu Sep 4 07:06:19 2008
@@ -134,6 +134,25 @@
((SOAPBinding) binding).setMTOMEnabled(true);
}
}
+
+ // check for properties that need to be set on the BindingProvider
+ String seiName = null;
+ if(endpointDesc.getEndpointInterfaceDescription() != null
+ &&
+ endpointDesc.getEndpointInterfaceDescription().getSEIClass() != null) {
+ seiName = endpointDesc.getEndpointInterfaceDescription().getSEIClass().getName();
+ }
+ String portQNameString = endpointDesc.getPortQName().toString();
+ String key = seiName + ":" + portQNameString;
+ Map<String, Object> bProps = endpointDesc.getServiceDescription().getBindingProperties(serviceDelegate, key);
+ if(bProps != null) {
+ if(log.isDebugEnabled()) {
+ log.debug("Setting binding props with size: " + bProps.size() + " on " +
+ "BindingProvider RequestContext");
+ }
+ requestContext.putAll(bProps);
+ }
+
binding.setHandlerChain(handlerResolver.getHandlerChain(endpointDesc.getPortInfo()));
//Set JAX-WS 2.1 related properties.
Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataPortTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataPortTest.java?rev=692024&r1=692023&r2=692024&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataPortTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataPortTest.java Thu Sep 4 07:06:19 2008
@@ -20,6 +20,7 @@
package org.apache.axis2.jaxws.spi;
import junit.framework.TestCase;
+
import org.apache.axis2.jaxws.description.DescriptionTestUtils2;
import org.apache.axis2.jaxws.description.EndpointDescription;
import org.apache.axis2.jaxws.description.ServiceDescription;
@@ -28,6 +29,7 @@
import javax.jws.WebService;
import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.soap.SOAPBinding;
@@ -521,6 +523,72 @@
ClientMetadataTest.restoreOriginalFactory();
}
}
+
+ /**
+ * Validate enabling the setting of properties on the BindingProvider based
+ * on a map of properties supplied to the sparse composite.
+ */
+ public void testSetBindingProperties() {
+ try {
+ ClientMetadataTest.installCachingFactory();
+
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ QName portQN = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
+
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+ sparseComposite.setIsMTOMEnabled(true);
+ Map<String, Map<String, Object>> allBindingProps = new HashMap<String, Map<String,Object>>();
+ String key = ClientMetadataPortSEI.class.getName() + ":" + portQN.toString();
+ Map<String, Object> bindingProps = new HashMap<String, Object>();
+ bindingProps.put("customProperty", "someValue");
+ allBindingProps.put(key, bindingProps);
+ sparseComposite.getProperties().put(MDQConstants.BINDING_PROPS_MAP, allBindingProps);
+
+ ServiceDelegate.setServiceMetadata(sparseComposite);
+ Service service1 = Service.create(wsdlUrl, serviceQName);
+ ClientMetadataPortSEI port1 = service1.getPort(portQN, ClientMetadataPortSEI.class);
+ BindingProvider bp = (BindingProvider) port1;
+ assertNotNull(bp.getRequestContext().get("customProperty"));
+ assertEquals(bp.getRequestContext().get("customProperty"), "someValue");
+
+ } finally {
+ ClientMetadataTest.restoreOriginalFactory();
+ }
+ }
+
+ /**
+ * This will validate that the properties to be set on the BindingProvider, via
+ * the sparse composite, can be correctly scoped at the port level.
+ */
+ public void testNoSetBindingProperties() {
+ try {
+ ClientMetadataTest.installCachingFactory();
+
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ QName portQN = new QName(namespaceURI, multiPortWsdl_portLocalPart2);
+
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+ sparseComposite.setIsMTOMEnabled(true);
+ Map<String, Map<String, Object>> allBindingProps = new HashMap<String, Map<String,Object>>();
+ String key = ClientMetadataPortSEI.class.getName() + ":" + portQN.toString();
+ Map<String, Object> bindingProps = new HashMap<String, Object>();
+ bindingProps.put("customProperty", "someValue");
+ allBindingProps.put(key, bindingProps);
+ sparseComposite.getProperties().put(MDQConstants.BINDING_PROPS_MAP, allBindingProps);
+
+ ServiceDelegate.setServiceMetadata(sparseComposite);
+ Service service1 = Service.create(wsdlUrl, serviceQName);
+ ClientMetadataPortSEI port1 = service1.getPort(new QName(namespaceURI, multiPortWsdl_portLocalPart1),
+ ClientMetadataPortSEI.class);
+ BindingProvider bp = (BindingProvider) port1;
+ assertNull(bp.getRequestContext().get("customProperty"));
+
+ } finally {
+ ClientMetadataTest.restoreOriginalFactory();
+ }
+ }
}
@WebService(name="EchoMessagePortType", targetNamespace="http://description.jaxws.axis2.apache.org")
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java?rev=692024&r1=692023&r2=692024&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java Thu Sep 4 07:06:19 2008
@@ -28,6 +28,7 @@
import javax.xml.ws.handler.PortInfo;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
/**
* A ServiceDescription corresponds to a Service under which there can be a collection of enpdoints.
@@ -203,5 +204,17 @@
* @param delegate The ServiceDelegate instance that owns this ServiceDescription.
*/
public void releaseResources(Object delegate);
+
+ /**
+ * This method is responsible for querying the metadata for properties associated with
+ * a given BindingProvider instance. This is only applicable for the requestor-side, and
+ * the properties are scoped at the port level.
+ * @param serviceDelegateKey This should always be non-null when called via ServiceDelegate and is
+ * used to help retrieve dynamic ports per client
+ * @param key This should always be non-null and is used to retrieve properties for a given
+ * client-side port
+ * @return
+ */
+ public Map<String, Object> getBindingProperties(Object serviceDelegateKey, String key);
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?rev=692024&r1=692023&r2=692024&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java Thu Sep 4 07:06:19 2008
@@ -55,6 +55,7 @@
public static final String HANDLER_CHAIN_DECLARING_CLASS = "HANDLER_CHAIN_DECLARING_CLASS";
public static final String SEI_MTOM_ENABLEMENT_MAP = "org.apache.axis2.jaxws.description.builder.SEI_MTOM_ENABLEMENT_MAP";
+ public static final String BINDING_PROPS_MAP = "org.apache.axis2.jaxws.description.builder.BINDING_PROPS_MAP";
//Represent SOAP/JMS Bindings
//REVIEW: SOAP-JMS may be using the same NS for SOAP11 and SOAP12,
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=692024&r1=692023&r2=692024&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Thu Sep 4 07:06:19 2008
@@ -1317,6 +1317,31 @@
}
/* (non-Javadoc)
+ * @see org.apache.axis2.jaxws.description.ServiceDescription#getBindingProperites(java.lang.Object, String key)
+ */
+ public Map<String, Object> getBindingProperties(Object serviceDelegateKey, String key) {
+ if(log.isDebugEnabled()) {
+ log.debug("getBindingProperties, serviceDelegateKey= " + serviceDelegateKey +
+ ", key= " + key);
+ }
+
+ Map<String, Object> bindingProps = null;
+ DescriptionBuilderComposite sparseComposite = getDescriptionBuilderComposite().getSparseComposite(serviceDelegateKey);
+ if(sparseComposite != null) {
+ Map<String, Map<String, Object>> allBindingProps = (Map<String, Map<String, Object>>)
+ sparseComposite.getProperties().get(MDQConstants.BINDING_PROPS_MAP);
+ bindingProps = allBindingProps != null ? (Map<String, Object>) allBindingProps.get(key) : null;
+ }
+
+ if(log.isDebugEnabled()) {
+ log.debug("getBindingProperties, serviceDelegateKey= " + serviceDelegateKey +
+ ", key= " + key + ", propsSize= " + (bindingProps != null ? bindingProps.size() : 0));
+ }
+
+ return bindingProps;
+ }
+
+ /* (non-Javadoc)
* @see org.apache.axis2.jaxws.description.ServiceDescription#getPreferredPort(java.lang.Object)
*/
public QName getPreferredPort(Object key) {