cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1504881 - in /cxf/trunk: api/src/main/java/org/apache/cxf/databinding/ api/src/main/java/org/apache/cxf/interceptor/ rt/core/src/main/java/org/apache/cxf/databinding/source/ rt/core/src/main/java/org/apache/cxf/databinding/stax/ rt/core/sr...
Date Fri, 19 Jul 2013 14:06:01 GMT
Author: dkulp
Date: Fri Jul 19 14:06:00 2013
New Revision: 1504881

URL: http://svn.apache.org/r1504881
Log:
Move closing the XMlStreamReader up to PRE_INVOKE except for the streaming Source cases

Added:
    cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractInterceptorProvidingDataBinding.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/StaxInEndingInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
    cxf/trunk/rt/core/src/test/java/org/apache/cxf/databinding/source/XMLStreamDataReaderTest.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java

Added: cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractInterceptorProvidingDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractInterceptorProvidingDataBinding.java?rev=1504881&view=auto
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractInterceptorProvidingDataBinding.java
(added)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/databinding/AbstractInterceptorProvidingDataBinding.java
Fri Jul 19 14:06:00 2013
@@ -0,0 +1,64 @@
+/**
+ * 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.databinding;
+
+import java.util.List;
+
+import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorProvider;
+import org.apache.cxf.message.Message;
+
+/**
+ * 
+ */
+public abstract class AbstractInterceptorProvidingDataBinding 
+    extends AbstractDataBinding implements InterceptorProvider {
+    
+    protected ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> inInterceptors
+        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+    protected ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> outInterceptors
+        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+    protected ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> outFaultInterceptors
+        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+    protected ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> inFaultInterceptors
+        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
+
+    public AbstractInterceptorProvidingDataBinding() {
+    }
+
+
+    public List<Interceptor<? extends Message>> getInInterceptors() {
+        return inInterceptors;
+    }
+
+    public List<Interceptor<? extends Message>> getOutInterceptors() {
+        return outInterceptors;
+    }
+
+    public List<Interceptor<? extends Message>> getInFaultInterceptors() {
+        return inFaultInterceptors;
+    }
+
+    public List<Interceptor<? extends Message>> getOutFaultInterceptors() {
+        return outFaultInterceptors;
+    }
+
+}

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/StaxInEndingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/StaxInEndingInterceptor.java?rev=1504881&r1=1504880&r2=1504881&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/StaxInEndingInterceptor.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/interceptor/StaxInEndingInterceptor.java Fri
Jul 19 14:06:00 2013
@@ -35,7 +35,10 @@ public class StaxInEndingInterceptor ext
     public static final StaxInEndingInterceptor INSTANCE = new StaxInEndingInterceptor();
     
     public StaxInEndingInterceptor() {
-        super(Phase.POST_INVOKE);
+        super(Phase.PRE_INVOKE);
+    }
+    public StaxInEndingInterceptor(String phase) {
+        super(phase);
     }
 
     public void handleMessage(Message message) throws Fault {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java?rev=1504881&r1=1504880&r2=1504881&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/source/XMLStreamDataReader.java
Fri Jul 19 14:06:00 2013
@@ -45,9 +45,11 @@ import org.apache.cxf.common.logging.Log
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxInEndingInterceptor;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.staxutils.DepthXMLStreamReader;
 import org.apache.cxf.staxutils.FragmentStreamReader;
@@ -167,11 +169,15 @@ public class XMLStreamDataReader impleme
         }
         return null;
     }
