cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r767159 - in /cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors: DispatchInDatabindingInterceptor.java DispatchOutDatabindingInterceptor.java
Date Tue, 21 Apr 2009 14:37:30 GMT
Author: dkulp
Date: Tue Apr 21 14:37:30 2009
New Revision: 767159

URL: http://svn.apache.org/viewvc?rev=767159&view=rev
Log:
[CXF-2181] Cache message factories for dispatch/provider stuff as well.

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java?rev=767159&r1=767158&r2=767159&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchInDatabindingInterceptor.java
Tue Apr 21 14:37:30 2009
@@ -49,7 +49,6 @@
 
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.soap.Soap11;
-import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.common.logging.LogUtils;
@@ -57,7 +56,6 @@
 import org.apache.cxf.databinding.source.NodeDataReader;
 import org.apache.cxf.databinding.source.XMLStreamDataReader;
 import org.apache.cxf.endpoint.Endpoint;
-//import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.XMLUtils;
@@ -75,9 +73,6 @@
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.message.XMLMessage;
 import org.apache.cxf.phase.Phase;
-//import org.apache.cxf.service.model.BindingOperationInfo;
-//import org.apache.cxf.service.model.MessageInfo;
-//import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceModelUtil;
@@ -86,8 +81,10 @@
 public class DispatchInDatabindingInterceptor extends AbstractInDatabindingInterceptor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(DispatchInDatabindingInterceptor.class);
-    private Class type;
-    private Service.Mode mode;
+    private final Class type;
+    private final Service.Mode mode;
+    private MessageFactory soap11Factory;
+    private MessageFactory soap12Factory;
     
     public DispatchInDatabindingInterceptor(Class type, Mode mode) {
         super(Phase.READ);
@@ -95,7 +92,21 @@
         this.type = type;
         this.mode = mode;
     }
-
+    private MessageFactory getFactory(SoapMessage message) throws SOAPException {
+        return getFactory(message.getVersion());
+    }
+    private synchronized MessageFactory getFactory(SoapVersion version) throws SOAPException
{
+        if (version instanceof Soap11) {
+            if (soap11Factory == null) { 
+                soap11Factory = MessageFactory.newInstance();
+            } 
+            return soap11Factory;
+        }
+        if (soap12Factory == null) {
+            soap12Factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+        }
+        return soap12Factory;
+    }
     public void handleMessage(Message message) throws Fault {
         Exchange ex = message.getExchange();     
         
@@ -184,8 +195,6 @@
     }    
     
     private SOAPMessage newSOAPMessage(InputStream is, SoapMessage msg) throws Exception
{
-        SoapVersion version = msg.getVersion();
-
         MimeHeaders headers = new MimeHeaders();
         if (msg.containsKey(Message.PROTOCOL_HEADERS)) {
             Map<String, List<String>> heads = CastUtils.cast((Map<?, ?>)msg.get(Message.PROTOCOL_HEADERS));
@@ -196,13 +205,7 @@
             }
         }
         
-        MessageFactory msgFactory = null;
-        if (version == null || version instanceof Soap11) {
-            msgFactory = MessageFactory.newInstance();
-        } else if (version instanceof Soap12) {
-            msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
-        }
-        return msgFactory.createMessage(headers, is);
+        return getFactory(msg).createMessage(headers, is);
     }
 
     void setupBindingOperationInfo(Exchange exch, SOAPMessage msg) {
@@ -324,13 +327,7 @@
 
                 if (SOAPMessage.class.isAssignableFrom(type)) {
                     try {
-                        SoapVersion version = ((SoapMessage)message).getVersion();
-                        MessageFactory msgFactory = null;
-                        if (version == null || version instanceof Soap11) {
-                            msgFactory = MessageFactory.newInstance();
-                        } else if (version instanceof Soap12) {
-                            msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
-                        }
+                        MessageFactory msgFactory = getFactory((SoapMessage)message);
                         SOAPMessage msg = msgFactory.createMessage();
                         msg.getSOAPPart().setContent(source);
                         

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java?rev=767159&r1=767158&r2=767159&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/DispatchOutDatabindingInterceptor.java
Tue Apr 21 14:37:30 2009
@@ -52,7 +52,6 @@
 
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.soap.Soap11;
-import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.SoapVersion;
 import org.apache.cxf.common.WSDLConstants;
@@ -78,7 +77,9 @@
     private static final Logger LOG = LogUtils.getL7dLogger(DispatchOutDatabindingInterceptor.class);
     private DispatchOutDatabindingEndingInterceptor ending;
     
-    private Service.Mode mode;
+    private final Service.Mode mode;
+    private MessageFactory soap11Factory;
+    private MessageFactory soap12Factory;
     
     public DispatchOutDatabindingInterceptor(Mode mode) {
         super(Phase.WRITE);
@@ -86,7 +87,21 @@
         
         this.mode = mode;
     }
-
+    private MessageFactory getFactory(SoapMessage message) throws SOAPException {
+        return getFactory(message.getVersion());
+    }
+    private synchronized MessageFactory getFactory(SoapVersion version) throws SOAPException
{
+        if (version instanceof Soap11) {
+            if (soap11Factory == null) { 
+                soap11Factory = MessageFactory.newInstance();
+            } 
+            return soap11Factory;
+        }
+        if (soap12Factory == null) {
+            soap12Factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+        }
+        return soap12Factory;
+    }
     public void handleMessage(Message message) throws Fault {
         Object obj = null;
         Object result = message.getContent(List.class);
@@ -337,13 +352,7 @@
                     }
                 } else {
                     try {
-                        SoapVersion version = ((SoapMessage)message).getVersion();
-                        MessageFactory msgFactory = null;
-                        if (version == null || version instanceof Soap11) {
-                            msgFactory = MessageFactory.newInstance();
-                        } else if (version instanceof Soap12) {
-                            msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
-                        }
+                        MessageFactory msgFactory = getFactory((SoapMessage)message);
                         SOAPMessage msg = msgFactory.createMessage();
                         msg.getSOAPPart().setContent(source);
                         if (message.getAttachments() != null) {
@@ -375,12 +384,7 @@
         SOAPMessage msg = null;
         
         MimeHeaders headers = new MimeHeaders();
-        MessageFactory msgFactory = null;
-        if (version == null || version instanceof Soap11) {
-            msgFactory = MessageFactory.newInstance();
-        } else if (version instanceof Soap12) {
-            msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
-        }
+        MessageFactory msgFactory = getFactory(version);
         
         if (is != null) {
             msg = msgFactory.createMessage(headers, is);



Mime
View raw message