cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1071987 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/staxutils/transform/ rt/core/src/main/java/org/apache/cxf/interceptor/transform/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ systests/jaxrs/src/test/jav...
Date Fri, 18 Feb 2011 12:52:22 GMT
Author: sergeyb
Date: Fri Feb 18 12:52:21 2011
New Revision: 1071987

URL: http://svn.apache.org/viewvc?rev=1071987&view=rev
Log:
[CXF-3338] Blocking the original reader by default

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java?rev=1071987&r1=1071986&r2=1071987&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
Fri Feb 18 12:52:21 2011
@@ -40,16 +40,26 @@ public class InTransformReader extends D
     private QName currentQName;
     private QName previousQName;
     private int previousDepth = -1;
+    private boolean blockOriginalReader = true;
     
     public InTransformReader(XMLStreamReader reader, 
                              Map<String, String> inMap,
-                             Map<String, String> appendMap) {
+                             Map<String, String> appendMap,
+                             boolean blockOriginalReader) {
         super(reader);
         inElementsMap = new QNamesMap(inMap == null ? 0 : inMap.size());
+        this.blockOriginalReader = blockOriginalReader;
         TransformUtils.convertToQNamesMap(inMap, inElementsMap, nsMap);
         TransformUtils.convertToMapOfQNames(appendMap, inAppendMap);
     }
     
+    @Override
+    // If JAXB schema validation is disabled then returning 
+    // the native reader and thus bypassing this reader may work
+    public XMLStreamReader getReader() {
+        return blockOriginalReader ? this : super.getReader();
+    }
+    
     public int next() throws XMLStreamException {
         if (currentQName != null) {
             return XMLStreamConstants.START_ELEMENT;

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java?rev=1071987&r1=1071986&r2=1071987&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/TransformUtils.java
Fri Feb 18 12:52:21 2011
@@ -64,7 +64,8 @@ public final class TransformUtils {
                                                                 InputStream is,
                                                                 List<String> inDropElements,
                                                                 Map<String, String>
inElementsMap,
-                                                                Map<String, String>
inAppendMap) {
+                                                                Map<String, String>
inAppendMap,
+                                                                boolean blockOriginalReader)
{
         if (inDropElements != null) {
             Set<QName> dropElements = XMLUtils.convertStringsToQNames(inDropElements);
             reader = StaxUtils.createFilteredReader(createNewReaderIfNeeded(reader, is),
@@ -72,7 +73,7 @@ public final class TransformUtils {
         }
         if (inElementsMap != null || inAppendMap != null) {
             reader = new InTransformReader(createNewReaderIfNeeded(reader, is),
-                                           inElementsMap, inAppendMap);
+                                           inElementsMap, inAppendMap, blockOriginalReader);
         }
         return reader;
     }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java?rev=1071987&r1=1071986&r2=1071987&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/transform/TransformInInterceptor.java
Fri Feb 18 12:52:21 2011
@@ -38,9 +38,10 @@ import org.apache.cxf.staxutils.transfor
  */
 public class TransformInInterceptor extends AbstractPhaseInterceptor<Message> {
     
-    protected List<String> inDropElements;
-    protected Map<String, String> inElementsMap;
-    protected Map<String, String> inAppendMap;
+    private List<String> inDropElements;
+    private Map<String, String> inElementsMap;
+    private Map<String, String> inAppendMap;
+    private boolean blockOriginalReader = true;
     
     public TransformInInterceptor() {
         super(Phase.POST_STREAM);
@@ -63,7 +64,8 @@ public class TransformInInterceptor exte
         return TransformUtils.createTransformReaderIfNeeded(reader, is,
                                                             inDropElements,
                                                             inElementsMap,
-                                                            inAppendMap);
+                                                            inAppendMap,
+                                                            blockOriginalReader);
     }
     
     public void setInAppendElements(Map<String, String> inElements) {
@@ -78,4 +80,7 @@ public class TransformInInterceptor exte
         this.inElementsMap = inElements;
     }
    
+    public void setBlockOriginalReader(boolean blockOriginalReader) {
+        this.blockOriginalReader = blockOriginalReader;
+    }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=1071987&r1=1071986&r2=1071987&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Fri Feb 18 12:52:21 2011
@@ -645,6 +645,7 @@ public abstract class AbstractJAXBProvid
         return TransformUtils.createTransformReaderIfNeeded(reader, is,
                                                             inDropElements,
                                                             inElementsMap,
-                                                            inAppendMap);
+                                                            inAppendMap,
+                                                            true);
     }
 }

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=1071987&r1=1071986&r2=1071987&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Fri Feb 18 12:52:21 2011
@@ -682,18 +682,34 @@ public class JAXRSSoapBookTest extends A
                                 new QName("http://books.com", "BookService"));
         BookStoreJaxrsJaxws store = service.getBookPort();
         
