Author: barrettj
Date: Wed Apr 7 15:57:53 2010
New Revision: 931598
URL: http://svn.apache.org/viewvc?rev=931598&view=rev
Log:
Add support for setting MTOM threshold via a DBC sparse composite as would be
used for a deploment descriptor. Add associated TDD test.
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataMTOMFeatureTests.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?rev=931598&r1=931597&r2=931598&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
Wed Apr 7 15:57:53 2010
@@ -28,6 +28,7 @@ import org.apache.axis2.jaxws.client.Pro
import org.apache.axis2.jaxws.core.InvocationContext;
import org.apache.axis2.jaxws.core.MessageContext;
import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.description.ServiceDescription;
import org.apache.axis2.jaxws.description.ServiceDescriptionWSDL;
import org.apache.axis2.jaxws.handler.HandlerResolverImpl;
import org.apache.axis2.jaxws.i18n.Messages;
@@ -126,6 +127,7 @@ public class BindingProvider implements
// 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 = false;
+ int mtomThreshold = 0;
// if we have an SEI for the port, then we'll use it in order to
search for MTOM configuration
if(endpointDesc.getEndpointInterfaceDescription() != null
@@ -133,9 +135,13 @@ public class BindingProvider implements
endpointDesc.getEndpointInterfaceDescription().getSEIClass() != null) {
enableMTOMFromMetadata =
endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate,
endpointDesc.getEndpointInterfaceDescription().getSEIClass());
+ mtomThreshold =
getMTOMThreshold(endpointDesc.getServiceDescription(), serviceDelegate,
+
endpointDesc.getEndpointInterfaceDescription().getSEIClass());
}
else {
enableMTOMFromMetadata =
endpointDesc.getServiceDescription().isMTOMEnabled(serviceDelegate);
+ // Threshold does not need to be set here based on the sparse
composite (i.e. depolyment descriptor)
+ // since it can only be applied to a port injection (i.e. an
SEI) using a DD.
}
if (!enableMTOMFromMetadata) {
String bindingType = endpointDesc.getClientBindingID();
@@ -145,6 +151,7 @@ public class BindingProvider implements
if (enableMTOMFromMetadata) {
((SOAPBinding) binding).setMTOMEnabled(true);
+ ((SOAPBinding) binding).setMTOMThreshold(mtomThreshold);
}
}
@@ -179,6 +186,12 @@ public class BindingProvider implements
}
}
+ private int getMTOMThreshold(ServiceDescription serviceDescription,
ServiceDelegate serviceDelegate, Class seiClass) {
+ int threshold = serviceDescription.getMTOMThreshold(serviceDelegate,
seiClass);
+
+ return threshold;
+ }
+
public ServiceDelegate getServiceDelegate() {
return serviceDelegate;
}
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java?rev=931598&r1=931597&r2=931598&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
Wed Apr 7 15:57:53 2010
@@ -43,6 +43,7 @@ import java.util.Set;
*/
public class SOAPBinding extends BindingImpl implements
javax.xml.ws.soap.SOAPBinding {
private boolean mtomEnabled = false;
+ private int mtomThreshold = 0;
private static Log log = LogFactory.getLog(SOAPBinding.class);
@@ -54,6 +55,12 @@ public class SOAPBinding extends Binding
super(endpointDesc);
}
+ public int getMTOMThreshold() {
+ return mtomThreshold;
+ }
+ public void setMTOMThreshold(int threshold) {
+ mtomThreshold = threshold;
+ }
/*
* (non-Javadoc)
*
Modified:
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?rev=931598&r1=931597&r2=931598&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
(original)
+++
axis/axis2/java/core/trunk/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
Wed Apr 7 15:57:53 2010
@@ -196,6 +196,9 @@ public class JAXWSProxyHandler extends B
if (((SOAPBinding)bnd).isMTOMEnabled()) {
Message requestMsg = request.getMessage();
requestMsg.setMTOMEnabled(true);
+ int threshold =
((org.apache.axis2.jaxws.binding.SOAPBinding)bnd).getMTOMThreshold();
+
request.setProperty(org.apache.axis2.Constants.Configuration.MTOM_THRESHOLD,
+ new Integer(threshold));
}
}
Added:
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataMTOMFeatureTests.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataMTOMFeatureTests.java?rev=931598&view=auto
==============================================================================
---
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataMTOMFeatureTests.java
(added)
+++
axis/axis2/java/core/trunk/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataMTOMFeatureTests.java
Wed Apr 7 15:57:53 2010
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.spi;
+
+import org.apache.axis2.jaxws.binding.SOAPBinding;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.MDQConstants;
+import org.apache.axis2.jaxws.description.builder.MTOMAnnot;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import java.lang.annotation.Annotation;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Validate the setting up of the MTOM WebServiceFeature via meta-data (such
as a deployment descriptor)
+ */
+public class ClientMetadataMTOMFeatureTests extends TestCase {
+ static final String namespaceURI =
"http://description.jaxws.axis2.apache.org";
+ static final String svcLocalPart = "svcLocalPart";
+ static final String multiPortWsdl = "ClientMetadataMultiPort.wsdl";
+ static final String multiPortWsdl_portLocalPart1 = "portLocalPartMulti1";
+ static final String multiPortWsdl_portLocalPart2 = "portLocalPartMulti2";
+
+
+ public static final int MTOM_THRESHOLD = 3000;
+
+ /**
+ * Validate the default value of MTOM Threshold if MTOM is not enabled.
+ */
+ public void testDefaultThresholdWhenMTOMNotEnabled() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ ClientMetadataMTOMPortSEI port =
service.getPort(ClientMetadataMTOMPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertFalse("MTOM is enabled but should not be",
soapBinding.isMTOMEnabled());
+ assertEquals("MTOM threshold default incorrect", 0,
soapBinding.getMTOMThreshold());
+ }
+
+ /**
+ * Validate the default value of MTOM Threshold if MTOM is enabled.
+ */
+ public void testDefaultThresholdWhenMTOMEnabled() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ // MTOM is enabled, but a threshold is not set
+ mtomFeature.setEnabled(true);
+ wsFeatures.add(mtomFeature);
+ map.put(ClientMetadataMTOMPortSEI.class.getName(), wsFeatures);
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ ClientMetadataMTOMPortSEI port =
service.getPort(ClientMetadataMTOMPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("MTOM is not enabled but should be",
soapBinding.isMTOMEnabled());
+ assertEquals("MTOM threshold default incorrect", 0,
soapBinding.getMTOMThreshold());
+ }
+
+ /**
+ * Enable MTOM with the "old" way by setting MTOM isENabled directly on
the service DBC.
+ * Note this way will eventually be deprecated.
+ */
+ public void testMTOMEnabledOldMTOMEnabled() {
+ Service service = createService(true);
+ ClientMetadataMTOMPortSEI port =
service.getPort(ClientMetadataMTOMPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("MTOM is not enabled", soapBinding.isMTOMEnabled());
+ }
+
+ /**
+ * Validate that MTOM threshold can be set using the new feature property
when MTOM is
+ * enabled the "old" way.
+ */
+ public void testMTOMThresholdOldMTOMEnabled() {
+ Service service = createService(true);
+ ClientMetadataMTOMPortSEI port =
service.getPort(ClientMetadataMTOMPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertEquals("MTOM threshold not set", MTOM_THRESHOLD,
soapBinding.getMTOMThreshold());
+ }
+
+ /**
+ * Validate that MTOM can be enabled using the new feature property
without having to use the
+ * old method of setting isMTOMEnabled directly on the service DBC
+ */
+ public void testMTOMEnablement() {
+ Service service = createService(false);
+ ClientMetadataMTOMPortSEI port =
service.getPort(ClientMetadataMTOMPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("MTOM is not enabled", soapBinding.isMTOMEnabled());
+
+ }
+
+ /**
+ * Validate that if the NEW way of setting MTOM explcitly says MTOM is
disabled and the OLD
+ * way says it is enabled, we use the new setting and MTOM is disabled.
+ */
+ public void testMTOMEnablementConflict_NewOff_OldOn() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ // Explicitly disable MTOM with the new way of enabling it
+ mtomFeature.setEnabled(false);
+ mtomFeature.setThreshold(MTOM_THRESHOLD);
+ wsFeatures.add(mtomFeature);
+ map.put(ClientMetadataMTOMPortSEI.class.getName(), wsFeatures);
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ // Enable MTOM with the old way of enabling it
+ serviceDBC.setIsMTOMEnabled(true);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ ClientMetadataMTOMPortSEI port =
service.getPort(ClientMetadataMTOMPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertFalse("MTOM is enabled but should not be",
soapBinding.isMTOMEnabled());
+ }
+
+ /**
+ * Validate that if the NEW way of setting MTOM is not explcitly specified
for a port and the OLD
+ * way says it is enabled, we MTOM is enabled.
+ */
+ public void testMTOMEnablementConflict_NewUnspec_OldOn() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ // The port we do the get on will not have any feautres specified for
it.
+ mtomFeature.setEnabled(false);
+ mtomFeature.setThreshold(MTOM_THRESHOLD);
+ wsFeatures.add(mtomFeature);
+ // Set the feature on a different port name than we will be using in
getPort
+ map.put(ClientMetadataMTOMPortSEI2.class.getName(), wsFeatures);
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ // Enable MTOM with the old way of enabling it
+ serviceDBC.setIsMTOMEnabled(true);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ ClientMetadataMTOMPortSEI port =
service.getPort(ClientMetadataMTOMPortSEI.class);
+
+ BindingProvider bindingProvider = (BindingProvider) port;
+ SOAPBinding soapBinding = (SOAPBinding) bindingProvider.getBinding();
+ assertTrue("MTOM is not enabled", soapBinding.isMTOMEnabled());
+ }
+
+ /**
+ * Validate that MTOM can be enabled on some ports and not others by
explicitly setting the features.
+ */
+ public void testMTOMEnableSomeNotOthersExplicitly() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ // Enable MTOM explicitly on one port
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ mtomFeature.setEnabled(true);
+ mtomFeature.setThreshold(MTOM_THRESHOLD);
+ wsFeatures.add(mtomFeature);
+ map.put(ClientMetadataMTOMPortSEI.class.getName(), wsFeatures);
+
+ // Disable MTOM explicitly on a different port
+ ArrayList<Annotation> wsFeatures2 = new ArrayList<Annotation>();
+ MTOMAnnot mtomFeatureDisable = new MTOMAnnot();
+ mtomFeatureDisable.setEnabled(false);
+ wsFeatures2.add(mtomFeatureDisable);
+ map.put(ClientMetadataMTOMPortSEI2.class.getName(), wsFeatures2);
+
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ // Validate that MTOM is enabled on one port and disabled on the other
+ QName portQN1 = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
+ QName portQN2 = new QName(namespaceURI, multiPortWsdl_portLocalPart2);
+
+ ClientMetadataMTOMPortSEI enabledPort = service.getPort(portQN1,
ClientMetadataMTOMPortSEI.class);
+ BindingProvider enabledBindingProvider = (BindingProvider) enabledPort;
+ SOAPBinding enabledSoapBinding = (SOAPBinding)
enabledBindingProvider.getBinding();
+ assertTrue("MTOM is not enabled", enabledSoapBinding.isMTOMEnabled());
+ assertEquals("Threashold value incorrect", MTOM_THRESHOLD,
enabledSoapBinding.getMTOMThreshold());
+
+ ClientMetadataMTOMPortSEI2 disabledPort = service.getPort(portQN2,
ClientMetadataMTOMPortSEI2.class);
+ BindingProvider disabledBindingProvider = (BindingProvider)
disabledPort;
+ SOAPBinding disabledSoapBinding = (SOAPBinding)
disabledBindingProvider.getBinding();
+ assertFalse("MTOM is enabled and should not be",
disabledSoapBinding.isMTOMEnabled());
+ assertEquals("Threashold value incorrect", 0,
disabledSoapBinding.getMTOMThreshold());
+
+ }
+
+ /**
+ * Validate that MTOM can be enabled on some ports and not others by not
specificing the MTOM feature
+ * on the ports it should not be enabled on.
+ */
+ public void testMTOMEnableSomeNotOthersUnspecified() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ // Enable MTOM explicitly on one port
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ mtomFeature.setEnabled(true);
+ mtomFeature.setThreshold(MTOM_THRESHOLD);
+ wsFeatures.add(mtomFeature);
+ map.put(ClientMetadataMTOMPortSEI.class.getName(), wsFeatures);
+
+ // Do not specify the MTOM feature for the other port
+
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ // Validate that MTOM is enabled on one port and disabled on the other
+ QName portQN1 = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
+ QName portQN2 = new QName(namespaceURI, multiPortWsdl_portLocalPart2);
+
+ ClientMetadataMTOMPortSEI enabledPort = service.getPort(portQN1,
ClientMetadataMTOMPortSEI.class);
+ BindingProvider enabledBindingProvider = (BindingProvider) enabledPort;
+ SOAPBinding enabledSoapBinding = (SOAPBinding)
enabledBindingProvider.getBinding();
+ assertTrue("MTOM is not enabled", enabledSoapBinding.isMTOMEnabled());
+ assertEquals("Threashold value incorrect", MTOM_THRESHOLD,
enabledSoapBinding.getMTOMThreshold());
+
+ ClientMetadataMTOMPortSEI2 disabledPort = service.getPort(portQN2,
ClientMetadataMTOMPortSEI2.class);
+ BindingProvider disabledBindingProvider = (BindingProvider)
disabledPort;
+ SOAPBinding disabledSoapBinding = (SOAPBinding)
disabledBindingProvider.getBinding();
+ assertFalse("MTOM is enabled and should not be",
disabledSoapBinding.isMTOMEnabled());
+ assertEquals("Threashold value incorrect", 0,
disabledSoapBinding.getMTOMThreshold());
+ }
+
+ /**
+ * Validate if there are multiple instances of the same feature for a port
in the list, the last one is used.
+ */
+ public void testMultipleFeaturesForPortThreshold() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ // Enable MTOM explicitly then add another feature that enables it
with a different threshold.
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ mtomFeature.setEnabled(true);
+ mtomFeature.setThreshold(MTOM_THRESHOLD + 10);
+ wsFeatures.add(mtomFeature);
+
+ MTOMAnnot mtomFeature3 = new MTOMAnnot();
+ mtomFeature3.setEnabled(true);
+ mtomFeature3.setThreshold(MTOM_THRESHOLD);
+ wsFeatures.add(mtomFeature3);
+ map.put(ClientMetadataMTOMPortSEI.class.getName(), wsFeatures);
+
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ QName portQN1 = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
+
+ ClientMetadataMTOMPortSEI enabledPort = service.getPort(portQN1,
ClientMetadataMTOMPortSEI.class);
+ BindingProvider enabledBindingProvider = (BindingProvider) enabledPort;
+ SOAPBinding enabledSoapBinding = (SOAPBinding)
enabledBindingProvider.getBinding();
+ assertTrue("MTOM is not enabled", enabledSoapBinding.isMTOMEnabled());
+ assertEquals("Threashold value incorrect", MTOM_THRESHOLD,
enabledSoapBinding.getMTOMThreshold());
+ }
+
+ public void testMultipoleFeaturesForPortEnable() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ // Enable MTOM explicitly then add another feature that disables it
explicitly.
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ mtomFeature.setEnabled(true);
+ mtomFeature.setThreshold(MTOM_THRESHOLD);
+ wsFeatures.add(mtomFeature);
+
+ MTOMAnnot mtomFeature2 = new MTOMAnnot();
+ mtomFeature2.setEnabled(false);
+ wsFeatures.add(mtomFeature2);
+
+ map.put(ClientMetadataMTOMPortSEI.class.getName(), wsFeatures);
+
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ QName portQN1 = new QName(namespaceURI, multiPortWsdl_portLocalPart1);
+
+ ClientMetadataMTOMPortSEI enabledPort = service.getPort(portQN1,
ClientMetadataMTOMPortSEI.class);
+ BindingProvider enabledBindingProvider = (BindingProvider) enabledPort;
+ SOAPBinding enabledSoapBinding = (SOAPBinding)
enabledBindingProvider.getBinding();
+ assertFalse("MTOM is not enabled", enabledSoapBinding.isMTOMEnabled());
+ }
+
+ /**
+ * Create a service as would be done via injection or lookup, including a
sparse composite that
+ * contains features (as might be set by a deployment descriptor).
+ *
+ * @param oldMTOMEnablement use the old style of enabling MTOM if true
+ *
+ * @return a Service created as done via injection or lookup.
+ */
+ private Service createService(boolean oldMTOMEnablement) {
+ // Even for a port injection or lookup, the service will also be
treated as an injection or lookup
+ // So we need to setup the sparse DBC to create the service
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(multiPortWsdl);
+ DescriptionBuilderComposite serviceDBC = new
DescriptionBuilderComposite();
+
+ Map<String, List<Annotation>> map = new HashMap();
+ ArrayList<Annotation> wsFeatures = new ArrayList<Annotation>();
+ MTOMAnnot mtomFeature = new MTOMAnnot();
+ mtomFeature.setEnabled(true);
+ mtomFeature.setThreshold(MTOM_THRESHOLD);
+ wsFeatures.add(mtomFeature);
+ map.put(ClientMetadataMTOMPortSEI.class.getName(), wsFeatures);
+ serviceDBC.getProperties().put(MDQConstants.SEI_FEATURES_MAP, map);
+ if (oldMTOMEnablement) {
+ serviceDBC.setIsMTOMEnabled(true);
+ }
+ ServiceDelegate.setServiceMetadata(serviceDBC);
+ Service service = Service.create(wsdlUrl, serviceQName);
+ return service;
+ }
+}
+
+...@webservice(name="EchoMessagePortType",
targetNamespace="http://description.jaxws.axis2.apache.org")
+interface ClientMetadataMTOMPortSEI {
+ public String echoMessage(String string);
+}
+
+...@webservice(name="EchoMessagePortType2",
targetNamespace="http://description.jaxws.axis2.apache.org")
+interface ClientMetadataMTOMPortSEI2 {
+ public String echoMessage(String string);
+}
\ No newline at end of file
Modified:
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java?rev=931598&r1=931597&r2=931598&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
Wed Apr 7 15:57:53 2010
@@ -217,4 +217,14 @@ public interface ServiceDescription {
*/
public Map<String, Object> getBindingProperties(Object serviceDelegateKey,
String key);
+ /**
+ * Return the MTOM Threshold as set by the Client via a sparse composite
(such as a client deployment
+ * descriptor).
+ *
+ * @param serviceDelegateKey The instance of the service delegate related
to this service
+ * @param seiClass The SEI for the port to retried the MTOM threshold for
+ * @return the MTOM thredhold if set, or 0 if not set.
+ */
+ public int getMTOMThreshold(Object serviceDelegateKey, Class seiClass);
+
}
Modified:
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java?rev=931598&r1=931597&r2=931598&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/builder/MDQConstants.java
Wed Apr 7 15:57:53 2010
@@ -56,12 +56,20 @@ public class MDQConstants {
public static final String CLIENT_SEI_CLASS = "CLIENT_SEI_CLASS";
public static final String HANDLER_CHAIN_DECLARING_CLASS =
"HANDLER_CHAIN_DECLARING_CLASS";
-
+ /**
+ * Indicates if MTOM is enabled for specific ports (indexed by the SEI
class name) under a service on the
+ * client side.
+ * @deprecated Replaced by SEI_FEATURES_MAP with a MTOMAnnot to indicate
if MTOM is enabled.
+ */
public static final String SEI_MTOM_ENABLEMENT_MAP =
"org.apache.axis2.jaxws.description.builder.SEI_MTOM_ENABLEMENT_MAP";
- // Note that this property is ONLY used on the client-side, not the server
side.
- // Value is Map<String, List<java.lang.annotation.Annotation>> where
- // String: SEI Class name (i.e. the port name)
- // Annotation: The list of WebServiceFeatures expressed as the
corresponding Annotation related to that Port
+ /**
+ * Sets the Web Service Features (as Annotation instances) for specific
ports under a service on the
+ * client side. The value associated with this property is:
+ * Map<String, List<java.lang.annotation.Annotation>>
+ * Where:
+ * String: SEI Class name (i.e. the port name)
+ * Annotation: The list of WebServiceFeatures expressed as the
corresponding Annotation related to that Port
+ */
public static final String SEI_FEATURES_MAP =
"org.apache.axis2.jaxws.description.builder.SEI_FEATURES_MAP";
public static final String BINDING_PROPS_MAP =
"org.apache.axis2.jaxws.description.builder.BINDING_PROPS_MAP";
Modified:
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?rev=931598&r1=931597&r2=931598&view=diff
==============================================================================
---
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
(original)
+++
axis/axis2/java/core/trunk/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Wed Apr 7 15:57:53 2010
@@ -38,6 +38,7 @@ import org.apache.axis2.jaxws.descriptio
import org.apache.axis2.jaxws.description.ServiceRuntimeDescription;
import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.builder.MDQConstants;
+import org.apache.axis2.jaxws.description.builder.MTOMAnnot;
import org.apache.axis2.jaxws.description.builder.PortComposite;
import static
org.apache.axis2.jaxws.description.builder.MDQConstants.RETURN_TYPE_FUTURE;
@@ -1323,28 +1324,59 @@ public class ServiceDescriptionImpl
}
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
+ boolean checkOldEnablementMethod = true;
+
+ /*
+ * This is the NEW way of setting MTOM enabled using a property on the
DBC that contains the
+ * WebServiceFeatures for the ports on that service. One of those
features indicats if MTOM should
+ * be enabled
+ */
+ List<Annotation> seiFeatureList = getSEIFeatureList(key, seiClass);
+ if (seiFeatureList != null) {
+ for (int i = 0; i < seiFeatureList.size(); i++) {
+ Annotation checkAnnotation = seiFeatureList.get(i);
+ if (checkAnnotation instanceof MTOMAnnot) {
+ MTOMAnnot mtomAnnot = (MTOMAnnot) checkAnnotation;
+ mtomEnabled = mtomAnnot.enabled();
+ // We found an explicit setting for this port, so do not
check the old way of enabling MTOM
+ checkOldEnablementMethod = false;
+ }
+ }
+ }
+
+ /*
+ * This is the OLD way of setting MTOM enabled and it is deprecated.
Within the OLD way, there are
+ * two ways to enable MTOM:
+ * 1) By setting isMTOMEnabled to true on a single DBC which
represents a Service. This enables MTOM
+ * on all the ports under it.
+ * 2) By setting the property SEI_MTOM_ENABLEMENT_MAP to a list of
ports keyed by SEI name with a
+ * Boolean value indicating if MTOM should be enabled for that port.
+ */
+ if (checkOldEnablementMethod) {
+ DescriptionBuilderComposite sparseComposite =
getDescriptionBuilderComposite().getSparseComposite(key);
+ if(sparseComposite != null
&&
- seiToMTOM.get(seiClass.getName()) != null) {
- mtomEnabled = seiToMTOM.get(seiClass.getName());
+ 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);
}
}
- else {
- mtomEnabled = isMTOMEnabled(key);
- }
if(log.isDebugEnabled()) {
log.debug("isMTOMEnabled, key= " + key + ", seiClass= " + seiClass
+ ", isMTOMEnabled= " + mtomEnabled);
}
+
return mtomEnabled;
}
@@ -2876,4 +2908,38 @@ public class ServiceDescriptionImpl
}
return (returnCatalogManager);
}
+
+ public int getMTOMThreshold(Object serviceDelegate, Class seiClass) {
+ int threshold = 0;
+ List<Annotation> seiFeatureList = getSEIFeatureList(serviceDelegate,
seiClass);
+ if (log.isDebugEnabled()) {
+ log.debug("Feature list for delegate: " + serviceDelegate + ", and
SEI: " + seiClass
+ + ", is: " + seiFeatureList);
+ }
+ if (seiFeatureList != null) {
+ for (int i = 0; i < seiFeatureList.size(); i++) {
+ Annotation checkAnnotation = seiFeatureList.get(i);
+ if (checkAnnotation instanceof MTOMAnnot) {
+ MTOMAnnot mtomAnnot = (MTOMAnnot) checkAnnotation;
+ threshold = mtomAnnot.threshold();
+ }
+ }
+ }
+ return threshold;
+ }
+
+ private List<Annotation> getSEIFeatureList(Object serviceDelegate, Class
seiClass) {
+ List<Annotation> featureList = null;
+
+ DescriptionBuilderComposite sparseComposite =
getDescriptionBuilderComposite().getSparseComposite(serviceDelegate);
+ // The Features are only set on the sparse composite based on
Depoyment Descriptor information.
+ // And the information is keyed by the SEI class. Both need to be
non-null to get the value
+ if (sparseComposite != null && seiClass != null) {
+ Map<String, List<Annotation>> featureMap = (Map<String,
List<Annotation>>)
sparseComposite.getProperties().get(MDQConstants.SEI_FEATURES_MAP);
+ if (featureMap != null) {
+ featureList = featureMap.get(seiClass.getName());
+ }
+ }
+ return featureList;
+ }
}