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 15:44:52 UTC

svn commit: r692012 - 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 06:44:51 2008
New Revision: 692012

URL: http://svn.apache.org/viewvc?rev=692012&view=rev
Log:
Changes to allow MTOM enablement to be set via sparse composite properties

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=692012&r1=692011&r2=692012&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 06:44:51 2008
@@ -112,7 +112,18 @@
         if (binding instanceof SOAPBinding) {
             // MTOM can be enabled either at the ServiceDescription level (via the WSDL binding type) or
             // at the EndpointDescription level via the binding type used to create a Dispatch.
-            boolean enableMTOMFromMetadata = endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate);
+            boolean enableMTOMFromMetadata = false;
+            
+            // if we have an SEI for the port, then we'll use it in order to search for MTOM configuration
+            if(endpointDesc.getEndpointInterfaceDescription() != null
+                    &&
+                    endpointDesc.getEndpointInterfaceDescription().getSEIClass() != null) {
+                enableMTOMFromMetadata = endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate, 
+                                                                   endpointDesc.getEndpointInterfaceDescription().getSEIClass());
+            }
+            else {
+                enableMTOMFromMetadata = endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate);
+            }
             if (!enableMTOMFromMetadata) {
                 String bindingType = endpointDesc.getClientBindingID();
                 enableMTOMFromMetadata = (bindingType.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) || 

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=692012&r1=692011&r2=692012&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 06:44:51 2008
@@ -24,6 +24,7 @@
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.MDQConstants;
 
 import javax.jws.WebService;
 import javax.xml.namespace.QName;
@@ -31,6 +32,7 @@
 import javax.xml.ws.WebServiceClient;
 import javax.xml.ws.soap.SOAPBinding;
 import java.net.URL;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -422,6 +424,71 @@
     }
     
     /**
+     * Validate enabling MTOM when creating the service results ports created under that service
+     * have MTOM enabled.
+     */
+    public void testEnableMTOMFromServiceDBC() {
+        QName serviceQName = new QName(namespaceURI, svcLocalPart);
+        URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+        DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+        Map<String, Boolean> seiToMTOM = new HashMap<String, Boolean>();
+        seiToMTOM.put(ClientMetadataPortSEI.class.getName(), true);
+        sparseComposite.getProperties().put(MDQConstants.SEI_MTOM_ENABLEMENT_MAP, seiToMTOM);
+        ServiceDelegate.setServiceMetadata(sparseComposite);
+        Service service = Service.create(wsdlUrl, serviceQName);
+        ClientMetadataPortSEI port = service.getPort(ClientMetadataPortSEI.class);
+        assertNotNull(port);
+        // Verify that MTOM is enabled on this port.
+        BindingProvider bindingProvider = (BindingProvider) port;
+        SOAPBinding binding = (SOAPBinding) bindingProvider.getBinding();
+        assertTrue(binding.isMTOMEnabled());
+        
+        // Verify that specific ports under this service also have MTOM enabled
+        QName port1QN = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
+        ClientMetadataPortSEI port1 = service.getPort(port1QN, ClientMetadataPortSEI.class);
+        SOAPBinding binding1 = ((SOAPBinding) ((BindingProvider) port1).getBinding());
+        assertTrue(binding1.isMTOMEnabled());
+        
+        QName port2QN = new QName(namespaceURI, multiPortWsdl_portLocalPart2);
+        ClientMetadataPortSEI port2 = service.getPort(port2QN, ClientMetadataPortSEI.class);
+        SOAPBinding binding2 = ((SOAPBinding) ((BindingProvider) port2).getBinding());
+        assertTrue(binding2.isMTOMEnabled());
+    }
+    
+    /**
+     * Validate enabling MTOM when creating the service results ports created under that service
+     * have MTOM enabled.
+     */
+    public void testDisableMTOMFromServiceDBC() {
+        QName serviceQName = new QName(namespaceURI, svcLocalPart);
+        URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+        DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+        Map<String, Boolean> seiToMTOM = new HashMap<String, Boolean>();
+        seiToMTOM.put(ClientMetadataPortSEI.class.getName(), false);
+        sparseComposite.getProperties().put(MDQConstants.SEI_MTOM_ENABLEMENT_MAP, seiToMTOM);
+        ServiceDelegate.setServiceMetadata(sparseComposite);
+        Service service = Service.create(wsdlUrl, serviceQName);
+        ClientMetadataPortSEI port = service.getPort(ClientMetadataPortSEI.class);
+        assertNotNull(port);
+        // Verify that MTOM is enabled on this port.
+        BindingProvider bindingProvider = (BindingProvider) port;
+        SOAPBinding binding = (SOAPBinding) bindingProvider.getBinding();
+        assertTrue(!binding.isMTOMEnabled());
+        
+        // Verify that specific ports under this service also have MTOM enabled
+        QName port1QN = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
+        ClientMetadataPortSEI port1 = service.getPort(port1QN, ClientMetadataPortSEI.class);
+        SOAPBinding binding1 = ((SOAPBinding) ((BindingProvider) port1).getBinding());
+        assertTrue(!binding1.isMTOMEnabled());
+        
+        QName port2QN = new QName(namespaceURI, multiPortWsdl_portLocalPart2);
+        ClientMetadataPortSEI port2 = service.getPort(port2QN, ClientMetadataPortSEI.class);
+        SOAPBinding binding2 = ((SOAPBinding) ((BindingProvider) port2).getBinding());
+        assertTrue(!binding2.isMTOMEnabled());
+    }
+    
+    
+    /**
      * Validate enabling MTOM when creating the service results in enablement only
      * for that service delegate, and not a different service delegate referencing
      * the same service.

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=692012&r1=692011&r2=692012&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 06:44:51 2008
@@ -144,6 +144,23 @@
      */
     public boolean isMTOMEnabled(Object key);
     
