Author: dkulp
Date: Mon Feb 22 20:58:28 2010
New Revision: 915058

URL: http://svn.apache.org/viewvc?rev=915058&view=rev
Log:
Use original streamreader when possible in JAXB

Modified:
    
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java

Modified: 
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java?rev=915058&r1=915057&r2=915058&view=diff
==============================================================================
--- 
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
 (original)
+++ 
cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
 Mon Feb 22 20:58:28 2010
@@ -69,6 +69,7 @@
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.SchemaInfo;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -744,8 +745,16 @@
             }
             if (source instanceof Node) {
                 obj = unmarshalWithClass ? u.unmarshal((Node)source, clazz) : 
u.unmarshal((Node)source);
+            } else if (source instanceof DepthXMLStreamReader) {
+                // JAXB optimizes a ton of stuff depending on the StreamReader 
impl. Thus,
+                // we REALLY want to pass the original reader in.   This is OK 
with JAXB
+                // as it doesn't read beyond the end so the 
DepthXMLStreamReader state
+                // would be OK when it returns.   The main winner is 
FastInfoset where parsing
+                // a testcase I have goes from about 300/sec to well over 1000.
+                DepthXMLStreamReader dr = (DepthXMLStreamReader)source;
+                obj = unmarshalWithClass ? u.unmarshal(dr.getReader(), clazz) 
: u
+                    .unmarshal(dr.getReader());
             } else if (source instanceof XMLStreamReader) {
-
                 obj = unmarshalWithClass ? 
u.unmarshal((XMLStreamReader)source, clazz) : u
                     .unmarshal((XMLStreamReader)source);
             } else if (source instanceof XMLEventReader) {


Reply via email to