cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1479874 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Tue, 07 May 2013 12:12:27 GMT
Author: sergeyb
Date: Tue May  7 12:12:26 2013
New Revision: 1479874

URL: http://svn.apache.org/r1479874
Log:
[CXF-4988] Minor update to the way readers/writers manage tcontent types

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractInterceptorContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractInterceptorContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractInterceptorContextImpl.java?rev=1479874&r1=1479873&r2=1479874&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractInterceptorContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractInterceptorContextImpl.java
Tue May  7 12:12:26 2013
@@ -21,8 +21,6 @@ package org.apache.cxf.jaxrs.impl;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.cxf.message.Message;
 
 public class AbstractInterceptorContextImpl extends AbstractPropertiesImpl {
@@ -30,16 +28,13 @@ public class AbstractInterceptorContextI
     private Class<?> cls;
     private Type type;
     private Annotation[] anns;
-    private MediaType mt;
     public AbstractInterceptorContextImpl(Class<?> cls,
                                         Type type,
                                         Annotation[] anns,
-                                        MediaType mt,
                                         Message message) {
         super(message);
         this.cls = cls;
         this.type = type;
-        this.mt = mt;
         this.anns = anns;
     }
     
@@ -55,10 +50,6 @@ public class AbstractInterceptorContextI
         return type;
     }
 
-    public MediaType getMediaType() {
-        return mt;
-    }
-
     public void setAnnotations(Annotation[] annotations) {
         anns = annotations;
 
@@ -68,10 +59,6 @@ public class AbstractInterceptorContextI
         type = genType;
     }
 
-    public void setMediaType(MediaType mtype) {
-        mt = mtype;
-    }
-
     public void setType(Class<?> ctype) {
         cls = ctype;
     }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java?rev=1479874&r1=1479873&r2=1479874&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
Tue May  7 12:12:26 2013
@@ -25,11 +25,13 @@ import java.lang.reflect.Type;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.ReaderInterceptor;
 import javax.ws.rs.ext.ReaderInterceptorContext;
 
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 
 public class ReaderInterceptorContextImpl extends AbstractInterceptorContextImpl 
@@ -40,11 +42,10 @@ public class ReaderInterceptorContextImp
     public ReaderInterceptorContextImpl(Class<?> cls,
                                         Type type,
                                         Annotation[] anns,
-                                        MediaType mt,
                                         InputStream is,
                                         Message message,
                                         List<ReaderInterceptor> readers) {
-        super(cls, type, anns, mt, message);
+        super(cls, type, anns, message);
         this.is = is;
         this.readers = readers;
     }
@@ -77,4 +78,15 @@ public class ReaderInterceptorContextImp
 
     }
 
+    @Override
+    public MediaType getMediaType() {
+        return JAXRSUtils.toMediaType(getHeaders().getFirst(HttpHeaders.CONTENT_TYPE));
+    }
+
+    @Override
+    public void setMediaType(MediaType mt) {
+        getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, JAXRSUtils.mediaTypeToString(mt));
+        
+    }
+
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java?rev=1479874&r1=1479873&r2=1479874&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
Tue May  7 12:12:26 2013
@@ -25,11 +25,13 @@ import java.lang.reflect.Type;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.WriterInterceptor;
 import javax.ws.rs.ext.WriterInterceptorContext;
 
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Message;
 
 public class WriterInterceptorContextImpl extends AbstractInterceptorContextImpl 
@@ -43,12 +45,11 @@ public class WriterInterceptorContextImp
                                         Class<?> cls,
                                         Type type,
                                         Annotation[] anns,
-                                        MediaType mt,
                                         OutputStream os,
                                         Message message,
                                         List<WriterInterceptor> writers) {
     //CHECKSTYLE:ON    
-        super(cls, type, anns, mt, message);
+        super(cls, type, anns, message);
         this.entity = entity;
         this.os = os;
         this.writers = writers;
@@ -94,4 +95,17 @@ public class WriterInterceptorContextImp
 
     }
 
+
+    @Override
+    public MediaType getMediaType() {
+        Object value = getHeaders().getFirst(HttpHeaders.CONTENT_TYPE);
+        return value instanceof MediaType ? (MediaType)value : JAXRSUtils.toMediaType((String)value);
+    }
+
+
+    @Override
+    public void setMediaType(MediaType mt) {
+        getHeaders().putSingle(HttpHeaders.CONTENT_TYPE, mt);
+    }
+
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=1479874&r1=1479873&r2=1479874&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Tue
May  7 12:12:26 2013
@@ -1321,7 +1321,6 @@ public final class JAXRSUtils {
             ReaderInterceptorContext context = new ReaderInterceptorContextImpl(targetTypeClass,

                                                                             parameterType,

                                                                             parameterAnnotations,

-                                                                            mediaType,
                                                                             is,
                                                                             m,
                                                                             readers);
@@ -1354,8 +1353,7 @@ public final class JAXRSUtils {
             WriterInterceptorContext context = new WriterInterceptorContextImpl(entity,
                                                                                 type, 
                                                                             genericType,

-                                                                            annotations,

-                                                                            mediaType,
+                                                                            annotations,
                                                                             entityStream,
                                                                             message,
                                                                             writers);

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java?rev=1479874&r1=1479873&r2=1479874&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
Tue May  7 12:12:26 2013
@@ -46,6 +46,7 @@ import javax.ws.rs.container.PreMatching
 import javax.ws.rs.container.ResourceInfo;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.FeatureContext;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.ReaderInterceptor;
@@ -394,7 +395,7 @@ public class BookServer20 extends Abstra
             if (!ct.endsWith("ISO-8859-1")) {
                 ct += "us-ascii";
             }
-            context.getHeaders().putSingle("Content-Type", ct);
+            context.setMediaType(MediaType.valueOf(ct));
             context.proceed();
         }
         



Mime
View raw message