axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject svn commit: r641889 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/sample/ jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/ jaxws/src/org/apache/axis2/datasource/jaxb/ jaxws/src/org/apache/axis2/jaxw...
Date Thu, 27 Mar 2008 16:54:58 GMT
Author: scheu
Date: Thu Mar 27 09:54:49 2008
New Revision: 641889

URL: http://svn.apache.org/viewvc?rev=641889&view=rev
Log:
AXIS2-3671
Contributor:Rich Scheuerle
The mtom setting is based on both the @MTOM annotation and the @BindingType annotation.
If present, the @MTOM annotation takes precedence.
Adding tests and code.

Added:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDefaultService.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisable2Service.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisableService.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMEnableService.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshallerMonitor.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSample.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleService.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/MtomSampleTests.java Thu Mar 27 09:54:49 2008
@@ -22,6 +22,8 @@
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
+
+import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
 import org.apache.axis2.jaxws.TestLogger;
 import org.apache.axis2.jaxws.framework.AbstractTestCase;
 import org.apache.axis2.jaxws.provider.DataSourceImpl;
@@ -46,14 +48,26 @@
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.soap.SOAPFaultException;
 
-import java.awt.*;
+import java.awt.Image;
 import java.io.File;
+import java.util.List;
 
 public class MtomSampleTests extends AbstractTestCase {
 
     private static final QName QNAME_SERVICE = new QName("urn://mtom.test.org", "MtomSampleService");
     private static final QName QNAME_PORT    = new QName("urn://mtom.test.org", "MtomSample");
     private static final String URL_ENDPOINT = "http://localhost:6060/axis2/services/MtomSampleService.MtomSampleServicePort";
+    
+    private static final String URL_ENDPOINT_MTOMDISABLE = 
+        "http://localhost:6060/axis2/services/MtomSampleService.MtomSampleMTOMDisableServicePort";
+    private static final String URL_ENDPOINT_MTOMDISABLE2 = 
+        "http://localhost:6060/axis2/services/MtomSampleService.MtomSampleMTOMDisable2ServicePort";
+    private static final String URL_ENDPOINT_MTOMENABLE = 
+        "http://localhost:6060/axis2/services/MtomSampleService.MtomSampleMTOMEnableServicePort";
+    private static final String URL_ENDPOINT_MTOMDEFAULT = 
+        "http://localhost:6060/axis2/services/MtomSampleService.MtomSampleMTOMDefaultServicePort";
+    
+    
     private static final String IMAGE_DIR = System.getProperty("basedir",".")+"/"+"test-resources"+File.separator+"image";   
     
     private static boolean CHECK_VERSIONMISMATCH = true;
@@ -143,12 +157,257 @@
         service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT);
         Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD, mtom21);
         
+        List cids = null;
+        SendImageResponse response = null;
+        try {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(true);
+            response = (SendImageResponse) dispatch.invoke(request);
+            
+            // The cids are collected in the monitor.  We will check
+            // this to make sure the response mtom is not inlined
+            cids = JAXBAttachmentUnmarshallerMonitor.getBlobCIDs();
+        } finally {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(false);
+        }
         
-        SendImageResponse response = (SendImageResponse) dispatch.invoke(request);
         
         assertNotNull(response);
         assertNotNull(response.getOutput().getImageData());
