cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6861] Prototyping JAXBElementTypedProvider
Date Thu, 07 Apr 2016 17:15:49 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 8cfbd97e0 -> 6c8d2ba81


[CXF-6861] Prototyping JAXBElementTypedProvider


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/6c8d2ba8
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/6c8d2ba8
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/6c8d2ba8

Branch: refs/heads/3.1.x-fixes
Commit: 6c8d2ba818713be47a26541a22a67470235daf96
Parents: 8cfbd97
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Apr 7 18:13:30 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Apr 7 18:15:33 2016 +0100

----------------------------------------------------------------------
 .../provider/JAXBElementTypedProvider.java      | 48 +++++++++++++++++++
 .../cxf/jaxrs/provider/ProviderFactory.java     |  3 +-
 .../cxf/jaxrs/provider/ProviderFactoryTest.java | 50 ++++++++++----------
 3 files changed, 75 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6c8d2ba8/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementTypedProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementTypedProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementTypedProvider.java
new file mode 100644
index 0000000..388035f
--- /dev/null
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementTypedProvider.java
@@ -0,0 +1,48 @@
+/**
+ * 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.jaxrs.provider;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.xml.bind.JAXBElement;
+
+@SuppressWarnings("rawtypes")
+public class JAXBElementTypedProvider extends JAXBElementProvider<JAXBElement>  
+    implements MessageBodyWriter<JAXBElement>, MessageBodyReader<JAXBElement>
{
+    
+    public JAXBElement readFrom(Class<JAXBElement> type, Type genericType, Annotation[]
anns, MediaType mt, 
+        MultivaluedMap<String, String> headers, InputStream is) 
+        throws IOException {
+        return super.readFrom(type, genericType, anns, mt, headers, is);
+    }
+    public void writeTo(JAXBElement<?> obj, Class<?> cls, Type genericType, Annotation[]
anns,  
+        MediaType m, MultivaluedMap<String, Object> headers, OutputStream os) 
+        throws IOException {
+        super.writeTo(obj, cls, genericType, anns, m, headers, os);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/6c8d2ba8/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
index c0bdd1f..f89c6fb 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
@@ -134,7 +134,8 @@ public abstract class ProviderFactory {
                      new FormEncodingProvider<Object>(),
                      new StringTextProvider(),
                      new PrimitiveTextProvider<Object>(),
-                     createProvider(JAXB_PROVIDER_NAME),
+                     new JAXBElementProvider<Object>(),
+                     new JAXBElementTypedProvider(),
                      new MultipartProvider());
         Object prop = factory.getBus().getProperty("skip.default.json.provider.registration");
         if (!PropertyUtils.isTrue(prop)) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/6c8d2ba8/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
index 2f66a70..8da87d5 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
@@ -96,9 +96,9 @@ public class ProviderFactoryTest extends Assert {
         WildcardReader2 reader2 = new WildcardReader2();
         pf.registerUserProvider(reader2);
         List<ProviderInfo<MessageBodyReader<?>>> readers = pf.getMessageReaders();
-        assertEquals(10, readers.size());
-        assertSame(reader1, readers.get(6).getProvider());
-        assertSame(reader2, readers.get(7).getProvider());
+        assertEquals(11, readers.size());
+        assertSame(reader1, readers.get(7).getProvider());
+        assertSame(reader2, readers.get(8).getProvider());
     }
     
     @Test
@@ -124,13 +124,13 @@ public class ProviderFactoryTest extends Assert {
         
         // writers
         List<ProviderInfo<MessageBodyWriter<?>>> writers = pf.getMessageWriters();
-        assertEquals(8, writers.size());
-        Object lastWriter = writers.get(7).getProvider();
+        assertEquals(9, writers.size());
+        Object lastWriter = writers.get(8).getProvider();
         assertTrue(lastWriter instanceof StringTextProvider);
         //readers
         List<ProviderInfo<MessageBodyReader<?>>> readers = pf.getMessageReaders();
-        assertEquals(8, readers.size());
-        Object lastReader = readers.get(7).getProvider();
+        assertEquals(9, readers.size());
+        Object lastReader = readers.get(8).getProvider();
         assertTrue(lastReader instanceof StringTextProvider);
     }
     @Test
@@ -154,13 +154,13 @@ public class ProviderFactoryTest extends Assert {
         
         // writers
         List<ProviderInfo<MessageBodyWriter<?>>> writers = pf.getMessageWriters();
-        assertEquals(8, writers.size());
-        Object lastWriter = writers.get(7).getProvider();
+        assertEquals(9, writers.size());
+        Object lastWriter = writers.get(8).getProvider();
         assertTrue(lastWriter instanceof StringTextProvider);
         //readers
         List<ProviderInfo<MessageBodyReader<?>>> readers = pf.getMessageReaders();
-        assertEquals(8, readers.size());
-        Object lastReader = readers.get(7).getProvider();
+        assertEquals(9, readers.size());
+        Object lastReader = readers.get(8).getProvider();
         assertTrue(lastReader instanceof StringTextProvider);
     }
     @SuppressWarnings("rawtypes")
@@ -188,13 +188,13 @@ public class ProviderFactoryTest extends Assert {
         
         // writers
         List<ProviderInfo<MessageBodyWriter<?>>> writers = pf.getMessageWriters();
-        assertEquals(8, writers.size());
-        Object lastWriter = writers.get(7).getProvider();
+        assertEquals(9, writers.size());
+        Object lastWriter = writers.get(8).getProvider();
         assertFalse(lastWriter instanceof StringTextProvider);
         //readers
         List<ProviderInfo<MessageBodyReader<?>>> readers = pf.getMessageReaders();
-        assertEquals(8, readers.size());
-        Object lastReader = readers.get(7).getProvider();
+        assertEquals(9, readers.size());
+        Object lastReader = readers.get(8).getProvider();
         assertTrue(lastReader instanceof StringTextProvider);
     }
     @Test
@@ -221,13 +221,13 @@ public class ProviderFactoryTest extends Assert {
         
         // writers
         List<ProviderInfo<MessageBodyWriter<?>>> writers = pf.getMessageWriters();
-        assertEquals(8, writers.size());
-        Object lastWriter = writers.get(7).getProvider();
+        assertEquals(9, writers.size());
+        Object lastWriter = writers.get(8).getProvider();
         assertTrue(lastWriter instanceof StringTextProvider);
         //readers
         List<ProviderInfo<MessageBodyReader<?>>> readers = pf.getMessageReaders();
-        assertEquals(8, readers.size());
-        Object lastReader = readers.get(7).getProvider();
+        assertEquals(9, readers.size());
+        Object lastReader = readers.get(8).getProvider();
         assertFalse(lastReader instanceof StringTextProvider);
     }
     
@@ -240,9 +240,9 @@ public class ProviderFactoryTest extends Assert {
         ProviderFactory pf = ServerProviderFactory.createInstance(bus);
         pf.registerUserProvider(wc2);
         List<ProviderInfo<MessageBodyReader<?>>> readers = pf.getMessageReaders();
-        assertEquals(10, readers.size());
-        assertSame(wc2, readers.get(6).getProvider());
-        assertSame(wc1, readers.get(7).getProvider());
+        assertEquals(11, readers.size());
+        assertSame(wc2, readers.get(7).getProvider());
+        assertSame(wc1, readers.get(8).getProvider());
     }
     @Test
     public void testCustomProviderSortingWithBus2() {
@@ -253,9 +253,9 @@ public class ProviderFactoryTest extends Assert {
         ProviderFactory pf = ServerProviderFactory.createInstance(bus);
         pf.registerUserProvider(wc1);
         List<ProviderInfo<MessageBodyReader<?>>> readers = pf.getMessageReaders();
-        assertEquals(10, readers.size());
-        assertSame(wc1, readers.get(6).getProvider());
-        assertSame(wc2, readers.get(7).getProvider());
+        assertEquals(11, readers.size());
+        assertSame(wc1, readers.get(7).getProvider());
+        assertSame(wc2, readers.get(8).getProvider());
     }
     
     @Test


Mime
View raw message