-        TransformInInterceptor in =  new TransformInInterceptor();
-        Map<String, String> mapIn = new HashMap<String, String>();
-        mapIn.put("*", "{http://jaxws.jaxrs.systest.cxf.apache.org/}*");
-        in.setInTransformElements(mapIn);
-        
         TransformOutInterceptor out =  new TransformOutInterceptor();
         Map<String, String> mapOut = new HashMap<String, String>();
-        mapOut.put("{http://jaxws.jaxrs.systest.cxf.apache.org/}*", "getBookRequest");
+        // Book content (id, name) is unqualified, thus the following works
+        // because JAXB will report 
+        // - {http://jaxws.jaxrs.systest.cxf.apache.org/}Book
+        // - id
+        // - name
+        // and only the qualified top-level Book tag gets matched by the following
+        // mapping
+        mapOut.put("{http://jaxws.jaxrs.systest.cxf.apache.org/}*", "*");
         out.setOutTransformElements(mapOut);
         
+        TransformInInterceptor in =  new TransformInInterceptor();
+        Map<String, String> mapIn = new HashMap<String, String>();
+        // mapIn.put("*", "{http://jaxws.jaxrs.systest.cxf.apache.org/}*");
+        // won't work for a case where a totally unqualified getBookResponse needs to be
+        // qualified such that only the top-level getBookResponse is processed because of
'*'.
+        // Such a mapping would work nicely if we had say a package-info making both
+        // Book id & name qualified; otherwise we need to choose what tag we need to
qualify 
+        
+        // mapIn.put("*", "{http://jaxws.jaxrs.systest.cxf.apache.org/}*");
+        // works too if the schema validation is disabled
+        
+        mapIn.put("getBookResponse", "{http://jaxws.jaxrs.systest.cxf.apache.org/}getBookResponse");
+        in.setInTransformElements(mapIn);
         
         Client cl = ClientProxy.getClient(store);
+        ((HTTPConduit)cl.getConduit()).getClient().setReceiveTimeout(10000000);
         cl.getInInterceptors().add(in);
         cl.getOutInterceptors().add(out);
         

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java?rev=1071987&r1=1071986&r2=1071987&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/jaxws/BookStoreSoapRestImpl.java
Fri Feb 18 12:52:21 2011
@@ -34,6 +34,7 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
 import javax.xml.ws.WebServiceContext;
 
+import org.apache.cxf.annotations.SchemaValidation;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.systest.jaxrs.Book;
@@ -42,7 +43,7 @@ import org.apache.cxf.systest.jaxrs.Book
 import org.apache.cxf.systest.jaxrs.BookSubresource;
 import org.apache.cxf.systest.jaxrs.BookSubresourceImpl;
 
-
+@SchemaValidation
 public class BookStoreSoapRestImpl implements BookStoreJaxrsJaxws {
 
     private Map<Long, Book> books = new HashMap<Long, Book>();

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml?rev=1071987&r1=1071986&r2=1071987&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml Fri Feb
18 12:52:21 2011
@@ -217,7 +217,7 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
       </property>
       <property name="inTransformElements">
         <map>
-         <entry key="*" value="{http://jaxws.jaxrs.systest.cxf.apache.org/}*"/>
+         <entry key="getBook" value="{http://jaxws.jaxrs.systest.cxf.apache.org/}getBook"/>
         </map>
       </property>
    </bean>



Mime
View raw message