cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1060031 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Date Mon, 17 Jan 2011 18:04:29 GMT
Author: sergeyb
Date: Mon Jan 17 18:04:29 2011
New Revision: 1060031

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

........
  r1060030 | sergeyb | 2011-01-17 18:02:31 +0000 (Mon, 17 Jan 2011) | 1 line
  
  [CXF-3247] Supporting providers with no generic parameters
........

Modified:
    cxf/branches/2.3.x-fixes/   (props changed)
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 17 18:04:29 2011
@@ -1 +1 @@
-/cxf/trunk:1059968
+/cxf/trunk:1059968,1060030

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

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=1060031&r1=1060030&r2=1060031&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
Mon Jan 17 18:04:29 2011
@@ -174,7 +174,7 @@ public final class ProviderFactory {
         List<ExceptionMapper<T>> candidates = new LinkedList<ExceptionMapper<T>>();
         
         for (ProviderInfo<ExceptionMapper> em : exceptionMappers) {
-            handleMapper((List)candidates, em, exceptionType, m);
+            handleMapper((List)candidates, em, exceptionType, m, ExceptionMapper.class);
         }
         if (candidates.size() == 0) {
             return null;
@@ -189,7 +189,7 @@ public final class ProviderFactory {
         List<ParameterHandler<T>> candidates = new LinkedList<ParameterHandler<T>>();
         
         for (ProviderInfo<ParameterHandler> em : paramHandlers) {
-            handleMapper((List)candidates, em, paramType, null);
+            handleMapper((List)candidates, em, paramType, null, ParameterHandler.class);
         }
         if (candidates.size() == 0) {
             return null;
@@ -205,7 +205,7 @@ public final class ProviderFactory {
         List<ResponseExceptionMapper<T>> candidates = new LinkedList<ResponseExceptionMapper<T>>();
         
         for (ProviderInfo<ResponseExceptionMapper> em : responseExceptionMappers) {
-            handleMapper((List)candidates, em, paramType, null);
+            handleMapper((List)candidates, em, paramType, null, ResponseExceptionMapper.class);
         }
         if (candidates.size() == 0) {
             return null;
@@ -215,7 +215,7 @@ public final class ProviderFactory {
     }
     
     private static void handleMapper(List<Object> candidates, ProviderInfo em, 
-                                     Class<?> expectedType, Message m) {
+                                     Class<?> expectedType, Message m, Class<?>
providerClass) {
         
         Class<?> mapperClass =  ClassHelper.getRealClass(em.getProvider());
         Type[] types = getGenericInterfaces(mapperClass);
@@ -259,6 +259,8 @@ public final class ProviderFactory {
                         return;
                     }
                 }
+            } else if (t instanceof Class && ((Class<?>)t).isAssignableFrom(providerClass))
{
+                candidates.add(em.getProvider());
             }
         }
     }
@@ -433,7 +435,7 @@ public final class ProviderFactory {
                     InjectionUtils.injectContextMethods(ep.getProvider(), ep, m);
                     return ep.getProvider();
                 }
-                handleMapper((List)candidates, ep, type, m);
+                handleMapper((List)candidates, ep, type, m, MessageBodyReader.class);
             }
         }     
         
@@ -487,7 +489,7 @@ public final class ProviderFactory {
                     InjectionUtils.injectContextMethods(ep.getProvider(), ep, m);
                     return ep.getProvider();
                 }
-                handleMapper((List)candidates, ep, type, m);
+                handleMapper((List)candidates, ep, type, m, MessageBodyWriter.class);
             }
         }     
         if (candidates.size() == 0) {

Modified: cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=1060031&r1=1060030&r2=1060031&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
Mon Jan 17 18:04:29 2011
@@ -233,6 +233,21 @@ public class ProviderFactoryTest extends
     }
     
     @Test
+    public void testMessageBodyWriterNoTypes() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        List<Object> providers = new ArrayList<Object>();
+        SuperBookReaderWriter2 superBookHandler = new SuperBookReaderWriter2();
+        providers.add(superBookHandler);
+        pf.setUserProviders(providers);
+        assertSame(superBookHandler, 
+                   pf.createMessageBodyReader(SuperBook.class, SuperBook.class, new Annotation[]{},

+                                              MediaType.APPLICATION_XML_TYPE, new MessageImpl()));
+        assertSame(superBookHandler, 
+                   pf.createMessageBodyWriter(SuperBook.class, SuperBook.class, new Annotation[]{},

+                                              MediaType.APPLICATION_XML_TYPE, new MessageImpl()));
+    }
+    
+    @Test
     public void testSortEntityProviders() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         pf.registerUserProvider(new TestStringProvider());
@@ -602,6 +617,43 @@ public class ProviderFactoryTest extends
         
     }
     
+    @Produces("application/xml")
+    @Consumes("application/xml")
+    private static class SuperBookReaderWriter2 implements MessageBodyReader, MessageBodyWriter
{
+
+        public boolean isReadable(Class type, Type genericType, Annotation[] annotations,

+                                  MediaType mediaType) {
+            return true;
+        }
+
+        public Object readFrom(Class arg0, Type arg1, Annotation[] arg2, MediaType arg3,

+                                  MultivaluedMap arg4, InputStream arg5) 
+            throws IOException, WebApplicationException {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public long getSize(Object t, Class type, Type genericType, 
+                            Annotation[] annotations, MediaType mediaType) {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+
+        public boolean isWriteable(Class type, Type genericType, 
+                                   Annotation[] annotations, MediaType mediaType) {
+            return true;
+        }
+
+        
+        public void writeTo(Object arg0, Class arg1, Type arg2, 
+                            Annotation[] arg3, MediaType arg4, MultivaluedMap arg5, 
+                            OutputStream arg6) throws IOException, WebApplicationException
{
+            // TODO Auto-generated method stub
+            
+        }
+        
+    }
+    
     private static class TestHandler implements RequestHandler {
 
         public Response handleRequest(Message m, ClassResourceInfo resourceClass) {



Mime
View raw message