cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject svn commit: r439247 - in /incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor: AbstractXMLBindingInterceptor.java XMLMessageInInterceptor.java XMLMessageOutInterceptor.java
Date Fri, 01 Sep 2006 09:29:56 GMT
Author: tli
Date: Fri Sep  1 02:29:56 2006
New Revision: 439247

URL: http://svn.apache.org/viewvc?rev=439247&view=rev
Log:
fix logic of XMLMessageInInterceptor, refactor the package, remove AbstractXMLBindingInterceptor

Removed:
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/AbstractXMLBindingInterceptor.java
Modified:
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
    incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java?rev=439247&r1=439246&r2=439247&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageInInterceptor.java
Fri Sep  1 02:29:56 2006
@@ -19,13 +19,18 @@
 
 package org.apache.cxf.binding.xml.interceptor;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.ResourceBundle;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 
 import org.apache.cxf.bindings.xformat.XMLBindingMessageFormat;
 import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.AbstractInDatabindingInterceptor;
 import org.apache.cxf.interceptor.BareInInterceptor;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.WrappedInInterceptor;
@@ -37,56 +42,71 @@
 import org.apache.cxf.staxutils.StaxUtils;
 
 public class XMLMessageInInterceptor
-                extends AbstractXMLBindingInterceptor {
+                extends AbstractInDatabindingInterceptor {
 
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(WrappedInInterceptor.class);
 
     public void handleMessage(Message message) throws Fault {
+
         XMLStreamReader xsr = message.getContent(XMLStreamReader.class);
         DepthXMLStreamReader dxsr = new DepthXMLStreamReader(xsr);
         Endpoint ep = message.getExchange().get(Endpoint.class);
         BindingInfo service = ep.getEndpointInfo().getBinding();
-        boolean result = false;
+
+        List<Object> parameters = new ArrayList<Object>();
+        DataReader<XMLStreamReader> dr = getDataReader(message);
+        // StaxUtils.nextEvent(xmlReader);
+        while (StaxUtils.toNextElement(dxsr)) {
+            Object o = dr.read(dxsr);
+            parameters.add(o);
+        }
+        if (!StaxUtils.toNextElement(dxsr)) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT",
BUNDLE));
+        }
+        QName startQName = new QName(dxsr.getLocalName(), dxsr.getNamespaceURI());
         for (BindingOperationInfo boi : service.getOperations()) {
-            if (!boi.isUnwrappedCapable()) {
-                // process bare mode
-                MessageInfo mi;
-                if (isRequestor(message)) {
-                    mi = boi.getOperationInfo().getInput();
-                } else {
-                    mi = boi.getOperationInfo().getOutput();
-                }
+            MessageInfo mi;
+            if (isRequestor(message)) {
+                mi = boi.getOperationInfo().getInput();
+            } else {
+                mi = boi.getOperationInfo().getOutput();
+            }
+            QName rootInModel = ((XMLBindingMessageFormat) mi.getExtensor(XMLBindingMessageFormat.class))
+                            .getRootNode();
+            if (rootInModel != null && rootInModel.equals(startQName)) {
                 if (mi.getMessageParts().size() != 1) {
-                    // Part more than 1, needs a root, which should match the
-                    // root defined in wsdl binding
-                    // Retrive the root value from input message xml infoset
-                    if (!StaxUtils.toNextElement(dxsr)) {
-                        throw new Fault(
-                            new org.apache.cxf.common.i18n.Message("NO_OPERATION_ELEMENT",
BUNDLE));
+                    message.getExchange().put(BindingOperationInfo.class, boi);
+                    new BareInInterceptor().handleMessage(message);
+                    break;
+                } else {
+                    if (boi.isUnwrapped()) {
+                        // it's bare with one part and part name equals
+                        // operation name (not support yet)
+                        QName paramName = mi.getMessagePartByIndex(0).getElementQName();
+                        if (paramName.equals(startQName)) {
+                            message.getExchange().put(BindingOperationInfo.class, boi);
+                            new BareInInterceptor().handleMessage(message);
+                            break;
+                        }
+                    } else {
+                        // processing wrap here
+                        message.getExchange().put(BindingOperationInfo.class, boi);
+                        new WrappedInInterceptor().handleMessage(message);
+                        break;
                     }
-                    String rootMsg = dxsr.getLocalName();
-                    String rootInModel = ((XMLBindingMessageFormat) mi
-                                    .getExtensor(XMLBindingMessageFormat.class)).getRootNode();
-                    if (rootInModel != null && rootInModel.equals(rootMsg)) {
+                }
+            } else {
+                // bare with one part and part name not equal operation name,
+                // check param match
+                if (boi.isUnwrapped()) {
+                    QName paramName = mi.getMessagePartByIndex(0).getElementQName();
+                    if (paramName.equals(startQName)) {
                         message.getExchange().put(BindingOperationInfo.class, boi);
                         new BareInInterceptor().handleMessage(message);
-                        result = true;
                         break;
                     }
-                } else {
-                    // Only one part, no root, using the BareInInterceptor inner
-                    // logic to find operation
-                    new BareInInterceptor().handleMessage(message);
-                    result = true;
-                    break;
                 }
-            } else {
-                // process wrap mode
-                new WrappedInInterceptor().handleMessage(message);
             }
-        }
-        if (!result) {
-            // fault processing
         }
     }
 }

Modified: incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java?rev=439247&r1=439246&r2=439247&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/xml/src/main/java/org/apache/cxf/binding/xml/interceptor/XMLMessageOutInterceptor.java
Fri Sep  1 02:29:56 2006
@@ -26,6 +26,7 @@
 
 import org.apache.cxf.bindings.xformat.XMLBindingMessageFormat;
 import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.interceptor.BareOutInterceptor;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.WrappedOutInterceptor;
@@ -33,7 +34,8 @@
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessageInfo;
 
-public class XMLMessageOutInterceptor extends AbstractXMLBindingInterceptor {
+public class XMLMessageOutInterceptor
+                extends AbstractOutDatabindingInterceptor {
 
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(WrappedOutInterceptor.class);
 
@@ -46,32 +48,32 @@
         } else {
             mi = boi.getOperationInfo().getOutput();
         }
-        String rootInModel = ((XMLBindingMessageFormat) mi.getExtensor(XMLBindingMessageFormat.class))
-                        .getRootNode();
-
         if (boi.isUnwrapped()) {
             if (mi.getMessageParts().size() != 1) {
+                QName rootInModel = ((XMLBindingMessageFormat) mi.getExtensor(XMLBindingMessageFormat.class))
+                                .getRootNode();
                 if (rootInModel == null) {
                     throw new RuntimeException("Bare style must define the rootNode in this
case!");
                 }
-                XMLStreamWriter xmlWriter = message.getContent(XMLStreamWriter.class);
-
-                MessageInfo messageInfo = message.get(MessageInfo.class);
-                QName name = messageInfo.getName();
-
-                try {
-                    xmlWriter.writeStartElement(name.getLocalPart(), name.getNamespaceURI());
-                    new BareOutInterceptor().handleMessage(message);
-                    xmlWriter.writeEndElement();
-                } catch (XMLStreamException e) {
-                    throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_READ_EXC",
BUNDLE, e));
-                }
-
+                writeMessage(message, rootInModel);
             } else {
                 new BareOutInterceptor().handleMessage(message);
             }
-
+        } else {
+            QName name = mi.getName();
+            writeMessage(message, name);
         }
     }
 
+    private void writeMessage(Message message, QName name) {
+        XMLStreamWriter xmlWriter = message.getContent(XMLStreamWriter.class);
+        try {
+            xmlWriter.writeStartElement(name.getLocalPart(), name.getNamespaceURI());
+            new BareOutInterceptor().handleMessage(message);
+            xmlWriter.writeEndElement();
+        } catch (XMLStreamException e) {
+            throw new Fault(new org.apache.cxf.common.i18n.Message("STAX_WRITE_EXC", BUNDLE,
e));
+        }
+
+    }
 }



Mime
View raw message