+        
+        
+        int numCIDs = (cids == null) ? 0 : cids.size();
+        assertTrue("Expected one attachment but there were:" + numCIDs, numCIDs == 1);
+    }
+    
+    /*
+     * Enable attachment Optimization but call an endpoint with @MTOM(enable=false)
+     */
+    public void testSendImage_MTOMDisable() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        MTOMFeature mtom21 = new MTOMFeature();
+
+        // Create the JAX-WS client needed to send the request
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT_MTOMDISABLE);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD, mtom21);
+        
+        List cids = null;
+        SendImageResponse response = null;
+        try {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(true);
+            response = (SendImageResponse) dispatch.invoke(request);
+            
+            // The cids are collected in the monitor.  We will check
+            // this to make sure the response mtom is not inlined
+            cids = JAXBAttachmentUnmarshallerMonitor.getBlobCIDs();
+        } finally {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(false);
+        }
+        
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        
+        
+        int numCIDs = (cids == null) ? 0 : cids.size();
+        assertTrue("Expected zero attachments but there were:" + numCIDs, numCIDs == 0);
+    }
+    
+    /*
+     * Enable attachment Optimization but call an endpoint with @MTOM(enable=false)
+     * which should override the MTOM BindingType
+     */
+    public void testSendImage_MTOMDisable2() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        MTOMFeature mtom21 = new MTOMFeature();
+
+        // Create the JAX-WS client needed to send the request
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT_MTOMDISABLE2);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD, mtom21);
+        
+        List cids = null;
+        SendImageResponse response = null;
+        try {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(true);
+            response = (SendImageResponse) dispatch.invoke(request);
+            
+            // The cids are collected in the monitor.  We will check
+            // this to make sure the response mtom is not inlined
+            cids = JAXBAttachmentUnmarshallerMonitor.getBlobCIDs();
+        } finally {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(false);
+        }
+        
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        
+        
+        int numCIDs = (cids == null) ? 0 : cids.size();
+        assertTrue("Expected zero attachments but there were:" + numCIDs, numCIDs == 0);
+    }
+    
+    /*
+     * Enable attachment Optimization but call an endpoint with @MTOM(enable=true)
+     */
+    public void testSendImage_MTOMEnable() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        MTOMFeature mtom21 = new MTOMFeature();
+
+        // Create the JAX-WS client needed to send the request
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT_MTOMENABLE);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD, mtom21);
+        
+        List cids = null;
+        SendImageResponse response = null;
+        try {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(true);
+            response = (SendImageResponse) dispatch.invoke(request);
+            
+            // The cids are collected in the monitor.  We will check
+            // this to make sure the response mtom is not inlined
+            cids = JAXBAttachmentUnmarshallerMonitor.getBlobCIDs();
+        } finally {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(false);
+        }
+        
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        
+        
+        int numCIDs = (cids == null) ? 0 : cids.size();
+        assertTrue("Expected one attachment but there were:" + numCIDs, numCIDs == 1);
+    }
+    
+    /*
+     * Enable attachment Optimization but call an endpoint with @MTOM
+     */
+    public void testSendImage_MTOMDefault() throws Exception {
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+        
+        String imageResourceDir = IMAGE_DIR;
+        
+        //Create a DataSource from an image 
+        File file = new File(imageResourceDir+File.separator+"test.jpg");
+        ImageInputStream fiis = new FileImageInputStream(file);
+        Image image = ImageIO.read(fiis);
+        DataSource imageDS = new DataSourceImpl("image/jpeg","test.jpg",image);
+        
+        //Create a DataHandler with the String DataSource object
+        DataHandler dataHandler = new DataHandler(imageDS);
+        
+        //Store the data handler in ImageDepot bean
+        ImageDepot imageDepot = new ObjectFactory().createImageDepot();
+        imageDepot.setImageData(dataHandler);
+        
+        SendImage request = new ObjectFactory().createSendImage();
+        request.setInput(imageDepot);
+        
+        //Create the necessary JAXBContext
+        JAXBContext jbc = JAXBContext.newInstance("org.test.mtom");
+        
+        MTOMFeature mtom21 = new MTOMFeature();
+
+        // Create the JAX-WS client needed to send the request
+        Service service = Service.create(QNAME_SERVICE);
+        service.addPort(QNAME_PORT, SOAPBinding.SOAP11HTTP_BINDING, URL_ENDPOINT_MTOMDEFAULT);
+        Dispatch<Object> dispatch = service.createDispatch(QNAME_PORT, jbc, Mode.PAYLOAD, mtom21);
+        
+        List cids = null;
+        SendImageResponse response = null;
+        try {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(true);
+            response = (SendImageResponse) dispatch.invoke(request);
+            
+            // The cids are collected in the monitor.  We will check
+            // this to make sure the response mtom is not inlined
+            cids = JAXBAttachmentUnmarshallerMonitor.getBlobCIDs();
+        } finally {
+            JAXBAttachmentUnmarshallerMonitor.setMonitoring(false);
+        }
+        
+        
+        assertNotNull(response);
+        assertNotNull(response.getOutput().getImageData());
+        
+        
+        int numCIDs = (cids == null) ? 0 : cids.size();
+        assertTrue("Expected one attachment but there were:" + numCIDs, numCIDs == 1);
     }
