cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r951348 - in /cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws: DispatchImpl.java ServiceImpl.java
Date Fri, 04 Jun 2010 10:08:00 GMT
Author: ema
Date: Fri Jun  4 10:07:59 2010
New Revision: 951348

URL: http://svn.apache.org/viewvc?rev=951348&view=rev
Log:
[CXF-2836]:Refactor code and fix the build

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java?rev=951348&r1=951347&r2=951348&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/DispatchImpl.java Fri Jun
 4 10:07:59 2010
@@ -55,6 +55,7 @@ import javax.xml.ws.soap.SOAPFaultExcept
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.binding.soap.model.SoapOperationInfo;
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
 import org.apache.cxf.common.i18n.Message;
@@ -289,35 +290,32 @@ public class DispatchImpl<T> implements 
                     wsaEnabled = true; 
                 }
             }
-            if (wsaEnabled) {
-                QName dispatchedOpName = null;
-
+            Map<String, QName> payloadOPMap = 
+                createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo());
+            if (wsaEnabled && !payloadOPMap.isEmpty()) {
+                String payloadElementName = null;              
                 if (obj instanceof javax.xml.transform.Source) {
                     try {
                         XMLStreamReader reader = StaxUtils
                             .createXMLStreamReader((javax.xml.transform.Source)obj);
                         Document document = StaxUtils.read(reader);
-                        dispatchedOpName = getDispatchedOpName(document.getDocumentElement());
-                        if (dispatchedOpName != null) {
-                            createdSource = new StaxSource(StaxUtils.createXMLStreamReader(document));
-                        }
-                    } catch (Exception e) {
-                        createdSource = null;
-                        opName = null;
+                        createdSource = new StaxSource(StaxUtils.createXMLStreamReader(document));
+                        payloadElementName = getPayloadElementName(document.getDocumentElement());
+                    } catch (Exception e) {                        
                         // ignore, we are tring to get the operation name
                     }
                 }
                 if (obj instanceof SOAPMessage) {
-                    dispatchedOpName = getDispatchedOpName((SOAPMessage)obj);
+                    payloadElementName = getPayloadElementName((SOAPMessage)obj);
 
                 }
 
                 if (this.context != null) {
-                    dispatchedOpName = getDispatchedOpName(obj);
+                    payloadElementName = getPayloadElementName(obj);
                 }
 
-                if (dispatchedOpName != null) {
-
+                if (payloadElementName != null) {
+                    QName dispatchedOpName = payloadOPMap.get(payloadElementName);
                     BindingOperationInfo bop = client.getEndpoint().getBinding().getBindingInfo()
                         .getOperation(opName);
                     if (bop != null) {
@@ -375,12 +373,7 @@ public class DispatchImpl<T> implements 
         return client;
     }
     
-    @SuppressWarnings("unchecked")
-    private QName getDispatchedOpName(Element ele) {
-        String payLoadName = null;
-        Map<String, QName> map = (Map<String, QName>)client.getEndpoint().getEndpointInfo().getBinding()
-            .getProperty("payloadElementOpNameMap");
-        
+    private String getPayloadElementName(Element ele) {
         XMLStreamReader xmlreader = StaxUtils.createXMLStreamReader(ele);
         DepthXMLStreamReader reader = new DepthXMLStreamReader(xmlreader);
         try {
@@ -388,46 +381,35 @@ public class DispatchImpl<T> implements 
 
                 StaxUtils.skipToStartOfElement(reader);
 
-                payLoadName = reader.getName().toString();
+                return reader.getName().toString();
             }
             if (this.mode == Service.Mode.MESSAGE) {
                 StaxUtils.skipToStartOfElement(reader);
                 StaxUtils.toNextTag(reader,
                                     new QName("http://schemas.xmlsoap.org/soap/envelope/",
"Body"));
                 reader.nextTag();
-                payLoadName = reader.getName().toString();
+                return reader.getName().toString();
             }
         } catch (XMLStreamException e) {
             // ignore
         }
-        if (map != null && payLoadName != null) {
-            return map.get(payLoadName);
-        }
         return null;
         
     }
     
     
-    @SuppressWarnings("unchecked")
-    private QName getDispatchedOpName(SOAPMessage soapMessage) {
-        String payLoadName = null;
-        Map<String, QName> map = (Map<String, QName>)client.getEndpoint().getEndpointInfo().getBinding()
-            .getProperty("payloadElementOpNameMap");
+    private String getPayloadElementName(SOAPMessage soapMessage) {
         try {            
             SOAPElement element  = (SOAPElement)soapMessage.getSOAPBody().getChildElements().next();
-            payLoadName = new QName(element.getNamespaceURI(), element.getLocalName()).toString();

+            return new QName(element.getNamespaceURI(), element.getLocalName()).toString();
         } catch (Exception e) {
             //ignore
         }
-        
-        if (map != null && payLoadName != null) {
-            return map.get(payLoadName);
-        }
         return null;
         
     }
     
-    private QName getDispatchedOpName(Object object) {
+    private String getPayloadElementName(Object object) {
         JAXBDataBinding dataBinding = new JAXBDataBinding();
         dataBinding.setContext(context);
         DataWriter<XMLStreamWriter> dbwriter = dataBinding.createWriter(XMLStreamWriter.class);
@@ -444,12 +426,36 @@ public class DispatchImpl<T> implements 
 
                 StaxUtils.skipToStartOfElement(reader);
 
-                return reader.getName();
+                return reader.getName().toString();
 
             }
         } catch (XMLStreamException e) {
             // ignore
         }
         return null;
-    }   
+    }
+    
+    private Map<String, QName> createPayloadEleOpNameMap(BindingInfo bindingInfo) {
+        Map<String, QName> payloadElementMap = new java.util.HashMap<String, QName>();
+        for (BindingOperationInfo bop : bindingInfo.getOperations()) {
+            SoapOperationInfo soi = (SoapOperationInfo)bop.getExtensor(SoapOperationInfo.class);
+            if (soi != null) {
+                if ("document".equals(soi.getStyle())) {
+                    // if doc
+                    if (bop.getOperationInfo().getInput() != null
+                        && !bop.getOperationInfo().getInput().getMessageParts().isEmpty())
{
+                        QName qn = bop.getOperationInfo().getInput().getMessagePartByIndex(0)
+                            .getElementQName();
+                        payloadElementMap.put(qn.toString(), bop.getOperationInfo().getName());
+                    }
+                } else if ("rpc".equals(soi.getStyle())) {
+                    // if rpc
+                    payloadElementMap.put(bop.getOperationInfo().getName().toString(), bop.getOperationInfo()
+                        .getName());
+                }
+            }
+        }
+        return payloadElementMap;
+    }
+    
 }

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=951348&r1=951347&r2=951348&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java Fri Jun
 4 10:07:59 2010
@@ -51,14 +51,12 @@ import javax.xml.ws.WebServiceException;
 import javax.xml.ws.WebServiceFeature;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.HandlerResolver;
-import javax.xml.ws.soap.AddressingFeature;
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.ws.spi.ServiceDelegate;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
-import org.apache.cxf.binding.soap.model.SoapOperationInfo;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PackageUtils;
@@ -88,7 +86,6 @@ import org.apache.cxf.service.factory.Ab
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.factory.ServiceConstructionException;
 import org.apache.cxf.service.model.BindingInfo;
-import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.service.model.ServiceModelUtil;
@@ -629,19 +626,7 @@ public class ServiceImpl extends Service
         if (executor != null) {
             client.getEndpoint().setExecutor(executor);
         }
-        
-        //CXF-2836:create wsdlOperation name and payloadElement Map
-        boolean wsaFeature = false;
-        for (WebServiceFeature feature : features) {
-            if (feature instanceof AddressingFeature 
-                && ((AddressingFeature)feature).isEnabled()) {
-                wsaFeature = true;
-            }
-        }
-        if (wsaFeature) {
-            createPayloadEleOpNameMap(client.getEndpoint().getEndpointInfo().getBinding());
-        }
-        
+                
         Dispatch<T> disp = new DispatchImpl<T>(client, mode, type);
         configureObject(disp);
         return disp;
@@ -691,17 +676,7 @@ public class ServiceImpl extends Service
         if (executor != null) {
             client.getEndpoint().setExecutor(executor);
         }
-        //CXF-2836:create wsdlOperation name and payloadElement Map
-        boolean wsaFeature = false;
-        for (WebServiceFeature feature : features) {
-            if (feature instanceof AddressingFeature 
-                && ((AddressingFeature)feature).isEnabled()) {
-                wsaFeature = true;
-            }
-        }
-        if (wsaFeature) {
-            createPayloadEleOpNameMap(client.getEndpoint().getEndpointInfo().getBinding());
-        }        
+        
         Dispatch<Object> disp = new DispatchImpl<Object>(client, mode, 
                                                          context, Object.class);
         configureObject(disp);
@@ -732,31 +707,7 @@ public class ServiceImpl extends Service
         client.getOutInterceptors().addAll(clientFact.getOutInterceptors());
         client.getInFaultInterceptors().addAll(clientFact.getInFaultInterceptors());
         client.getOutFaultInterceptors().addAll(clientFact.getOutFaultInterceptors());
-    }
-
-    // Create payload element and operationName map
-    private void createPayloadEleOpNameMap(BindingInfo bindingInfo) {
-        Map<String, QName> payloadElementMap = new java.util.HashMap<String, QName>();
-        for (BindingOperationInfo bop : bindingInfo.getOperations()) {
-            SoapOperationInfo soi = (SoapOperationInfo)bop.getExtensor(SoapOperationInfo.class);
-            if (soi != null) {
-                if ("document".equals(soi.getStyle())) {
-                    // if doc
-                    if (bop.getOperationInfo().getInput() != null
-                        && !bop.getOperationInfo().getInput().getMessageParts().isEmpty())
{
-                        QName qn = bop.getOperationInfo().getInput().getMessagePartByIndex(0)
-                            .getElementQName();
-                        payloadElementMap.put(qn.toString(), bop.getOperationInfo().getName());
-                    }
-                } else if ("rpc".equals(soi.getStyle())) {
-                    // if rpc
-                    payloadElementMap.put(bop.getOperationInfo().getName().toString(), bop.getOperationInfo()
-                        .getName());
-                }
-            }
-        }
-        bindingInfo.setProperty("payloadElementOpNameMap", payloadElementMap);
-    }
+    }    
 }
 
 



Mime
View raw message