cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1086615 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/provider/ test/java/org/apache/cxf/jaxrs/provider/
Date Tue, 29 Mar 2011 15:01:20 GMT
Author: sergeyb
Date: Tue Mar 29 15:01:20 2011
New Revision: 1086615

URL: http://svn.apache.org/viewvc?rev=1086615&view=rev
Log:
[JAX-RS] Making sure JAXBProvider does not accept XMLSource if unmarshalAsJaxbElement flag
is set

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java

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=1086615&r1=1086614&r2=1086615&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
Tue Mar 29 15:01:20 2011
@@ -225,7 +225,7 @@ public abstract class AbstractJAXBProvid
             }
         }
         
-        return unmarshalAsJaxbElement || isSupported(type, genericType, anns);
+        return marshalAsJaxbElement || isSupported(type, genericType, anns);
     }
     
     protected JAXBContext getCollectionContext(Class<?> type) throws JAXBException
{
@@ -324,9 +324,13 @@ public abstract class AbstractJAXBProvid
     }
     
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType
mt) {
-        return (marshalAsJaxbElement && type != Response.class) || isSupported(type,
genericType, anns);
+        return canBeReadAsJaxbElement(type) || isSupported(type, genericType, anns);
     }
 
+    protected boolean canBeReadAsJaxbElement(Class<?> type) {
+        return unmarshalAsJaxbElement && type != Response.class;
+    }
+    
     public void setSchemaLocations(List<String> locations) {
         schema = SchemaHandler.createSchema(locations, getBus());    
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=1086615&r1=1086614&r2=1086615&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
Tue Mar 29 15:01:20 2011
@@ -56,6 +56,7 @@ import javax.xml.stream.XMLStreamWriter;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.jaxb.NamespaceMapper;
 import org.apache.cxf.jaxrs.ext.MessageContext;
+import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
@@ -97,6 +98,11 @@ public class JAXBElementProvider extends
         return super.isReadable(type, genericType, anns, mt);
     }
     
+    @Override
+    protected boolean canBeReadAsJaxbElement(Class<?> type) {
+        return type != XMLSource.class && super.canBeReadAsJaxbElement(type);
+    }
+    
     @Context
     public void setMessageContext(MessageContext mc) {
         super.setContext(mc);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1086615&r1=1086614&r2=1086615&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Tue Mar 29 15:01:20 2011
@@ -64,6 +64,7 @@ import org.w3c.dom.Node;
 
 import org.xml.sax.ContentHandler;
 
+import org.apache.cxf.jaxrs.ext.xml.XMLSource;
 import org.apache.cxf.jaxrs.fortest.jaxb.packageinfo.Book2NoRootElement;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@@ -1024,6 +1025,14 @@ public class JAXBElementProviderTest ext
                                  new Annotation[]{}, MediaType.APPLICATION_XML_TYPE));
     }
     
+    
+    @Test 
+    public void testXMLSourceIsNotReadable() {
+        JAXBElementProvider p = new JAXBElementProvider();
+        assertFalse(p.isReadable(XMLSource.class, 
+                                 XMLSource.class, 
+                                 new Annotation[]{}, MediaType.APPLICATION_XML_TYPE));
+    }
     @Test 
     public void testPackageContextObjectFactory() {
         JAXBElementProvider p = new JAXBElementProvider();



Mime
View raw message