+    
     /*
      * Enable attachment optimization using the SOAP11 binding
      * property for MTOM.

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSample.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSample.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSample.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSample.java Thu Mar 27 09:54:49 2008
@@ -29,7 +29,7 @@
 import javax.xml.ws.RequestWrapper;
 import javax.xml.ws.ResponseWrapper;
 
-@WebService(name = "MtomSample", 
+@WebService(name = "MtomSample",
             targetNamespace = "http://org/apache/axis2/jaxws/sample/mtom", 
             wsdlLocation = "META-INF/ImageDepot.wsdl")
 public interface MtomSample {

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDefaultService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDefaultService.java?rev=641889&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDefaultService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDefaultService.java Thu Mar 27 09:54:49 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.sample.mtom;
+
+
+import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.axis2.jaxws.provider.DataSourceImpl;
+import org.test.mtom.ImageDepot;
+import org.test.mtom.ObjectFactory;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.imageio.ImageIO;
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.SOAPBinding;
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ * Endpoint with default MTOM annotation
+ */
+@WebService(serviceName="MtomSampleService",
+	    endpointInterface="org.apache.axis2.jaxws.sample.mtom.MtomSample")
+//@BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+@MTOM
+public class MtomSampleMTOMDefaultService implements MtomSample {
+
+    public ImageDepot sendImage(ImageDepot input) {
+        TestLogger.logger.debug("MtomSampleMTOMDefaultService [new sendImage request received]");
+        DataHandler data = input.getImageData();
+
+        TestLogger.logger.debug("[contentType] " + data.getContentType());
+        ImageDepot output = (new ObjectFactory()).createImageDepot();
+        Image image = null;
+        
+        resetAttachmentUnmarshallingMonitor();
+        try {
+            InputStream stream = (InputStream) data.getContent();
+            image = ImageIO.read(stream);
+            
+            DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
+            DataHandler handler = new DataHandler(imageDS);
+            output.setImageData(handler);
+        }
+        catch (Exception e) {
+            throw new WebServiceException(e);
+        }
+        return output;
+    }
+
+    public ImageDepot sendText(byte[] input) {
+        TestLogger.logger.debug("[new sendText request received]");
+        return null;
+    }
+
+    /**
+     * Reset the monitor so that we can determine if an
+     * attachment is unmarshalled on the response.
+     */
+    private void resetAttachmentUnmarshallingMonitor() {
+        if (JAXBAttachmentUnmarshallerMonitor.isMonitoring()) {
+            JAXBAttachmentUnmarshallerMonitor.clear();
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisable2Service.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisable2Service.java?rev=641889&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisable2Service.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisable2Service.java Thu Mar 27 09:54:49 2008
@@ -0,0 +1,88 @@
+/*
+ * 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.sample.mtom;
+
+
+import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.axis2.jaxws.provider.DataSourceImpl;
+import org.test.mtom.ImageDepot;
+import org.test.mtom.ObjectFactory;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.imageio.ImageIO;
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.SOAPBinding;
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ * The binding indicates MTOM, but @MTOM indicates enabled=false
+ * Thus no MTOM.
+ */
+@WebService(serviceName="MtomSampleService",
+	    endpointInterface="org.apache.axis2.jaxws.sample.mtom.MtomSample")
+@BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+@MTOM(enabled=false)
+public class MtomSampleMTOMDisable2Service implements MtomSample {
+
+    public ImageDepot sendImage(ImageDepot input) {
+        TestLogger.logger.debug("MtomSampleMTOMDisable2Service [new sendImage request received]");
+        DataHandler data = input.getImageData();
+
+        TestLogger.logger.debug("[contentType] " + data.getContentType());
+        ImageDepot output = (new ObjectFactory()).createImageDepot();
+        Image image = null;
+        
+        resetAttachmentUnmarshallingMonitor();
+        try {
+            InputStream stream = (InputStream) data.getContent();
+            image = ImageIO.read(stream);
+            
+            DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
+            DataHandler handler = new DataHandler(imageDS);
+            output.setImageData(handler);
+        }
+        catch (Exception e) {
+            throw new WebServiceException(e);
+        }
+        return output;
+    }
+
+    public ImageDepot sendText(byte[] input) {
+        TestLogger.logger.debug("[new sendText request received]");
+        return null;
+    }
+
+    /**
+     * Reset the monitor so that we can determine if an
+     * attachment is unmarshalled on the response.
+     */
+    private void resetAttachmentUnmarshallingMonitor() {
+        if (JAXBAttachmentUnmarshallerMonitor.isMonitoring()) {
+            JAXBAttachmentUnmarshallerMonitor.clear();
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisableService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisableService.java?rev=641889&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisableService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMDisableService.java Thu Mar 27 09:54:49 2008
@@ -0,0 +1,88 @@
+/*
+ * 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.sample.mtom;
+
+
+import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.axis2.jaxws.provider.DataSourceImpl;
+import org.test.mtom.ImageDepot;
+import org.test.mtom.ObjectFactory;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.imageio.ImageIO;
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.SOAPBinding;
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+
+/**
+ * Endpoint with MTOM disabled
+ */
+@WebService(serviceName="MtomSampleService",
+	    endpointInterface="org.apache.axis2.jaxws.sample.mtom.MtomSample")
+//@BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+@MTOM(enabled=false)
+public class MtomSampleMTOMDisableService implements MtomSample {
+
+    public ImageDepot sendImage(ImageDepot input) {
+        TestLogger.logger.debug("MtomSampleMTOMDisableService [new sendImage request received]");
+        DataHandler data = input.getImageData();
+
+        TestLogger.logger.debug("[contentType] " + data.getContentType());
+        ImageDepot output = (new ObjectFactory()).createImageDepot();
+        Image image = null;
+        
+        resetAttachmentUnmarshallingMonitor();
+        try {
+            InputStream stream = (InputStream) data.getContent();
+            image = ImageIO.read(stream);
+            
+            DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
+            DataHandler handler = new DataHandler(imageDS);
+            output.setImageData(handler);
+        }
+        catch (Exception e) {
+            throw new WebServiceException(e);
+        }
+        return output;
+    }
+
+    public ImageDepot sendText(byte[] input) {
+        TestLogger.logger.debug("[new sendText request received]");
+        return null;
+    }
+
+    /**
+     * Reset the monitor so that we can determine if an
+     * attachment is unmarshalled on the response.
+     */
+    private void resetAttachmentUnmarshallingMonitor() {
+        if (JAXBAttachmentUnmarshallerMonitor.isMonitoring()) {
+            JAXBAttachmentUnmarshallerMonitor.clear();
+        }
+    }
+}

Added: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMEnableService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMEnableService.java?rev=641889&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMEnableService.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleMTOMEnableService.java Thu Mar 27 09:54:49 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.sample.mtom;
+
+
+import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
+import org.apache.axis2.jaxws.TestLogger;
+import org.apache.axis2.jaxws.provider.DataSourceImpl;
+import org.test.mtom.ImageDepot;
+import org.test.mtom.ObjectFactory;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.imageio.ImageIO;
+import javax.jws.WebService;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.SOAPBinding;
+import java.awt.*;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+/**
+ * Endpoint with MTOM enabled
+ */
+@WebService(serviceName="MtomSampleService",
+	    endpointInterface="org.apache.axis2.jaxws.sample.mtom.MtomSample")
+//@BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
+@MTOM(enabled=true)
+public class MtomSampleMTOMEnableService implements MtomSample {
+
+    public ImageDepot sendImage(ImageDepot input) {
+        TestLogger.logger.debug("MtomSampleMTOMEnableService [new sendImage request received]");
+        DataHandler data = input.getImageData();
+
+        TestLogger.logger.debug("[contentType] " + data.getContentType());
+        ImageDepot output = (new ObjectFactory()).createImageDepot();
+        Image image = null;
+        
+        resetAttachmentUnmarshallingMonitor();
+        try {
+            InputStream stream = (InputStream) data.getContent();
+            image = ImageIO.read(stream);
+            
+            DataSource imageDS = new DataSourceImpl("image/jpeg", "test.jpg", image);
+            DataHandler handler = new DataHandler(imageDS);
+            output.setImageData(handler);
+        }
+        catch (Exception e) {
+            throw new WebServiceException(e);
+        }
+        return output;
+    }
+
+    public ImageDepot sendText(byte[] input) {
+        TestLogger.logger.debug("[new sendText request received]");
+        return null;
+    }
+
+    /**
+     * Reset the monitor so that we can determine if an
+     * attachment is unmarshalled on the response.
+     */
+    private void resetAttachmentUnmarshallingMonitor() {
+        if (JAXBAttachmentUnmarshallerMonitor.isMonitoring()) {
+            JAXBAttachmentUnmarshallerMonitor.clear();
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleService.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleService.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleService.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/mtom/MtomSampleService.java Thu Mar 27 09:54:49 2008
@@ -20,6 +20,7 @@
 package org.apache.axis2.jaxws.sample.mtom;
 
 
+import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
 import org.apache.axis2.jaxws.TestLogger;
 import org.apache.axis2.jaxws.provider.DataSourceImpl;
 import org.test.mtom.ImageDepot;
@@ -31,23 +32,26 @@
 import javax.jws.WebService;
 import javax.xml.ws.BindingType;
 import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.MTOM;
 import javax.xml.ws.soap.SOAPBinding;
 import java.awt.*;
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 
 @WebService(serviceName="MtomSampleService",
-			endpointInterface="org.apache.axis2.jaxws.sample.mtom.MtomSample")
+	    endpointInterface="org.apache.axis2.jaxws.sample.mtom.MtomSample")
 @BindingType(SOAPBinding.SOAP11HTTP_MTOM_BINDING)
 public class MtomSampleService implements MtomSample {
 
     public ImageDepot sendImage(ImageDepot input) {
-        TestLogger.logger.debug("[new sendImage request received]");
+        TestLogger.logger.debug("MtomSampleService [new sendImage request received]");
         DataHandler data = input.getImageData();
 
         TestLogger.logger.debug("[contentType] " + data.getContentType());
         ImageDepot output = (new ObjectFactory()).createImageDepot();
         Image image = null;
+        
+        resetAttachmentUnmarshallingMonitor();
         try {
             InputStream stream = (InputStream) data.getContent();
             image = ImageIO.read(stream);
@@ -67,4 +71,13 @@
         return null;
     }
 
+    /**
+     * Reset the monitor so that we can determine if an
+     * attachment is unmarshalled on the response.
+     */
+    private void resetAttachmentUnmarshallingMonitor() {
+        if (JAXBAttachmentUnmarshallerMonitor.isMonitoring()) {
+            JAXBAttachmentUnmarshallerMonitor.clear();
+        }
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshaller.java Thu Mar 27 09:54:49 2008
@@ -156,7 +156,11 @@
         }
         // Get the attachment from the messagecontext using the blob cid
         if (msgContext != null) {
-            return msgContext.getAttachment(blobcid);
+            DataHandler dh = msgContext.getAttachment(blobcid);
+            if (dh != null) {
+                JAXBAttachmentUnmarshallerMonitor.addBlobCID(blobcid);
+            }
+            return dh;
         }
         return null;
     }

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshallerMonitor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshallerMonitor.java?rev=641889&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshallerMonitor.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/datasource/jaxb/JAXBAttachmentUnmarshallerMonitor.java Thu Mar 27 09:54:49 2008
@@ -0,0 +1,101 @@
+/*
+ * 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.datasource.jaxb;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The monitor is used by the tests to ensure
+ * that the JAXBAttachmentUnmarshaller is used and is functioning correctly.
+ * In normal usage, monitoring is off.
+ */
+public class JAXBAttachmentUnmarshallerMonitor {
+    
+    private static final Log log = LogFactory.getLog(JAXBAttachmentUnmarshallerMonitor.class);
+    private static boolean monitoring = false;
+    private static ArrayList blobCIDs = new ArrayList(); 
+    private static String semifore = "JAXBAttachmentUnmarshallerMonitor";
+    
+    /**
+     * Intentionally private.  All methods are static.
+     */
+    private JAXBAttachmentUnmarshallerMonitor() {
+        
+    }
+
+    /**
+     * @return true if monitoring
+     */
+    public static boolean isMonitoring() {
+        return monitoring;
+    }
+
+    /**
+     * Set monitoring
+     * @param monitoring boolean
+     */
+    public static void setMonitoring(boolean monitoring) {
+        JAXBAttachmentUnmarshallerMonitor.monitoring = monitoring;
+    }
+    
+    /**
+     * Clear the number of creates and failed creates
+     */
+    public static void clear() {
+        synchronized(semifore) {
+            blobCIDs.clear();
+        }
+    }
+
+    /**
+     * @return number of JAXBCustomBuilders created
+     */
+    public static List getBlobCIDs() {
+        synchronized(semifore) {
+            if (log.isDebugEnabled()) {
+                log.debug("NUM BLOB CIDS =" + blobCIDs.size());
+            }
+            return new ArrayList(blobCIDs);
+        }
+        
+    }
+
+    /**
+     * Increase number of total builders 
+     */
+    public static void addBlobCID(String blobCID) {
+        if (log.isDebugEnabled()) {
+            log.debug("call ADD BLOB CID =" + blobCID);
+        }
+        if (isMonitoring()) {
+            synchronized(semifore) {
+                if (log.isDebugEnabled()) {
+                    log.debug("ADD BLOB CID =" + blobCID);
+                }
+                blobCIDs.add(blobCID);
+            }
+        }
+    }
+  
+}

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/message/attachments/JAXBAttachmentUnmarshaller.java Thu Mar 27 09:54:49 2008
@@ -19,6 +19,7 @@
 
 package org.apache.axis2.jaxws.message.attachments;
 
+import org.apache.axis2.datasource.jaxb.JAXBAttachmentUnmarshallerMonitor;
 import org.apache.axis2.jaxws.message.Message;
 
 import javax.activation.DataHandler;
@@ -42,7 +43,11 @@
         
         // Get the attachment from the message using the cid
         if (message != null) {
-            return message.getDataHandler(cid);
+            DataHandler dh = message.getDataHandler(cid);
+            if (dh != null) {
+                JAXBAttachmentUnmarshallerMonitor.addBlobCID(cid);
+            }
+            return dh;
         } 
         return null;
     }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java Thu Mar 27 09:54:49 2008
@@ -216,12 +216,10 @@
         mc.setOperationName(mc.getAxisMessageContext().getAxisOperation().getName());
         mc.setOperationDescription(Utils.getOperationDescription(mc));
         endpointDesc = mc.getEndpointDescription();
-        String bindingType = endpointDesc.getBindingType();
-        if (bindingType != null) {
-            if (BindingUtils.isMTOMBinding(bindingType)) {
-        		mc.getMessage().setMTOMEnabled(true);
-            }
+        if (endpointDesc.isMTOMEnabled()) {
+            mc.getMessage().setMTOMEnabled(true);
         }
+      
         
         //Set SOAP Operation Related properties in SOAPMessageContext.
         ContextUtils.addWSDLProperties(mc);
@@ -309,19 +307,22 @@
         
         // Enable MTOM for the response if necessary.
         // (MTOM is not enabled it this operation has SWA parameters
-        
-        if (m.isDoingSWA()) {
-            EndpointDescription epDesc = request.getEndpointDescription();
-
-            String bindingType = epDesc.getBindingType();
-            if (bindingType != null) {
-                if (BindingUtils.isMTOMBinding(bindingType)) {
-                    if (log.isDebugEnabled()) {
-                        log.debug("MTOM enabled for the response message.");
-                    }
-                    m.setMTOMEnabled(true);
-                }
+           
+        EndpointDescription epDesc = request.getEndpointDescription();
+        String bindingType = epDesc.getBindingType();
+        boolean isMTOMBinding = epDesc.isMTOMEnabled();
+        boolean isDoingSWA = m.isDoingSWA();
+        if (log.isDebugEnabled()) {
+            log.debug("EndpointDescription = " + epDesc.toString());
+            log.debug("BindingType = " + bindingType);
+            log.debug("isMTOMBinding = " + isMTOMBinding);
+            log.debug("isDoingSWA = " + isDoingSWA);
+        }
+        if (!m.isDoingSWA() && isMTOMBinding) {
+            if (log.isDebugEnabled()) {
+                log.debug("MTOM enabled for the response message.");
             }
+            m.setMTOMEnabled(true);
         }
         
         return response;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java Thu Mar 27 09:54:49 2008
@@ -259,12 +259,9 @@
         Message message = request.getMessage();
         if (message != null) {
             
-            // Enable MTOM if indicated by the binding
-            String bindingType = endpointDesc.getBindingType();
-            if (bindingType != null) {
-            	if (BindingUtils.isMTOMBinding(bindingType)) {
-            		message.setMTOMEnabled(true);
-            	}
+            // Enable MTOM if indicated
+            if (endpointDesc.isMTOMEnabled()) {
+                message.setMTOMEnabled(true);
             }
 
             // Save off the protocol info so we can use it when creating the response message.
@@ -340,13 +337,11 @@
         
         MessageContext response = null;
         try {
-            // Enable MTOM if indicated by the binding
-            String bindingType = endpointDesc.getBindingType();
-            if (bindingType != null) {
-            	if (BindingUtils.isMTOMBinding(bindingType)) {
-                	m.setMTOMEnabled(true);
-            	}
+            // Enable MTOM if indicated 
+            if (endpointDesc.isMTOMEnabled()) {
+                m.setMTOMEnabled(true);
             }
+            
 
             response = MessageContextUtils.createResponseMessageContext(request);
             response.setMessage(m);
@@ -619,12 +614,8 @@
         mc.setOperationName(mc.getAxisMessageContext().getAxisOperation().getName());
 
         endpointDesc = mc.getEndpointDescription();
-        String bindingType = endpointDesc.getBindingType();
-
-        if (bindingType != null) {
-            if (BindingUtils.isMTOMBinding(bindingType)) {
-                mc.getMessage().setMTOMEnabled(true);
-            }
+        if (endpointDesc.isMTOMEnabled()) {
+            mc.getMessage().setMTOMEnabled(true);
         }
 
         //Set SOAP Operation Related properties in SOAPMessageContext.

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java Thu Mar 27 09:54:49 2008
@@ -160,6 +160,10 @@
      * Signals whether or not MTOM has been turned on for the endpoint 
      * based on the annotation configuration.
      * 
+     * Both the @MTOM and @BindingType are inspected.  The @MTOM
+     * annotation is inspected first.  If the @MTOM
+     * annotation is not present, then the @BindingType is inspected.
+     * 
      * @return a boolean value 
      */
     public boolean isMTOMEnabled();

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?rev=641889&r1=641888&r2=641889&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java Thu Mar 27 09:54:49 2008
@@ -70,6 +70,8 @@
 import javax.xml.ws.ServiceMode;
 import javax.xml.ws.WebServiceProvider;
 import javax.xml.ws.handler.PortInfo;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.MTOMFeature;
 import javax.xml.ws.soap.SOAPBinding;
 import java.io.InputStream;
 import java.lang.annotation.Annotation;
@@ -183,6 +185,9 @@
     private ServerFramework framework = new ServerFramework();
     
     private Map<String, Object> properties;
+    
+    // Remembers if this endpoint description is MTOMEnabled
+    private Boolean isMTOMEnabledCache = null;
 
     
     /**
@@ -1503,15 +1508,34 @@
      * @see org.apache.axis2.jaxws.description.EndpointDescription#isMTOMEnabled()
      */
     public boolean isMTOMEnabled() {
-        if (axisService != null) {
-            // We should cache this call here so we don't have to make
-            // it on every pass through.
-            Parameter enableMTOM = axisService.getParameter(Configuration.ENABLE_MTOM);
-            if (enableMTOM != null) {
-                return (Boolean) enableMTOM.getValue();
-            }
+        if (isMTOMEnabledCache != null) {
+            return isMTOMEnabledCache.booleanValue();
+        }
+        
+        // isMTOMEnabled is a combination of the @BindingType and the @MTOM setting.
+        MTOM mtomAnnotation =
+                (MTOM) getAnnoFeature(MTOMFeature.ID);
+        
+        // If the @MTOM annotation is set, it wins
+        if (mtomAnnotation != null) {
+            isMTOMEnabledCache = Boolean.valueOf(mtomAnnotation.enabled());
+            return isMTOMEnabledCache.booleanValue();
         }
         
+        // Else look at the bindingType
+        String bindingType = getBindingType();
+        isMTOMEnabledCache = Boolean.valueOf(isMTOMBinding(bindingType));
+        return isMTOMEnabledCache.booleanValue();
+    }
+    
+    private static boolean isMTOMBinding(String url) {
+        if (url != null && 
+               (url.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
+                       url.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING) ||
+                       url.equals(MDQConstants.SOAP11JMS_MTOM_BINDING) ||
+                       url.equals(MDQConstants.SOAP12JMS_MTOM_BINDING))) {
+            return true;
+        }
         return false;
     }
     



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message