cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r472428 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/databinding/jaxb/src/main/ja...
Date Wed, 08 Nov 2006 08:51:01 GMT
Author: tli
Date: Wed Nov  8 00:51:00 2006
New Revision: 472428

URL: http://svn.apache.org/viewvc?view=rev&rev=472428
Log:
refine the mtom-enabled setting for soap binding

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
    incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataWriter.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ServerMtomXopTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/message/MessageImpl.java Wed Nov
 8 00:51:00 2006
@@ -133,6 +133,11 @@
                 if (val == null) {
                     val = ep.getEndpointInfo().getProperty(key);
                 }
+
+                if (val == null) {
+                    val = ep.getEndpointInfo().getBinding().getProperty(key);
+                }
+
             }
         }
         

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBinding.java
Wed Nov  8 00:51:00 2006
@@ -25,10 +25,6 @@
 import org.apache.cxf.message.MessageImpl;
 
 public class SoapBinding extends AbstractBasicInterceptorProvider implements Binding {
-
-    // default to support mtom, left to config to turn on this feature.
-    private boolean mtomEnabled;
-    
     
     private SoapVersion version;
     
@@ -55,18 +51,7 @@
 
         soapMessage.put(Message.CONTENT_TYPE, version.getContentType());
 
-        if (mtomEnabled) {
-            soapMessage.put(Message.MTOM_ENABLED, Boolean.TRUE);
-        }
         return soapMessage;
-    }
-
-    public boolean isMtomEnabled() {
-        return mtomEnabled;
-    }
-
-    public void setMtomEnabled(boolean enabled) {
-        mtomEnabled = enabled;
     }
 
 }

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Wed Nov  8 00:51:00 2006
@@ -149,11 +149,7 @@
         sb.getInInterceptors().add(new MustUnderstandInterceptor());
         sb.getInInterceptors().add(new StaxInInterceptor());        
         
-        // TODO: We shouldn't be running this interceptor if MTOM isn't enabled
-        // as caching everything is going to slow us down, should set according to config

