cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r892990 - in /cxf/branches/2.2.x-fixes: ./ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ systests/ja...
Date Mon, 21 Dec 2009 21:35:22 GMT
Author: dkulp
Date: Mon Dec 21 21:35:21 2009
New Revision: 892990

URL: http://svn.apache.org/viewvc?rev=892990&view=rev
Log:
Merged revisions 892988 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r892988 | dkulp | 2009-12-21 16:33:08 -0500 (Mon, 21 Dec 2009) | 1 line
  
  [CXF-2422] Change the jaxrs DataBindingProvider to support generics
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingProviderTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec 21 21:35:21 2009
@@ -1 +1 @@
-/cxf/trunk:891375-891393,891452,891817,891827,891859,891945-891946,892056,892307,892360,892664,892890,892920,892953
+/cxf/trunk:891375-891393,891452,891817,891827,891859,891945-891946,892056,892307,892360,892664,892890,892920,892953,892988

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java?rev=892990&r1=892989&r2=892990&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapBindingFactory.java
Mon Dec 21 21:35:21 2009
@@ -20,6 +20,7 @@
 package org.apache.cxf.binding.soap;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProvider.java?rev=892990&r1=892989&r2=892990&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProvider.java
Mon Dec 21 21:35:21 2009
@@ -40,7 +40,7 @@
 @Provider
 @Produces("application/json")
 @Consumes("application/json")
-public class DataBindingJSONProvider extends DataBindingProvider {
+public class DataBindingJSONProvider<T> extends DataBindingProvider<T> {
     
     private List<String> arrayKeys;
     private boolean serializeAsArray;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java?rev=892990&r1=892989&r2=892990&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DataBindingProvider.java
Mon Dec 21 21:35:21 2009
@@ -43,7 +43,7 @@
 @Provider
 @Produces({"application/xml", "application/*+xml", "text/xml" })
 @Consumes({"application/xml", "application/*+xml", "text/xml" })
-public class DataBindingProvider implements MessageBodyReader<Object>, MessageBodyWriter<Object>
{
+public class DataBindingProvider<T> implements MessageBodyReader<T>, MessageBodyWriter<T>
{
 
     private DataBinding binding;
     
@@ -62,13 +62,14 @@
         return true;
     }
 
-    public Object readFrom(Class<Object> clazz, Type genericType, Annotation[] annotations,
MediaType type, 
-                       MultivaluedMap<String, String> headers, InputStream is)
+    public T readFrom(Class<T> clazz, Type genericType, Annotation[] annotations, MediaType
type, 
+                      MultivaluedMap<String, String> headers, InputStream is)
         throws IOException {
         try {
             XMLStreamReader reader = createReader(clazz, genericType, is);
             DataReader<XMLStreamReader> dataReader = binding.createReader(XMLStreamReader.class);
-            return dataReader.read(null, reader, clazz);
+            Object o = dataReader.read(null, reader, clazz);
+            return o == null ? null : clazz.cast(o);
         } catch (Exception ex) {
             throw new WebApplicationException(ex);
         }
@@ -79,7 +80,7 @@
         return StaxUtils.createXMLStreamReader(is);
     }
     
-    public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
+    public long getSize(T t, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         if (byte[].class.isAssignableFrom(t.getClass())) {
             return ((byte[])t).length;
         }
@@ -90,7 +91,7 @@
         return true;
     }
 
-    public void writeTo(Object o, Class<?> clazz, Type genericType, Annotation[] annotations,

+    public void writeTo(T o, Class<?> clazz, Type genericType, Annotation[] annotations,

                         MediaType type, MultivaluedMap<String, Object> headers, OutputStream
os)
         throws IOException {
         try {

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java?rev=892990&r1=892989&r2=892990&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingJSONProviderTest.java
Mon Dec 21 21:35:21 2009
@@ -60,7 +60,7 @@
         Service s = new JAXRSServiceImpl(Collections.singletonList(c), true);
         DataBinding binding = new JAXBDataBinding();
         binding.initialize(s);
-        DataBindingJSONProvider p = new DataBindingJSONProvider();
+        DataBindingJSONProvider<Book> p = new DataBindingJSONProvider<Book>();
         p.setDataBinding(binding);
         Book b = new Book("CXF", 127L);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -93,7 +93,7 @@
         s.put("writeXsiType", true);
         AegisDatabinding binding = new AegisDatabinding();
         binding.initialize(s);
-        DataBindingJSONProvider p = new DataBindingJSONProvider();
+        DataBindingJSONProvider<Book> p = new DataBindingJSONProvider<Book>();
         p.setDataBinding(binding);
         Book b = new Book("CXF", 127L);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -109,7 +109,7 @@
         s.put("writeXsiType", true);
         AegisDatabinding binding = new AegisDatabinding();
         binding.initialize(s);
-        DataBindingJSONProvider p = new DataBindingJSONProvider();
+        DataBindingJSONProvider<List<Book>> p = new DataBindingJSONProvider<List<Book>>();
         p.setDataBinding(binding);
         
         Book b = new Book("CXF", 127L);

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingProviderTest.java?rev=892990&r1=892989&r2=892990&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/DataBindingProviderTest.java
Mon Dec 21 21:35:21 2009
@@ -60,7 +60,7 @@
         s.put("writeXsiType", true);
         AegisDatabinding binding = new AegisDatabinding();
         binding.initialize(s);
-        DataBindingProvider p = new DataBindingProvider(binding);
+        DataBindingProvider<Book> p = new DataBindingProvider<Book>(binding);
         Book b = new Book("CXF", 127L);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         p.writeTo(b, Book.class, Book.class,
@@ -96,7 +96,7 @@
         Service s = new JAXRSServiceImpl(Collections.singletonList(c), true);
         DataBinding binding = new JAXBDataBinding();
         binding.initialize(s);
-        DataBindingProvider p = new DataBindingProvider(binding);
+        DataBindingProvider<Book> p = new DataBindingProvider<Book>(binding);
         Book b = new Book("CXF", 127L);
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         p.writeTo(b, Book.class, Book.class,
@@ -105,18 +105,17 @@
         assertEquals(bos.toString(), data);
     }
     
-    @SuppressWarnings("unchecked")
     @Test
     public void testJAXBRead() throws Exception {
         String data = "<Book><id>127</id><name>CXF</name><state></state></Book>";
         Service s = new JAXRSServiceImpl(Collections.singletonList(c), true);
         DataBinding binding = new JAXBDataBinding();
         binding.initialize(s);
-        DataBindingProvider p = new DataBindingProvider(binding);
+        DataBindingProvider<Book> p = new DataBindingProvider<Book>(binding);
         ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
-        Book book = (Book)p.readFrom((Class)Book.class, Book.class,
-                                      new Annotation[0], MediaType.APPLICATION_XML_TYPE,

-                                      new MetadataMap<String, String>(), is);
+        Book book = p.readFrom(Book.class, Book.class,
+                               new Annotation[0], MediaType.APPLICATION_XML_TYPE, 
+                               new MetadataMap<String, String>(), is);
         assertEquals("CXF", book.getName());
         assertEquals(127L, book.getId());
     }

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java?rev=892990&r1=892989&r2=892990&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSDataBindingTest.java
Mon Dec 21 21:35:21 2009
@@ -54,5 +54,4 @@
         assertEquals("CXF in Action", book.getName());
     }
     
-    
 }



Mime
View raw message