cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1056379 - in /cxf/branches/2.3.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/
Date Fri, 07 Jan 2011 16:41:31 GMT
Author: sergeyb
Date: Fri Jan  7 16:41:31 2011
New Revision: 1056379

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

........
  r1056347 | sergeyb | 2011-01-07 15:26:12 +0000 (Fri, 07 Jan 2011) | 1 line
  
  [CXF-3234] Minor update to JAXRSOutInterceptor for response Type be correctly determined
........

Added:
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/StringTextWriter.java
      - copied unchanged from r1056347, cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/StringTextWriter.java
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/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml

Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan  7 16:41:31 2011
@@ -1 +1 @@
-/cxf/trunk:1055184,1055554,1055566,1055582,1055584,1055649,1055817,1055895
+/cxf/trunk:1055184,1055554,1055566,1055582,1055584,1055649,1055817,1055895,1056347

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/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1056379&r1=1056378&r2=1056379&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.3.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Fri Jan  7 16:41:31 2011
@@ -202,22 +202,21 @@ public class JAXRSOutInterceptor extends
             invoked = ori == null ? null : ori.getAnnotatedMethod() == null
                 ? ori.getMethodToInvoke() : ori.getAnnotatedMethod();
         }
+        
         Class<?> targetType = getRawResponseClass(responseObj);
-        Type genericType = 
-            getGenericResponseType(ori == null ? null : invoked, responseObj);
+        Type genericType = getGenericResponseType(ori == null ? null : invoked, responseObj,
targetType);
         if (genericType instanceof TypeVariable) {
             genericType = InjectionUtils.getSuperType(ori.getClassResourceInfo().getServiceClass(),

                                                        (TypeVariable)genericType);
         }
         
+        Annotation[] annotations = invoked != null ? invoked.getAnnotations() : new Annotation[]{};
+        
         MessageBodyWriter writer = null;
         MediaType responseType = null;
         for (MediaType type : availableContentTypes) { 
             writer = ProviderFactory.getInstance(message)
-                .createMessageBodyWriter(targetType, genericType, 
-                      invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
-                      type,
-                      message);
+                .createMessageBodyWriter(targetType, genericType, annotations, type, message);
             
             if (writer != null) {
                 responseType = type;
@@ -239,8 +238,6 @@ public class JAXRSOutInterceptor extends
             LOG.fine("Response content type is: " + responseType.toString());
             message.put(Message.CONTENT_TYPE, responseType.toString());
             
-            Annotation[] annotations = invoked != null ? invoked.getAnnotations() : new Annotation[]{};
-            
             long size = writer.getSize(entity, targetType, genericType, annotations, responseType);
             if (size > 0) {
                 LOG.fine("Setting ContentLength to " + size + " as requested by " 
@@ -409,11 +406,17 @@ public class JAXRSOutInterceptor extends
         }
     }
     
-    private Type getGenericResponseType(Method invoked, Object targetObject) {
+    private Type getGenericResponseType(Method invoked, Object targetObject, Class<?>
targetType) {
         if (GenericEntity.class.isAssignableFrom(targetObject.getClass())) {
             return ((GenericEntity)targetObject).getType();
+        } else if (invoked == null || !invoked.getReturnType().isAssignableFrom(targetType))
{
+            // when a method has been invoked it is still possible that either an ExceptionMapper
+            // or a ResponseHandler filter overrides a response entity; if it happens then

+            // the Type is the class of the response object, unless this new entity is assignable
+            // to invoked.getReturnType(); same applies to the case when a method returns
Response
+            return targetObject.getClass(); 
         } else {
-            return invoked == null ? targetObject.getClass() : invoked.getGenericReturnType();
+            return invoked.getGenericReturnType();
         }
     }
     

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=1056379&r1=1056378&r2=1056379&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
Fri Jan  7 16:41:31 2011
@@ -259,7 +259,7 @@ public class JAXRSClientServerResourceCr
         assertNotNull(in);           
 
         assertEquals("Exception is not mapped correctly", 
-                     "Nonexistent method",
+                     "StringTextWriter - Nonexistent method",
                      getStringFromInputStream(in).trim());
     }
     

Modified: cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1056379&r1=1056378&r2=1056379&view=diff
==============================================================================
--- cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
(original)
+++ cxf/branches/2.3.x-fixes/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
Fri Jan  7 16:41:31 2011
@@ -37,6 +37,7 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
             <bean class="org.apache.cxf.jaxrs.ext.codegen.CodeGeneratorProvider"/>
             <ref bean="exceptionMapper"/>
             <ref bean="exceptionMapper2"/>
+            <ref bean="plainTextProvider"/>
         </jaxrs:providers>
     </jaxrs:server>
     <bean id="bookstore" scope="prototype" class="org.apache.cxf.systest.jaxrs.BookStore"/>
@@ -45,4 +46,5 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
         <property name="toHandle" value="true"/>
     </bean>   
     <bean id="exceptionMapper2" class="org.apache.cxf.systest.jaxrs.RuntimeExceptionMapper"/>
+    <bean id="plainTextProvider" class="org.apache.cxf.systest.jaxrs.StringTextWriter"/>
 </beans>



Mime
View raw message