-        if (sb.isMtomEnabled()) {
-            sb.getOutInterceptors().add(new AttachmentOutInterceptor());
-        }
+        sb.getOutInterceptors().add(new AttachmentOutInterceptor());
         
         sb.getOutInterceptors().add(new StaxOutInterceptor());
         sb.getOutInterceptors().add(new SoapPreProtocolOutInterceptor());

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AttachmentOutInterceptor.java
Wed Nov  8 00:51:00 2006
@@ -44,36 +44,41 @@
     }
 
     public void handleMessage(SoapMessage message) throws Fault {
-        
+
+        if (!Boolean.TRUE.equals(message.getContextualProperty(
+                org.apache.cxf.message.Message.MTOM_ENABLED))) {
+            return;
+        }
+
         OutputStream os = message.getContent(OutputStream.class);
         CachedStream cs = new CachedStream();
         message.setContent(OutputStream.class, cs);
-        
+
         // Calling for soap out interceptor
-        if (!message.getInterceptorChain().doIntercept(message) 
-            && message.getContent(Exception.class) != null) {
+        if (!message.getInterceptorChain().doIntercept(message)
+                && message.getContent(Exception.class) != null) {
             if (message.getContent(Exception.class) instanceof Fault) {
-                throw (Fault)message.getContent(Exception.class);
+                throw (Fault) message.getContent(Exception.class);
             } else {
                 throw new Fault(message.getContent(Exception.class));
             }
         }
         // Set back the output stream
-        message.setContent(OutputStream.class, os);        
+        message.setContent(OutputStream.class, os);
         try {
             Collection<Attachment> attachments = message.getAttachments();
-            cs.flush();            
+            cs.flush();
             if (attachments.size() > 0) {
                 AttachmentSerializer as = new AttachmentSerializer(message, cs.getInputStream(),
os);
                 as.serializeMultipartMessage();
             } else {
                 // get wire connection, and copy xml infoset directly into it
                 os.flush();
-                AbstractCachedOutputStream.copyStream(cs.getInputStream(), os, 64 * 1024);
               
+                AbstractCachedOutputStream.copyStream(cs.getInputStream(), os, 64 * 1024);
             }
         } catch (IOException ioe) {
             throw new SoapFault(new Message("ATTACHMENT_IO", BUNDLE, ioe.toString()), 
-                            SoapFault.ATTACHMENT_IO);
+                    SoapFault.ATTACHMENT_IO);
         }
     }
 

Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataWriter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataWriter.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataWriter.java
(original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/io/MessageDataWriter.java
Wed Nov  8 00:51:00 2006
@@ -46,7 +46,7 @@
     public void write(Object obj, MessagePartInfo part, Message output) {
         // if the mtom is enabled, we need to create the attachment mashaller
         JAXBAttachmentMarshaller am = null;
-        if (output.containsKey(Message.MTOM_ENABLED)) {
+        if (Boolean.TRUE.equals(output.getContextualProperty(Message.MTOM_ENABLED))) {
             am = new JAXBAttachmentMarshaller(output);
             am.setXOPPackage(true);
         }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/binding/soap/SOAPBindingImpl.java
Wed Nov  8 00:51:00 2006
@@ -20,25 +20,26 @@
 package org.apache.cxf.jaxws.binding.soap;
 
 
-import java.util.Iterator;
 import java.util.Set;
 
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPFactory;
 import javax.xml.ws.soap.SOAPBinding;
 
-import org.apache.cxf.binding.soap.SoapBinding;
-import org.apache.cxf.binding.soap.interceptor.AttachmentOutInterceptor;
-import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.jaxws.binding.BindingImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingInfo;
 
 public class SOAPBindingImpl extends BindingImpl implements SOAPBinding {
 
-    private SoapBinding soapBinding;
+    
+    private BindingInfo soapBinding;
+    
     // private SoapBinding soapBinding;
 
-    public SOAPBindingImpl(SoapBinding sb) {
+    public SOAPBindingImpl(BindingInfo sb) {
         soapBinding = sb;
+        
     }
     
     public Set<String> getRoles() {
@@ -50,25 +51,12 @@
     }
 
     public boolean isMTOMEnabled() {
-        return soapBinding.isMtomEnabled();
+        return Boolean.TRUE.equals(soapBinding.getProperty(Message.MTOM_ENABLED));
     }
 
     public void setMTOMEnabled(boolean flag) {
-        if (flag != soapBinding.isMtomEnabled()) {
-            soapBinding.setMtomEnabled(flag);
-            if (flag) {
-                soapBinding.getOutInterceptors().add(new AttachmentOutInterceptor());
-            } else {
-                Iterator<Interceptor> it = soapBinding.getOutInterceptors().iterator();
-                while (it.hasNext()) {
-                    Interceptor intc = it.next();
-                    if (intc instanceof AttachmentOutInterceptor) {
-                        soapBinding.getOutInterceptors().remove(intc);
-                        return;
-                    }
-                }
-            }
-        }
+        
+        soapBinding.setProperty(Message.MTOM_ENABLED, flag);
     }
 
     public MessageFactory getMessageFactory() {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsEndpointImpl.java
Wed Nov  8 00:51:00 2006
@@ -87,7 +87,7 @@
     
     final void createJaxwsBinding() {
         if (getBinding() instanceof SoapBinding) {
-            binding = new SOAPBindingImpl((SoapBinding)getBinding());
+            binding = new SOAPBindingImpl(getEndpointInfo().getBinding());
         } else {
             binding = new BindingImpl();
         }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
Wed Nov  8 00:51:00 2006
@@ -37,7 +37,6 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactoryHelper;
-import org.apache.cxf.binding.soap.SoapBinding;
 import org.apache.cxf.binding.soap.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.MultipartMessageInterceptor;
 import org.apache.cxf.endpoint.Client;
@@ -82,7 +81,7 @@
                 EndpointInfo ei = service.getServiceInfo().getEndpoint(endpointName);
                 service.setInvoker(new JAXWSMethodInvoker(implementor));
                 org.apache.cxf.endpoint.EndpointImpl endpoint = new JaxWsEndpointImpl(bus,
service, ei);
-                SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl((SoapBinding) endpoint.getBinding());

+                SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding()); 
                 jaxWsSoapBinding.setMTOMEnabled(true);
                 modifyBindingInterceptors(endpoint.getBinding().getInInterceptors(), endpoint.getBinding()
                         .getOutInterceptors());
@@ -176,7 +175,7 @@
         EndpointInfo ei = null;
         ei = si.getEndpoint(portName);
         JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
-        SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl((SoapBinding) jaxwsEndpoint.getBinding());
+        SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
         jaxWsSoapBinding.setMTOMEnabled(true);
         modifyBindingInterceptors(jaxwsEndpoint.getBinding().getInInterceptors(), jaxwsEndpoint.getBinding()
                 .getOutInterceptors());

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ServerMtomXopTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ServerMtomXopTest.java?view=diff&rev=472428&r1=472427&r2=472428
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ServerMtomXopTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ServerMtomXopTest.java
Wed Nov  8 00:51:00 2006
@@ -38,7 +38,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactoryHelper;
-import org.apache.cxf.binding.soap.SoapBinding;
+
 import org.apache.cxf.binding.soap.interceptor.AttachmentOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.MultipartMessageInterceptor;
 import org.apache.cxf.endpoint.Client;
@@ -80,7 +80,7 @@
         EndpointInfo ei = service.getServiceInfo().getEndpoint(endpointName);
         service.setInvoker(new JAXWSMethodInvoker(implementor));
         org.apache.cxf.endpoint.EndpointImpl endpoint = new JaxWsEndpointImpl(bus, service,
ei);
-        SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl((SoapBinding) endpoint.getBinding());
+        SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
         jaxWsSoapBinding.setMTOMEnabled(true);
         modifyBindingInterceptors(endpoint.getBinding().getInInterceptors(), endpoint.getBinding()
                 .getOutInterceptors());
@@ -169,7 +169,7 @@
         EndpointInfo ei = null;
         ei = si.getEndpoint(portName);
         JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus, service, ei);
-        SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl((SoapBinding) jaxwsEndpoint.getBinding());
+        SOAPBinding jaxWsSoapBinding = new SOAPBindingImpl(ei.getBinding());
         jaxWsSoapBinding.setMTOMEnabled(true);
         modifyBindingInterceptors(jaxwsEndpoint.getBinding().getInInterceptors(), jaxwsEndpoint.getBinding()
                 .getOutInterceptors());



Mime
View raw message