-    
     private XMLStreamReader resetForStreaming(XMLStreamReader input) throws XMLStreamException
{
         //Need to mark the message as streaming this so input stream
         //is not closed and additional parts are not read and such
         if (message != null) {
+            if (message.getInterceptorChain() != null) {
+                message.getInterceptorChain().remove(StaxInEndingInterceptor.INSTANCE);
+                message.getInterceptorChain().add(new StaxInEndingInterceptor(Phase.POST_INVOKE));
+            }
+            
             message.removeContent(XMLStreamReader.class);
             final InputStream ins = message.getContent(InputStream.class);
             message.removeContent(InputStream.class);

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java?rev=1504881&r1=1504880&r2=1504881&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/databinding/stax/StaxDataBinding.java Fri
Jul 19 14:06:00 2013
@@ -30,14 +30,17 @@ import javax.xml.validation.Schema;
 
 import org.w3c.dom.Node;
 
-import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
-import org.apache.cxf.databinding.AbstractDataBinding;
+import org.apache.cxf.databinding.AbstractInterceptorProvidingDataBinding;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.StaxInEndingInterceptor;
 import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.MessagePartInfo;
@@ -49,7 +52,7 @@ import org.apache.ws.commons.schema.cons
  * A simple databinding implementation which reads and writes Source objects.
  * This will not work with the standard databinding interceptors.
  */
-public class StaxDataBinding extends AbstractDataBinding {
+public class StaxDataBinding extends AbstractInterceptorProvidingDataBinding {
 
     private XMLStreamDataReader xsrReader;
     private XMLStreamDataWriter xswWriter;
@@ -58,7 +61,26 @@ public class StaxDataBinding extends Abs
         super();
         this.xsrReader = new XMLStreamDataReader();
         this.xswWriter = new XMLStreamDataWriter();
+        inInterceptors.add(new StaxInEndingInterceptor(Phase.POST_INVOKE));
+        inFaultInterceptors.add(new StaxInEndingInterceptor(Phase.POST_INVOKE));
+
+        inInterceptors.add(RemoveStaxInEndingInterceptor.INSTANCE);
+        inFaultInterceptors.add(RemoveStaxInEndingInterceptor.INSTANCE);
+    }
+    
+    static class RemoveStaxInEndingInterceptor extends AbstractPhaseInterceptor<Message>
{
+        static final RemoveStaxInEndingInterceptor INSTANCE = new RemoveStaxInEndingInterceptor();
+        
+        public RemoveStaxInEndingInterceptor() {
+            super(Phase.PRE_INVOKE);
+            addBefore(StaxInEndingInterceptor.class.getName());
+        }
+
+        public void handleMessage(Message message) throws Fault {
+            message.getInterceptorChain().remove(StaxInEndingInterceptor.INSTANCE);
+        }
     }
+    
 
     public void initialize(Service service) {
         for (ServiceInfo serviceInfo : service.getServiceInfos()) {
@@ -148,7 +170,7 @@ public class StaxDataBinding extends Abs
                                                             + obj.getClass() + " are not
supported.");
                 }
             } catch (XMLStreamException e) {
-                throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
+                throw new Fault("COULD_NOT_READ_XML_STREAM", LOG, e);
             }
         }
 

Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/databinding/source/XMLStreamDataReaderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/databinding/source/XMLStreamDataReaderTest.java?rev=1504881&r1=1504880&r2=1504881&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/databinding/source/XMLStreamDataReaderTest.java
(original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/databinding/source/XMLStreamDataReaderTest.java
Fri Jul 19 14:06:00 2013
@@ -43,6 +43,7 @@ public class XMLStreamDataReaderTest ext
     public void testCloseOriginalInputStream() throws Exception {
         XMLStreamDataReader reader = new XMLStreamDataReader();
         Message msg = new MessageImpl();
+        
         TestInputStream in1 = new TestInputStream(DUMMY_DATA);
         
         msg.setContent(InputStream.class, in1);

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=1504881&r1=1504880&r2=1504881&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java Fri
Jul 19 14:06:00 2013
@@ -68,23 +68,20 @@ import org.apache.cxf.common.jaxb.JAXBCo
 import org.apache.cxf.common.jaxb.JAXBContextProxy;
 import org.apache.cxf.common.jaxb.JAXBUtils;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
-import org.apache.cxf.databinding.AbstractDataBinding;
+import org.apache.cxf.databinding.AbstractInterceptorProvidingDataBinding;
 import org.apache.cxf.databinding.AbstractWrapperHelper;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.databinding.WrapperCapableDatabinding;
 import org.apache.cxf.databinding.WrapperHelper;
-import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.jaxb.attachment.JAXBAttachmentSchemaValidationHack;
 import org.apache.cxf.jaxb.io.DataReaderImpl;
 import org.apache.cxf.jaxb.io.DataWriterImpl;
-import org.apache.cxf.message.Message;
 import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.factory.ServiceConstructionException;
@@ -95,7 +92,7 @@ import org.apache.cxf.staxutils.StaxUtil
 import org.apache.cxf.ws.addressing.ObjectFactory;
 
 @NoJSR250Annotations
-public class JAXBDataBinding extends AbstractDataBinding
+public class JAXBDataBinding extends AbstractInterceptorProvidingDataBinding
     implements WrapperCapableDatabinding, InterceptorProvider {
 
     public static final String SCHEMA_RESOURCE = "SCHEMRESOURCE";
@@ -205,15 +202,6 @@ public class JAXBDataBinding extends Abs
     private boolean scanPackages = true;
     private boolean qualifiedSchemas;
 
-    private ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> in
-        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
-    private ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> out
-        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
-    private ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> outFault
-        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
-    private ModCountCopyOnWriteArrayList<Interceptor<? extends Message>> inFault
-        = new ModCountCopyOnWriteArrayList<Interceptor<? extends Message>>();
-
     public JAXBDataBinding() {
     }
 
@@ -306,8 +294,8 @@ public class JAXBDataBinding extends Abs
     @SuppressWarnings("unchecked")
     public synchronized void initialize(Service service) {
 
-        in.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
-        inFault.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
+        inInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
+        inFaultInterceptors.addIfAbsent(JAXBAttachmentSchemaValidationHack.INSTANCE);
 
         // context is already set, don't redo it
         if (context != null) {
@@ -836,19 +824,4 @@ public class JAXBDataBinding extends Abs
                                                           jaxbMethods, fields, objectFactory);
     }
 
-    public List<Interceptor<? extends Message>> getOutFaultInterceptors() {
-        return outFault;
-    }
-
-    public List<Interceptor<? extends Message>> getInFaultInterceptors() {
-        return inFault;
-    }
-
-    public List<Interceptor<? extends Message>> getInInterceptors() {
-        return in;
-    }
-
-    public List<Interceptor<? extends Message>> getOutInterceptors() {
-        return out;
-    }
 }



Mime
View raw message