cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r604295 - in /incubator/cxf/trunk/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ core/src/main/java/org/apache/cxf/interceptor/ databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/
Date Fri, 14 Dec 2007 21:09:48 GMT
Author: dkulp
Date: Fri Dec 14 13:09:46 2007
New Revision: 604295

URL: http://svn.apache.org/viewvc?rev=604295&view=rev
Log:
[CXF-1296] Support for reading from doms for Aegis.   Allow header interceptor to use StreamReaders
if nodes aren't supported

Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
  (with props)
Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java?rev=604295&r1=604294&r2=604295&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapHeaderInterceptor.java
Fri Dec 14 13:09:46 2007
@@ -21,6 +21,10 @@
 
 import java.util.List;
 
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -37,6 +41,7 @@
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.W3CDOMStreamReader;
 
 /**
  * Perform databinding of the SOAP headers.
@@ -81,6 +86,7 @@
             return;
         }
         
+        boolean supportsNode = this.supportsDataReader(message, Node.class);
         for (SoapHeaderInfo header : headers) {
             MessagePartInfo mpi = header.getPart();
             Header param = findHeader(message, mpi);
@@ -91,7 +97,17 @@
                 
                 if (param.getDataBinding() == null) {
                     Node source = (Node)param.getObject();
-                    object = getNodeDataReader(message).read(mpi, source);
+                    if (supportsNode) {
+                        object = getNodeDataReader(message).read(mpi, source);
+                    } else {
+                        W3CDOMStreamReader reader = new W3CDOMStreamReader((Element)source);
+                        try {
+                            reader.nextTag(); //advance into the first tag
+                        } catch (XMLStreamException e) {
+                            //ignore
+                        } 
+                        object = getDataReader(message, XMLStreamReader.class).read(mpi,
reader);
+                    }
                 } else {
                     object = param.getObject();
                 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java?rev=604295&r1=604294&r2=604295&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractInDatabindingInterceptor.java
Fri Dec 14 13:09:46 2007
@@ -63,7 +63,17 @@
     protected boolean isRequestor(Message message) {
         return Boolean.TRUE.equals(message.get(Message.REQUESTOR_ROLE));
     }
-
+ 
+    protected boolean supportsDataReader(Message message, Class<?> input) {
+        Service service = ServiceModelUtil.getService(message.getExchange());
+        Class<?> cls[] = service.getDataBinding().getSupportedReaderFormats();
+        for (Class<?> c : cls) {
+            if (c.equals(input)) {
+                return true;
+            }
+        }
+        return false;
+    }
     protected <T> DataReader<T> getDataReader(Message message, Class<T>
input) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataReader<T> dataReader = service.getDataBinding().createReader(input);

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java?rev=604295&r1=604294&r2=604295&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/AegisDatabinding.java
Fri Dec 14 13:09:46 2007
@@ -103,6 +103,8 @@
     public <T> DataReader<T> createReader(Class<T> cls) {
         if (cls.equals(XMLStreamReader.class)) {
             return (DataReader<T>) new XMLStreamDataReader(this);
+        } else if (cls.equals(Node.class)) {
+            return (DataReader<T>) new ElementDataReader(this);
         } else {
             throw new UnsupportedOperationException();
         }
@@ -120,7 +122,7 @@
     }
 
     public Class<?>[] getSupportedReaderFormats() {
-        return new Class[] {XMLStreamReader.class};
+        return new Class[] {XMLStreamReader.class, Node.class};
     }
 
     public Class<?>[] getSupportedWriterFormats() {

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java?rev=604295&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
Fri Dec 14 13:09:46 2007
@@ -0,0 +1,94 @@
+/**
+ * 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.cxf.aegis.databinding;
+
+import java.util.Collection;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.validation.Schema;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.databinding.DataReader;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.W3CDOMStreamReader;
+
+/**
+ * 
+ */
+public class ElementDataReader implements DataReader<Element> {
+    XMLStreamDataReader reader;
+    
+    ElementDataReader(AegisDatabinding binding) {
+        reader = new XMLStreamDataReader(binding);
+    }
+
+    /** {@inheritDoc}*/
+    public Object read(Element input) {
+        try {
+            W3CDOMStreamReader sreader = new W3CDOMStreamReader(input);
+            sreader.nextTag(); //advance into the first tag
+            return reader.read(sreader);
+        } catch (XMLStreamException e) {
+            throw new Fault(e);
+        }
+    }
+
+    /** {@inheritDoc}*/
+    public Object read(MessagePartInfo part, Element input) {
+        try {
+            W3CDOMStreamReader sreader = new W3CDOMStreamReader(input);
+            sreader.nextTag(); //advance into the first tag
+            return reader.read(part, sreader);
+        } catch (XMLStreamException e) {
+            throw new Fault(e);
+        }
+    }
+
+    /** {@inheritDoc}*/
+    public Object read(QName name, Element input, Class type) {
+        try {
+            W3CDOMStreamReader sreader = new W3CDOMStreamReader(input);
+            sreader.nextTag(); //advance into the first tag
+            return reader.read(name, sreader, type);
+        } catch (XMLStreamException e) {
+            throw new Fault(e);
+        }
+    }
+
+    /** {@inheritDoc}*/
+    public void setAttachments(Collection<Attachment> attachments) {
+        reader.setAttachments(attachments);
+    }
+
+    /** {@inheritDoc}*/
+    public void setProperty(String prop, Object value) {
+        reader.setProperty(prop, value);
+    }
+
+    /** {@inheritDoc}*/
+    public void setSchema(Schema s) {
+        reader.setSchema(s);
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ElementDataReader.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message