+    /**
+     * Answer if MTOM is enabled for the service represented by this Service Description  
+     * and the service-endpoint-interface indicated. This is currently only supported on the 
+     * service-requester side; it is not supported on the service-provider side.  If the key is 
+     * non-null, it is used to look up an sparse metadata that may have been specified when the 
+     * Service Description was created. If the seiClass is non-null it is used to further scope
+     * the enablement of MTOM to a specific SEI.
+     *  
+     * @param key If non-null, used to look up any sparse metadata that may have been specified
+     *     when the service was created.
+     * @param seiClass Represents client service-endpoint-interface class.
+     * 
+     * @return TRUE if mtom was enabled either in the sparse metadata or in the composite; FALSE
+     *     othewise.
+     */
+    public boolean isMTOMEnabled(Object key, Class seiClass);
+    
     public QName getPreferredPort(Object key);
     
     public JAXWSCatalogManager getCatalogManager();

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=692012&r1=692011&r2=692012&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 06:44:51 2008
@@ -54,6 +54,8 @@
     
     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";
+    
     //Represent SOAP/JMS Bindings
     //REVIEW: SOAP-JMS may be using the same NS for SOAP11 and SOAP12, 
     //  if so we could remove some duplicate values below

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=692012&r1=692011&r2=692012&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 06:44:51 2008
@@ -1283,6 +1283,40 @@
     }
     
     /* (non-Javadoc)
+     * @see org.apache.axis2.jaxws.description.ServiceDescription#isMTOMEnabled(java.lang.Object, Class seiClass)
+     */
+    public boolean isMTOMEnabled(Object key, Class seiClass) {
+        if(log.isDebugEnabled()) {
+            log.debug("isMTOMEnabled, key= " + key + ", seiClass= " + seiClass);
+        }
+        
+        boolean mtomEnabled = false;
+        DescriptionBuilderComposite sparseComposite = getDescriptionBuilderComposite().getSparseComposite(key);
+        if(sparseComposite != null
+                &&
+                seiClass != null) {
+            Map<String, Boolean> seiToMTOM = (Map<String, Boolean>) 
+                sparseComposite.getProperties().get(MDQConstants.SEI_MTOM_ENABLEMENT_MAP);
+            if(seiToMTOM != null
+                    &&
+                    seiToMTOM.get(seiClass.getName()) != null) {
+                mtomEnabled = seiToMTOM.get(seiClass.getName());
+            }
+            else {
+                mtomEnabled = isMTOMEnabled(key);
+            }
+        }
+        else {
+            mtomEnabled = isMTOMEnabled(key);
+        }
+        
+        if(log.isDebugEnabled()) {
+            log.debug("isMTOMEnabled, key= " + key + ", seiClass= " + seiClass + ", isMTOMEnabled= " + mtomEnabled);
+        }
+        return mtomEnabled;
+    }
+    
+    /* (non-Javadoc)
      * @see org.apache.axis2.jaxws.description.ServiceDescription#getPreferredPort(java.lang.Object)
      */
     public QName getPreferredPort(Object key) {
@@ -2275,7 +2309,7 @@
             innerMap.put(endpointDescriptionImpl.getPortQName(), endpointDescriptionImpl);
         }
     }
-    
+        
     /** Return a string representing this Description object and all the objects it contains. */
     public String toString() {
         final String newline = "\n";