cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r630316 [1/2] - in /incubator/cxf/trunk: rt/frontend/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ ...
Date Fri, 22 Feb 2008 20:52:16 GMT
Author: dkulp
Date: Fri Feb 22 12:52:08 2008
New Revision: 630316

URL: http://svn.apache.org/viewvc?rev=630316&view=rev
Log:
[CXF-1415] Update to jaxrs 0.5 spec.   Big patch from Sergey Beryozkin applied.

Modified:
    incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DOMSourceProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookNoSubResource.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStore.java
    incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BadgerFishProvider.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java
    incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/pom.xml Fri Feb 22 12:52:08 2008
@@ -58,44 +58,44 @@
             <artifactId>spring-core</artifactId>
         </dependency>
         <dependency>
-	            <groupId>org.apache.cxf</groupId>
-	            <artifactId>cxf-rt-frontend-jaxws</artifactId>
-	            <version>${project.version}</version>
-        </dependency>
-         <dependency>
-             <groupId>javax.ws.rs</groupId>
-             <artifactId>jsr311-api</artifactId>
-             <version>0.4</version>
-         </dependency>
-         <dependency>
-             <groupId>jaxen</groupId>
-             <artifactId>jaxen</artifactId>
-         </dependency>
-         <dependency>
-           <groupId>org.apache.abdera</groupId>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+            <version>0.5</version>
+        </dependency>
+        <dependency>
+            <groupId>jaxen</groupId>
+            <artifactId>jaxen</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.abdera</groupId>
             <artifactId>abdera-core</artifactId>
             <version>0.3.0-incubating</version>
-         </dependency>
-         <dependency>
-           <groupId>org.apache.abdera</groupId>
-           <artifactId>abdera-parser</artifactId>
-           <version>0.3.0-incubating</version>
-         </dependency>  
-        <dependency>
-	            <groupId>org.apache.geronimo.specs</groupId>
-	            <artifactId>geronimo-servlet_2.5_spec</artifactId>
-	            <scope>provided</scope>
-        </dependency>
-       <dependency>
-	            <groupId>org.codehaus.jettison</groupId>
-	            <artifactId>jettison</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.abdera</groupId>
+            <artifactId>abdera-parser</artifactId>
+            <version>0.3.0-incubating</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.codehaus.jettison</groupId>
+            <artifactId>jettison</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-testutils</artifactId>
             <version>${project.version}</version>
             <scope>test</scope>
-        </dependency>        
+        </dependency>
         <dependency>
             <groupId>org.easymock</groupId>
             <artifactId>easymockclassextension</artifactId>
@@ -110,11 +110,5 @@
             <url>http://people.apache.org/repo/m2-incubating-repository</url>
         </repository>
     </repositories>
-
-    <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/rs</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/cxf/trunk/rt/rs</developerConnection>
-      <url>http://svn.apache.org/viewvc/incubator/cxf/trunk/cxf-parent/cxf-rt-rs</url>
-  </scm>
 
 </project>

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Fri Feb 22 12:52:08 2008
@@ -97,7 +97,7 @@
             // presume Inputstream has not been consumed yet by the root resource class.
             //I.e., only one place either in the root resource or sub-resouce class can
             //have a parameter that read from entitybody.
-            List<Object> newParams = JAXRSUtils.processParameters(subOri.getMethod(), values, msg);
+            List<Object> newParams = JAXRSUtils.processParameters(subOri, values, msg);
             msg.setContent(List.class, newParams);
             
             return this.invoke(exchange, newParams);

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Fri Feb 22 12:52:08 2008
@@ -23,7 +23,6 @@
 import java.util.Arrays;
 import java.util.List;
 
-import javax.ws.rs.ext.EntityProvider;
 import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.BusException;
@@ -66,7 +65,7 @@
     private boolean start = true;
     private JAXRSServiceFactoryBean serviceFactory;
     private List<Object> serviceBeans;
-    private List<EntityProvider> entityProviders;
+    private List<?> entityProviders;
 
     public JAXRSServerFactoryBean() {
         this(new JAXRSServiceFactoryBean());
@@ -272,14 +271,14 @@
     /**
      * @return the entityProviders
      */
-    public List<EntityProvider> getEntityProviders() {
+    public List<?> getEntityProviders() {
         return entityProviders;
     }
 
     /**
      * @param entityProviders the entityProviders to set
      */
-    public void setEntityProviders(List<EntityProvider> entityProviders) {
+    public void setEntityProviders(List<? extends Object> entityProviders) {
         this.entityProviders = entityProviders;
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java Fri Feb 22 12:52:08 2008
@@ -27,8 +27,7 @@
 import java.util.Map;
 import java.util.concurrent.Executor;
 
-import javax.ws.rs.HttpMethod;
-import javax.ws.rs.UriTemplate;
+import javax.ws.rs.Path;
 
 import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
@@ -132,7 +131,7 @@
     }
 
     protected ClassResourceInfo createRootClassResourceInfo(final Class<?> c) {
-        UriTemplate uriTemplateAnnotation = c.getAnnotation(UriTemplate.class);
+        Path uriTemplateAnnotation = c.getAnnotation(Path.class);
         if (uriTemplateAnnotation == null) {
             return null;
         }
@@ -174,28 +173,29 @@
     protected MethodDispatcher createOperation(Class c, ClassResourceInfo cri) {
         MethodDispatcher md = new MethodDispatcher();
         for (Method m : c.getMethods()) {
-            if (m.getAnnotation(UriTemplate.class) != null && m.getAnnotation(HttpMethod.class) != null) {
+            String httpMethod = JAXRSUtils.getHttpMethodValue(m);
+            
+            if (m.getAnnotation(Path.class) != null && httpMethod != null) {
                 /*
                  * Sub-resource method, URI template created by concatenating
                  * the URI template of the resource class with the URI template
                  * of the method
                  */
                 OperationResourceInfo ori = new OperationResourceInfo(m, cri);
-                String uriTemplate = m.getAnnotation(UriTemplate.class).value();
+                String uriTemplate = m.getAnnotation(Path.class).value();
                 if (!uriTemplate.startsWith("/")) {
                     uriTemplate = "/" + uriTemplate;
                 }
 
                 ori.setURITemplate(new URITemplate(uriTemplate, URITemplate.UNLIMITED_REGEX_SUFFIX));
 
-                String httpMethod = m.getAnnotation(HttpMethod.class).value();
                 ori.setHttpMethod(httpMethod);
 
                 md.bind(ori, m);
-            } else if (m.getAnnotation(UriTemplate.class) != null) {
+            } else if (m.getAnnotation(Path.class) != null) {
                 // sub-resource locator
                 OperationResourceInfo ori = new OperationResourceInfo(m, cri);
-                String uriTemplate = m.getAnnotation(UriTemplate.class).value();
+                String uriTemplate = m.getAnnotation(Path.class).value();
                 if (!uriTemplate.startsWith("/")) {
                     uriTemplate = "/" + uriTemplate;
                 }                
@@ -209,8 +209,7 @@
                 //Iterate through sub-resources
                 ClassResourceInfo subCri = createClassResourceInfo(subResourceClass);
                 cri.addSubClassResourceInfo(subCri);
-            } else if (m.getAnnotation(HttpMethod.class) != null) {
-                String httpMethod = m.getAnnotation(HttpMethod.class).value();
+            } else if (httpMethod != null) {
                 OperationResourceInfo ori = new OperationResourceInfo(m, cri);
                 String uriTemplate = "/";
                 ori.setURITemplate(new URITemplate(uriTemplate, URITemplate.UNLIMITED_REGEX_SUFFIX));
@@ -222,7 +221,9 @@
 
         return md;
     }
-
+    
+    
+    
     protected Invoker createInvoker() {
         return new JAXRSInvoker();
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java Fri Feb 22 12:52:08 2008
@@ -31,19 +31,21 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
 import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.HeaderParam;
+import javax.ws.rs.HttpMethod;
 import javax.ws.rs.MatrixParam;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.UriParam;
 import javax.ws.rs.core.HttpContext;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.common.util.PrimitiveUtils;
@@ -52,16 +54,33 @@
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
-import org.apache.cxf.jaxrs.provider.ProviderFactoryImpl;
 import org.apache.cxf.message.Message;
 
 public final class JAXRSUtils {
 
-    private static final String ALL_TYPES = "*/*";
+    public static final MediaType ALL_TYPES = new MediaType();
 
     private JAXRSUtils() {        
     }
+    
+    public static String getHttpMethodValue(Method m) {
+        for (Annotation a : m.getAnnotations()) {
+            HttpMethod httpM = a.annotationType().getAnnotation(HttpMethod.class);
+            if (httpM != null) {
+                return httpM.value();
+            }
+        }
+        return null;
+    }
 
+    public static List<MediaType> getMediaTypes(String[] values) {
+        List<MediaType> supportedMimeTypes = new ArrayList<MediaType>(values.length);
+        for (int i = 0; i < values.length; i++) {
+            supportedMimeTypes.add(MediaType.parse(values[i]));    
+        }
+        return supportedMimeTypes;
+    }
+    
     public static ClassResourceInfo findSubResourceClass(ClassResourceInfo resource,
                                                          Class subResourceClassType) {
         for (ClassResourceInfo subCri : resource.getSubClassResourceInfo()) {
@@ -73,16 +92,18 @@
     }
 
     public static OperationResourceInfo findTargetResourceClass(List<ClassResourceInfo> resources,
-                                                                String path, String httpMethod,
+                                                                String path, 
+                                                                String httpMethod,
                                                                 Map<String, String> values,
-                                                                String contentTypes, 
+                                                                String requestContentType, 
                                                                 String acceptContentTypes) {
+        
         for (ClassResourceInfo resource : resources) {
             URITemplate uriTemplate = resource.getURITemplate();
             if (uriTemplate.match(path, values)) {
                 String subResourcePath = values.get(URITemplate.RIGHT_HAND_VALUE);
                 OperationResourceInfo ori = findTargetMethod(resource, subResourcePath, httpMethod, values,
-                                                             contentTypes, acceptContentTypes);
+                                                             requestContentType, acceptContentTypes);
                 if (ori != null) {
                     return ori;
                 }
@@ -91,82 +112,125 @@
         return null;
     }
 
-    public static OperationResourceInfo findTargetMethod(ClassResourceInfo resource, String path,
-                                                         String httpMethod, Map<String, String> values, 
-                                                         String contentTypes, String acceptContentTypes) {
+    public static OperationResourceInfo findTargetMethod(ClassResourceInfo resource, 
+                                                         String path,
+                                                         String httpMethod, 
+                                                         Map<String, String> values, 
+                                                         String requestContentType, 
+                                                         String acceptContentTypes) {
         List<OperationResourceInfo> candidateList = new ArrayList<OperationResourceInfo>();
-
-        for (OperationResourceInfo ori : resource.getMethodDispatcher().getOperationResourceInfos()) {
-            URITemplate uriTemplate = ori.getURITemplate();
-            if ((uriTemplate != null && uriTemplate.match(path, values))
-                && (ori.isSubResourceLocator() || (ori.getHttpMethod() != null && ori.getHttpMethod()
-                    .equalsIgnoreCase(httpMethod)))
-                    && matchMimeTypes(contentTypes, acceptContentTypes, ori.getMethod())) {
-                candidateList.add(ori);
+        MediaType requestType = requestContentType == null 
+                                ? ALL_TYPES : MediaType.parse(requestContentType);
+        List<MediaType> acceptTypes = JAXRSUtils.sortMediaTypes(acceptContentTypes);
+        for (MediaType acceptType : acceptTypes) {
+            for (OperationResourceInfo ori : resource.getMethodDispatcher().getOperationResourceInfos()) {
+                URITemplate uriTemplate = ori.getURITemplate();
+                if ((uriTemplate != null && uriTemplate.match(path, values))
+                    && (ori.isSubResourceLocator() || (ori.getHttpMethod() != null && ori.getHttpMethod()
+                        .equalsIgnoreCase(httpMethod)))
+                        && matchMimeTypes(requestType, acceptType, ori)) {
+                    candidateList.add(ori);
+                }
+            }
+            if (!candidateList.isEmpty()) {
+                Collections.sort(candidateList, new OperationResourceInfoComparator());
+                return candidateList.get(0);
             }
         }
 
-        if (!candidateList.isEmpty()) {
-            /*
-             * Sort M using the media type of input data as the primary key and
-             * the media type of output data as the secondary key.
-             */
-            Collections.sort(candidateList, new OperationResourceInfoComparator());
-            return candidateList.get(0);
-        } else {
-            return null;
-        }
+        return null;
     }    
 
+    public static List<MediaType> getConsumeTypes(ConsumeMime cm) {
+        return cm == null ? Collections.singletonList(ALL_TYPES)
+                          : getMediaTypes(cm.value());
+    }
+    
+    public static List<MediaType> getProduceTypes(ProduceMime pm) {
+        return pm == null ? Collections.singletonList(ALL_TYPES)
+                          : getMediaTypes(pm.value());
+    }
+    
     private static class OperationResourceInfoComparator implements Comparator<OperationResourceInfo> {
         public int compare(OperationResourceInfo e1, OperationResourceInfo e2) {
-            ConsumeMime c1 = e1.getMethod().getAnnotation(ConsumeMime.class);
-            String[] mimeType1 = {ALL_TYPES};
-            if (c1 != null) {
-                mimeType1 = c1.value();               
-            }
-
-            ConsumeMime c2 = e2.getMethod().getAnnotation(ConsumeMime.class);
-            String[] mimeType2 = {ALL_TYPES};
-            if (c2 != null) {
-                mimeType2 = c2.value();               
-            }
-
-            int resultOfComparingConsumeMime = compareString(mimeType1[0], mimeType2[0]);
-            if (resultOfComparingConsumeMime == 0) {
+            
+            List<MediaType> mimeType1 = 
+                getConsumeTypes(e1.getMethod().getAnnotation(ConsumeMime.class));
+            List<MediaType> mimeType2 = 
+                getConsumeTypes(e2.getMethod().getAnnotation(ConsumeMime.class));
+            
+            // TODO: we actually need to check all consume and produce types here ?
+            int result = JAXRSUtils.compareMediaTypes(mimeType1.get(0), 
+                                                      mimeType2.get(0));
+            if (result == 0) {
                 //use the media type of output data as the secondary key.
-                ProduceMime p1 = e1.getMethod().getAnnotation(ProduceMime.class);
-                String[] mimeTypeP1 = {ALL_TYPES};
-                if (p1 != null) {
-                    mimeTypeP1 = p1.value();               
-                }
+                List<MediaType> mimeTypeP1 = 
+                    getProduceTypes(e1.getMethod().getAnnotation(ProduceMime.class));
 
-                ProduceMime p2 = e2.getMethod().getAnnotation(ProduceMime.class);
-                String[] mimeTypeP2 = {ALL_TYPES};
-                if (p2 != null) {
-                    mimeTypeP2 = p2.value();               
-                }    
+                List<MediaType> mimeTypeP2 = 
+                    getProduceTypes(e2.getMethod().getAnnotation(ProduceMime.class));    
 
-                return compareString(mimeTypeP1[0], mimeTypeP2[0]);
+                return JAXRSUtils.compareMediaTypes(mimeTypeP1.get(0), 
+                                                    mimeTypeP2.get(0));
             } else {
-                return resultOfComparingConsumeMime;
+                return result;
             }
 
         }
-
-        private int compareString(String str1, String str2) {
-            if (!str1.startsWith("*/") && str2.startsWith("*/")) {
-                return -1;
-            } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
+        
+    }
+    
+    public static int compareMediaTypes(MediaType mt1, MediaType mt2) {
+        
+        if (mt1.equals(mt2)) {
+            float q1 = getMediaTypeQualityFactor(mt1);
+            float q2 = getMediaTypeQualityFactor(mt2);
+            int result = Float.compare(q1, q2);
+            return result == 0 ? result : ~result;
+        }
+        
+        if (mt1.isWildcardType() && !mt2.isWildcardType()) {
+            return 1;
+        }
+        if (!mt1.isWildcardType() && mt2.isWildcardType()) {
+            return -1;
+        }
+         
+        if (mt1.getType().equals(mt2.getType())) {
+            if (mt1.isWildcardSubtype() && !mt2.isWildcardSubtype()) {
                 return 1;
-            } 
-
-            return str1.compareTo(str2);
+            }
+            if (!mt1.isWildcardSubtype() && mt2.isWildcardSubtype()) {
+                return -1;
+            }       
         }
+        return mt1.toString().compareTo(mt2.toString());
+        
     }
 
+    private static float getMediaTypeQualityFactor(MediaType mt) {
+        String q = mt.getParameters().get("q");
+        if (q == null) {
+            return 1;
+        }
+        if (q.charAt(0) == '.') {
+            q = '0' + q;
+        }
+        try {
+            return Float.parseFloat(q);
+        } catch (NumberFormatException ex) {
+            // default value will do
+        }
+        return 1;
+    }
+    
     //Message contains following information: PATH, HTTP_REQUEST_METHOD, CONTENT_TYPE, InputStream.
-    public static List<Object> processParameters(Method method, Map<String, String> values, Message message) {
+    public static List<Object> processParameters(OperationResourceInfo ori, 
+                                                 Map<String, String> values, 
+                                                 Message message) {
+        
+        
+        Method method = ori.getMethod();
         Class[] parameterTypes = method.getParameterTypes();
         Type[] genericParameterTypes = method.getGenericParameterTypes();
         Annotation[][] parameterAnnotations = method.getParameterAnnotations();
@@ -174,27 +238,27 @@
         List<Object> params = new ArrayList<Object>(parameterTypes.length);
 
         for (int i = 0; i < parameterTypes.length; i++) {
-            Object param = processParameter(parameterTypes[i], genericParameterTypes[i],
-                                            parameterAnnotations[i], values, message);
+            Object param = processParameter(parameterTypes[i], 
+                                            genericParameterTypes[i],
+                                            parameterAnnotations[i], 
+                                            values, 
+                                            message,
+                                            ori);
             params.add(param);
         }
 
         return params;
     }
 
-    private static Object processParameter(Class<?> parameterClass, Type parameterType,
-                                           Annotation[] parameterAnnotations, Map<String, String> values,
-                                           Message message) {
+    private static Object processParameter(Class<?> parameterClass, 
+                                           Type parameterType,
+                                           Annotation[] parameterAnnotations, 
+                                           Map<String, String> values,
+                                           Message message,
+                                           OperationResourceInfo ori) {
         InputStream is = message.getContent(InputStream.class);
-        String contentTypes = (String)message.get(Message.CONTENT_TYPE);
-        if (contentTypes != null) {
-            try {
-                MimeType mt = new MimeType(contentTypes);
-                contentTypes = mt.getBaseType();
-            } catch (MimeTypeParseException e) {
-                // ignore
-            }
-        }
+        String contentType = (String)message.get(Message.CONTENT_TYPE);
+        
         String path = (String)message.get(JAXRSInInterceptor.RELATIVE_PATH);
         String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
 
@@ -202,7 +266,10 @@
 
         if ((parameterAnnotations == null || parameterAnnotations.length == 0)
             && ("PUT".equals(httpMethod) || "POST".equals(httpMethod))) {
-            result = readFromEntityBody(parameterClass, is, contentTypes);
+            result = readFromMessageBody(parameterClass, 
+                                         is, 
+                                         MediaType.parse(contentType),
+                                         ori.getConsumeTypes());
         } else if (parameterAnnotations[0].annotationType() == UriParam.class) {
             result = readFromUriParam((UriParam)parameterAnnotations[0], parameterClass, parameterType,
                                       parameterAnnotations, path, values);
@@ -258,19 +325,27 @@
     }
 
     @SuppressWarnings("unchecked")
-    private static Object readFromEntityBody(Class targetTypeClass, InputStream is, String contentTypes) {
-        Object result = null;
-        //Refactor once we move to JSR-311 0.5 API
-        EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(targetTypeClass, new String[]{contentTypes}, true);
-
-        try {
-            result = provider.readFrom(targetTypeClass, null, null, is);
-        } catch (IOException e) {
-            e.printStackTrace();
+    private static <T> Object readFromMessageBody(Class<T> targetTypeClass, InputStream is, 
+                                                  MediaType contentType, List<MediaType> consumeTypes) {
+        
+        List<MediaType> types = JAXRSUtils.intersectMimeTypes(consumeTypes, contentType);
+        
+        MessageBodyReader provider = null;
+        
+        for (MediaType type : types) { 
+            provider = ProviderFactory.getInstance()
+                .createMessageBodyReader(targetTypeClass, type);
+            if (provider != null) {
+                try {
+                    return provider.readFrom(targetTypeClass, contentType, null, is);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    return null;
+                }    
+            }
         }
 
-        return result;
+        return null;
     }
 
     private static Object readFromUriParam(UriParam uriParamAnnotation,
@@ -293,56 +368,39 @@
         return result;
     }
 
-    public static boolean matchMimeTypes(String contentTypes, String acceptContentTypes, Method m) {
-        if (contentTypes != null) {
-            try {
-                MimeType mt = new MimeType(contentTypes);
-                contentTypes = mt.getBaseType();
-            } catch (MimeTypeParseException e) {
-                // ignore
-            }
+    public static boolean matchMimeTypes(MediaType requestContentType, 
+                                         MediaType acceptContentType, 
+                                         OperationResourceInfo ori) {
+        
+        if (intersectMimeTypes(ori.getConsumeTypes(), requestContentType).size() != 0
+            && intersectMimeTypes(ori.getProduceTypes(), acceptContentType).size() != 0) {
+            return true;
         }
-        List<String> acceptValues = new ArrayList<String>();
-        if (acceptContentTypes != null) {
-            while (acceptContentTypes.length() > 0) {
-                String tp = acceptContentTypes;
-                int index = acceptContentTypes.indexOf(',');
+        return false;
+    }
+
+    public static List<MediaType> parseMediaTypes(String types) {
+        List<MediaType> acceptValues = new ArrayList<MediaType>();
+        
+        if (types != null) {
+            while (types.length() > 0) {
+                String tp = types;
+                int index = types.indexOf(',');
                 if (index != -1) {
-                    tp = acceptContentTypes.substring(0, index);
-                    acceptContentTypes = acceptContentTypes.substring(index + 1).trim();
+                    tp = types.substring(0, index);
+                    types = types.substring(index + 1).trim();
                 } else {
-                    acceptContentTypes = "";
+                    types = "";
                 }
-                try {
-                    MimeType mt = new MimeType(tp);
-                    acceptValues.add(mt.getBaseType());
-                } catch (MimeTypeParseException e) {
-                    // ignore
-                }   
+                acceptValues.add(MediaType.parse(tp));
             }
         } else {
             acceptValues.add(ALL_TYPES);
         }
-
-        String[] consumeMimeTypes = {ALL_TYPES};          
-        ConsumeMime c = m.getAnnotation(ConsumeMime.class);
-        if (c != null) {
-            consumeMimeTypes = c.value();               
-        } 
-
-        String[] produceMimeTypes = {ALL_TYPES};          
-        ProduceMime p = m.getAnnotation(ProduceMime.class);
-        if (p != null) {
-            produceMimeTypes = p.value();               
-        }     
-
-        if (intersectMimeTypes(consumeMimeTypes, contentTypes).length != 0
-            && intersectMimeTypes(produceMimeTypes, acceptValues.toArray(new String[]{})).length != 0) {
-            return true;
-        }
-        return false;
+        
+        return acceptValues;
     }
-
+    
     /**
      * intersect two mime types
      * 
@@ -350,62 +408,50 @@
      * @param mimeTypesB 
      * @return return a list of intersected mime types
      */   
-    public static String[] intersectMimeTypes(String[] mimeTypesA, String[] mimeTypesB) {
-        List<String> supportedMimeTypeList = new ArrayList<String>();
-
-        for (String mimeTypeB : mimeTypesB) {
-            String[] tmpList = intersectMimeTypes(mimeTypesA, mimeTypeB);
-            supportedMimeTypeList.addAll(Arrays.asList(tmpList));
-        }
-
-        String[] list = new String[supportedMimeTypeList.size()];
-        list = supportedMimeTypeList.toArray(list);
-        return list;
-    }
-
-    /**
-     * intersect two mime types
-     * 
-     * @param mimeTypesA 
-     * @param mimeTypeB 
-     * @return return a list of intersected mime types
-     */   
-    public static String[] intersectMimeTypes(String[] mimeTypesA, String mimeTypeB) {
-        List<String> intersectedMimeTypes = new ArrayList<String>();
-
-        for (String mimeTypeA : mimeTypesA) {
-            if (isSubSetOfMimeTypes(mimeTypeB, mimeTypeA)) {
-                intersectedMimeTypes.add(mimeTypeB);
-            } else if (isSubSetOfMimeTypes(mimeTypeA, mimeTypeB)) {
-                intersectedMimeTypes.add(mimeTypeA);               
+    public static List<MediaType> intersectMimeTypes(List<MediaType> mimeTypesA, 
+                                                     List<MediaType> mimeTypesB) {
+        Set<MediaType> supportedMimeTypeList = new LinkedHashSet<MediaType>();
+
+        for (MediaType mimeTypeA : mimeTypesA) {
+            for (MediaType mimeTypeB : mimeTypesB) {
+                if (mimeTypeB.isCompatible(mimeTypeA) || mimeTypeA.isCompatible(mimeTypeB)) {
+                    
+                    String type = mimeTypeA.getType().equals(MediaType.MEDIA_TYPE_WILDCARD) 
+                                      ? mimeTypeB.getType() : mimeTypeA.getType();
+                    String subtype = mimeTypeA.getSubtype().equals(MediaType.MEDIA_TYPE_WILDCARD) 
+                                      ? mimeTypeB.getSubtype() : mimeTypeA.getSubtype();                  
+                    supportedMimeTypeList.add(new MediaType(type, subtype));
+                }
             }
         }
 
-        String[] list = new String[intersectedMimeTypes.size()];
-        list = intersectedMimeTypes.toArray(list);
-        return list;
+        return new ArrayList<MediaType>(supportedMimeTypeList);
+        
     }
+    
+    public static List<MediaType> intersectMimeTypes(List<MediaType> mimeTypesA, 
+                                                     MediaType mimeTypeB) {
+        return intersectMimeTypes(mimeTypesA, 
+                                  Collections.singletonList(mimeTypeB));
+    }
+    
+    public static List<MediaType> intersectMimeTypes(String mimeTypesA, 
+                                                     String mimeTypesB) {
+        return intersectMimeTypes(parseMediaTypes(mimeTypesA),
+                                  parseMediaTypes(mimeTypesB));
+    }
+    
+    public static List<MediaType> sortMediaTypes(String mediaTypes) {
+        List<MediaType> types = JAXRSUtils.parseMediaTypes(mediaTypes);
+        if (types.size() > 1) {
+            Collections.sort(types, new Comparator<MediaType>() {
 
-    /**
-     * compare two mime types
-     * 
-     * @param mimeTypeA 
-     * @param mimeTypeB 
-     * @return return ture is mimeTypeB is a subset of mimeTypeA or if mimeTypeB
-     * is equal to  mimeTypeA. Return false otherwise. 
-     */
-    public static boolean isSubSetOfMimeTypes(String mimeTypeA, String mimeTypeB) {
-        if (mimeTypeB.equalsIgnoreCase(mimeTypeA)) {
-            return true;
-        } else if (mimeTypeB.startsWith("*/")) {
-            return true;
-        } else if (mimeTypeB.endsWith("/*")
-            && !mimeTypeA.startsWith("*/")
-            && mimeTypeB.substring(0, mimeTypeB.indexOf("/"))
-                .equalsIgnoreCase(mimeTypeA.substring(0, mimeTypeB.indexOf("/")))) {
-            return true;
+                public int compare(MediaType mt1, MediaType mt2) {
+                    return JAXRSUtils.compareMediaTypes(mt1, mt2);
+                }
+                
+            });
         }
-
-        return false;
+        return types;
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/MetadataMap.java Fri Feb 22 12:52:08 2008
@@ -28,33 +28,32 @@
 
 import javax.ws.rs.core.MultivaluedMap;
 
-public class MetadataMap implements MultivaluedMap<String, Object> {
+public class MetadataMap<K, V> implements MultivaluedMap<K, V> {
 
-    private Map<String, List<Object>> m = new HashMap<String, List<Object>>();
+    private Map<K, List<V>> m = new HashMap<K, List<V>>();
     
-    public void add(String key, Object value) {
-        List<Object> data = m.get(key);
+    public void add(K key, V value) {
+        List<V> data = m.get(key);
         if (data == null) {
-            data = new ArrayList<Object>();    
+            data = new ArrayList<V>();    
             m.put(key, data);
         }
         data.add(value);
     }
 
-    public Object getFirst(String key) {
-        List<Object> data = m.get(key);
+    public V getFirst(K key) {
+        List<V> data = m.get(key);
         return data == null ? null : data.get(0);
     }
 
-    public void putSingle(String key, Object value) {
-        List<Object> data = new ArrayList<Object>();
+    public void putSingle(K key, V value) {
+        List<V> data = new ArrayList<V>();
         data.add(value);
         m.put(key, data);
     }
 
     public void clear() {
         m.clear();
-
     }
 
     public boolean containsKey(Object key) {
@@ -65,11 +64,11 @@
         return m.containsValue(value);
     }
 
-    public Set<Entry<String, List<Object>>> entrySet() {
+    public Set<Entry<K, List<V>>> entrySet() {
         return m.entrySet();
     }
 
-    public List<Object> get(Object key) {
+    public List<V> get(Object key) {
         return m.get(key);
     }
 
@@ -77,19 +76,19 @@
         return m.isEmpty();
     }
 
-    public Set<String> keySet() {
+    public Set<K> keySet() {
         return m.keySet();
     }
 
-    public List<Object> put(String key, List<Object> value) {
+    public List<V> put(K key, List<V> value) {
         return m.put(key, value);
     }
 
-    public void putAll(Map<? extends String, ? extends List<Object>> map) {
+    public void putAll(Map<? extends K, ? extends List<V>> map) {
         m.putAll(map);
     }
 
-    public List<Object> remove(Object key) {
+    public List<V> remove(Object key) {
         return m.remove(key);
     }
 
@@ -97,7 +96,7 @@
         return m.size();
     }
 
-    public Collection<List<Object>> values() {
+    public Collection<List<V>> values() {
         return m.values();
     }
 

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Fri Feb 22 12:52:08 2008
@@ -50,15 +50,15 @@
         String path = (String)message.get(Message.PATH_INFO);
         String address = (String)message.get(Message.BASE_PATH);
         String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
-        String contentType = (String)message.get(Message.CONTENT_TYPE);
-        if (contentType == null) {
-            contentType = "*/*";
-        }
-        String acceptContentType = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
-        if (acceptContentType == null) {
-            acceptContentType = "*/*";
+        String requestContentType = (String)message.get(Message.CONTENT_TYPE);
+        if (requestContentType == null) {
+            requestContentType = "*/*";
+        }
+        String acceptContentTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
+        if (acceptContentTypes == null) {
+            acceptContentTypes = "*/*";
         }
-        message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentType);
+        message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
         
         if (address.startsWith("http")) {
             int idx = address.indexOf('/', 7);
@@ -75,15 +75,14 @@
         }
 
         if (!path.endsWith("/")) {
-            //path = path.substring(0, path.length() - 1);
             path = path + "/";
         }
         message.put(RELATIVE_PATH, path);
         
-        LOG.info("Request path is: " + path);
-        LOG.info("Request HTTP method is: " + httpMethod);
-        LOG.info("Request contentType is: " + contentType);
-        LOG.info("Accept contentType is: " + acceptContentType);
+        LOG.fine("Request path is: " + path);
+        LOG.fine("Request HTTP method is: " + httpMethod);
+        LOG.fine("Request contentType is: " + requestContentType);
+        LOG.fine("Accept contentType is: " + acceptContentTypes);
 
 
         //1. Matching target resource classes and method
@@ -91,12 +90,16 @@
         List<ClassResourceInfo> resources = ((JAXRSServiceImpl)service).getClassResourceInfos();
 
         Map<String, String> values = new HashMap<String, String>();
-        OperationResourceInfo ori = JAXRSUtils.findTargetResourceClass(resources, path, httpMethod, values,
-                                                                       contentType, acceptContentType);
+        OperationResourceInfo ori = JAXRSUtils.findTargetResourceClass(resources, 
+                                                                       path, 
+                                                                       httpMethod, 
+                                                                       values,
+                                                                       requestContentType, 
+                                                                       acceptContentTypes);
 
         if (ori == null) {
-            LOG.severe("No operation found for path: " + path + ", contentType: " + contentType
-                       + ", Accept contentType: " + acceptContentType);
+            LOG.severe("No operation found for path: " + path + ", contentType: " 
+                       + requestContentType + ", Accept contentType: " + acceptContentTypes);
             //throw new Fault(new org.apache.cxf.common.i18n.Message("NO_OP", BUNDLE, method, path));
         }
         LOG.info("Found operation: " + ori.getMethod().getName());
@@ -106,7 +109,7 @@
       
         //2. Process parameters
         List<Object> params = JAXRSUtils
-            .processParameters(ori.getMethod(), values, message);
+            .processParameters(ori, values, message);
 
         message.setContent(List.class, params);
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Fri Feb 22 12:52:08 2008
@@ -21,23 +21,19 @@
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Logger;
 
-import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
 import javax.ws.rs.ProduceMime;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
 import org.apache.cxf.jaxrs.JAXRSUtils;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.provider.ProviderFactoryImpl;
-import org.apache.cxf.jaxrs.provider.ResponseImpl;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
@@ -73,10 +69,8 @@
                 Response response = (Response)responseObj;
                 
                 message.put(Message.RESPONSE_CODE, response.getStatus());
-                if (response instanceof ResponseImpl) {
-                    ((ResponseImpl)response).serializeMetadata(message);
-                }
-                
+                message.put(Message.PROTOCOL_HEADERS, response.getMetadata());
+                                
                 responseObj = response.getEntity();
                 if (responseObj == null) {
                     return;
@@ -84,25 +78,25 @@
             } 
             
             Class targetType = responseObj.getClass();
-            String[] availableContentTypes = computeAvailableContentTypes(message);  
+            List<MediaType> availableContentTypes = 
+                computeAvailableContentTypes(message);  
             
-            StringBuffer typesTmp = new StringBuffer();
-            for (String type : availableContentTypes) {
-                typesTmp.append(type + ",");
+            MessageBodyWriter writer = null;
+            for (MediaType type : availableContentTypes) { 
+                writer = ProviderFactory.getInstance()
+                    .createMessageBodyWriter(targetType, type);
+                 
+                if (writer != null) {
+                    break;
+                }
             }
-            LOG.info("Available content types for response is: " + typesTmp);
-
-            EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-                .createEntityProvider(targetType, availableContentTypes, false);
-            LOG.info("Response EntityProvider is: " + provider.getClass().getName());
-
+            
             try {
-                String outputContentType = computeFinalContentTypes(availableContentTypes, provider);
-                LOG.info("Response content type is: " + outputContentType);
-               
-                message.put(Message.CONTENT_TYPE, computeFinalContentTypes(availableContentTypes, provider));
-                
-                provider.writeTo(responseObj, null, null, out);
+                LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
+                MediaType mt = computeFinalContentTypes(availableContentTypes, writer);
+                LOG.fine("Response content type is: " + mt.toString());
+                message.put(Message.CONTENT_TYPE, mt.toString());
+                writer.writeTo(responseObj, mt, null, out);
             } catch (IOException e) {
                 e.printStackTrace();
             }        
@@ -111,48 +105,25 @@
 
     }
     
-    private String[] computeAvailableContentTypes(Message message) {
+    private List<MediaType> computeAvailableContentTypes(Message message) {
         Exchange exchange = message.getExchange();
         
-        String[] methodMimeTypes = exchange.get(OperationResourceInfo.class).getProduceMimeTypes();
-        String acceptContentType = (String)exchange.get(Message.ACCEPT_CONTENT_TYPE);
-
-        List<String> types = new ArrayList<String>();
-        if (acceptContentType != null) {
-            while (acceptContentType.length() > 0) {
-                String tp = acceptContentType;
-                if (acceptContentType.contains(",")) {
-                    tp = acceptContentType.substring(0, acceptContentType.indexOf(','));
-                    acceptContentType = acceptContentType
-                        .substring(acceptContentType.indexOf(',') + 1).trim();
-                } else {
-                    acceptContentType = "";
-                }
-                try {
-                    MimeType mt = new MimeType(tp);
-                    types.add(mt.getBaseType());
-                } catch (MimeTypeParseException e) {
-                    // ignore
-                }
-            }
-        }
-        if (types.isEmpty()) {
-            types.add("*/*");
-        }
+        List<MediaType> methodMimeTypes = exchange.get(OperationResourceInfo.class).getProduceTypes();
+        String acceptContentTypes = (String)exchange.get(Message.ACCEPT_CONTENT_TYPE);
         
-        return JAXRSUtils.intersectMimeTypes(methodMimeTypes,
-                                             types.toArray(new String[types.size()]));        
+        List<MediaType> acceptValues = JAXRSUtils.parseMediaTypes(acceptContentTypes);
+        
+        return JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptValues);        
     }
     
-    private String computeFinalContentTypes(String[] requestContentTypes, EntityProvider provider) {
-        String[] providerMimeTypes = {"*/*"};            
-
-        ProduceMime c = provider.getClass().getAnnotation(ProduceMime.class);
-        if (c != null) {
-            providerMimeTypes = c.value();               
-        } 
-        
-        String[] list = JAXRSUtils.intersectMimeTypes(requestContentTypes, providerMimeTypes);
-        return list[0];      
+    private MediaType computeFinalContentTypes(List<MediaType> produceContentTypes, 
+                                               MessageBodyWriter provider) {
+        List<MediaType> providerMimeTypes = 
+            JAXRSUtils.getProduceTypes(provider.getClass().getAnnotation(ProduceMime.class));
+                
+        List<MediaType> list = 
+            JAXRSUtils.intersectMimeTypes(produceContentTypes, providerMimeTypes);
+      
+        return list.get(0);      
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java Fri Feb 22 12:52:08 2008
@@ -25,17 +25,17 @@
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 
 public class ClassResourceInfo {
-    private Class resourceClass;
+    private Class<?> resourceClass;
     private URITemplate uriTemplate;
     private MethodDispatcher methodDispatcher;
     private ResourceProvider resourceProvider;
     private List<ClassResourceInfo> subClassResourceInfo = new ArrayList<ClassResourceInfo>();
 
-    public ClassResourceInfo(Class theResourceClass) {
+    public ClassResourceInfo(Class<?> theResourceClass) {
         resourceClass = theResourceClass;
     }
 
-    public Class getResourceClass() {
+    public Class<?> getResourceClass() {
         return resourceClass;
     }
 

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java Fri Feb 22 12:52:08 2008
@@ -22,19 +22,18 @@
 import java.lang.reflect.Method;
 import java.util.List;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.ProduceMime;
-import javax.ws.rs.UriTemplate;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.cxf.jaxrs.JAXRSUtils;
 
 public class OperationResourceInfo {
     private URITemplate uriTemplate;
     private ClassResourceInfo classResourceInfo;
     private Method method;
-    private List<Class> parameterTypeList;
-    private List<Class> annotatedParameterTypeList;
-    private List<EntityProvider> entityProviderList;
     private String httpMethod;
+   
 
     public OperationResourceInfo(Method m, ClassResourceInfo cri) {
         method = m;
@@ -74,42 +73,31 @@
     }
     
     public boolean isSubResourceLocator() {
-        if (method.getAnnotation(UriTemplate.class) != null 
-            && method.getAnnotation(HttpMethod.class) == null) {
-            return true;
-        }
-        return false;
-    }
-
-    public List<Class> getParameterTypeList() {
-        return parameterTypeList;
-    }
-
-    public List<Class> getAnnotatedParameterTypeList() {
-        return annotatedParameterTypeList;
+        return httpMethod == null ? true : false;
     }
 
-    public List<EntityProvider> getEntityProviderList() {
-        return entityProviderList;
+    
+    public List<MediaType> getProduceTypes() {
+        
+        // this needs to be calculated on init
+        ProduceMime pm = method.getAnnotation(ProduceMime.class);
+        if (pm != null) {
+            return JAXRSUtils.getMediaTypes(pm.value());
+        }
+        
+        return JAXRSUtils.getProduceTypes(classResourceInfo.getResourceClass()
+                                          .getAnnotation(ProduceMime.class));
     }
-
-    public String[] getProduceMimeTypes() {
-        //TODO: 
-        /*
-         * These annotations MAY be applied to a resource class method, a
-         * resource class, or to an EntityProvider. Declarations on a resource
-         * class method override any on the resource class; declarations on an
-         * EntityProvider for a method argument or return type override those on
-         * a resource class or resource method. In the absence of either of
-         * these annotations, support for any media type (* / *) is assumed.
-         */   
+    
+    public List<MediaType> getConsumeTypes() {
         
-        String[] mimeTypes = {"*/*"};
-        ProduceMime c = method.getAnnotation(ProduceMime.class);
-        if (c != null) {
-            mimeTypes = c.value();               
+        // this needs to be calculated on init
+        ConsumeMime pm = method.getAnnotation(ConsumeMime.class);
+        if (pm != null) {
+            return JAXRSUtils.getMediaTypes(pm.value());
         }
         
-        return mimeTypes;
+        return JAXRSUtils.getConsumeTypes(classResourceInfo.getResourceClass()
+                                          .getAnnotation(ConsumeMime.class));
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java Fri Feb 22 12:52:08 2008
@@ -27,7 +27,9 @@
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
 
 import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Document;
@@ -35,7 +37,9 @@
 
 @ProduceMime("application/atom+xml")
 @ConsumeMime("application/atom+xml")
-public class AtomEntryProvider implements EntityProvider<Entry> {
+@Provider
+public class AtomEntryProvider 
+    implements MessageBodyReader<Entry>, MessageBodyWriter<Entry> {
 
     private static final Abdera ATOM_ENGINE = new Abdera();
     
@@ -46,7 +50,11 @@
         return doc.getRoot();
     }
 
-    public boolean supports(Class<?> type) {
+    public boolean isReadable(Class<?> type) {
+        return Entry.class.isAssignableFrom(type);
+    }
+    
+    public boolean isWriteable(Class<?> type) {
         return Entry.class.isAssignableFrom(type);
     }
 
@@ -55,5 +63,8 @@
         throws IOException {
         entry.writeTo(os);
     }
-
+ 
+    public long getSize(Entry entry) {
+        return -1;
+    }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java Fri Feb 22 12:52:08 2008
@@ -27,7 +27,9 @@
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
 
 import org.apache.abdera.Abdera;
 import org.apache.abdera.model.Document;
@@ -35,19 +37,13 @@
 
 @ProduceMime("application/atom+xml")
 @ConsumeMime("application/atom+xml")
-public class AtomFeedProvider implements EntityProvider<Feed> {
+@Provider
+public class AtomFeedProvider 
+    implements MessageBodyWriter<Feed>, MessageBodyReader<Feed> {
 
     private static final Abdera ATOM_ENGINE = new Abdera();
-    
-    public Feed readFrom(Class<Feed> clazz, MediaType mt, 
-                         MultivaluedMap<String, String> headers, InputStream is)
-        throws IOException {
-        Document<Feed> doc = ATOM_ENGINE.getParser().parse(is);
-        return doc.getRoot();
-    }
-
-    public boolean supports(Class<?> type) {
         
+    public boolean isWriteable(Class<?> type) {
         return Feed.class.isAssignableFrom(type);
     }
 
@@ -55,6 +51,20 @@
                         MultivaluedMap<String, Object> headers, OutputStream os)
         throws IOException {
         feed.writeTo(os);
+    }
+    
+    public long getSize(Feed feed) {
+        return -1;
+    }
+
+    public boolean isReadable(Class<?> type) {
+        return Feed.class.isAssignableFrom(type);
+    }
+
+    public Feed readFrom(Class<Feed> type, MediaType mediaType, 
+                         MultivaluedMap<String, String> headers, InputStream is) throws IOException {
+        Document<Feed> doc = ATOM_ENGINE.getParser().parse(is);
+        return doc.getRoot();
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BuilderImpl.java Fri Feb 22 12:52:08 2008
@@ -21,6 +21,7 @@
 
 import java.net.URI;
 import java.util.Date;
+import java.util.List;
 
 import javax.ws.rs.core.CacheControl;
 import javax.ws.rs.core.EntityTag;
@@ -28,22 +29,25 @@
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.NewCookie;
 import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Builder;
+import javax.ws.rs.core.Variant;
+import javax.ws.rs.ext.HeaderProvider;
+import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.jaxrs.MetadataMap;
 
-
-public final class BuilderImpl extends Response.Builder {
+public final class BuilderImpl extends Builder {
     private int status = 200;
     private Object entity;
-    private MultivaluedMap<String, Object> metadata = new MetadataMap();
+    private MultivaluedMap<String, Object> metadata = new MetadataMap<String, Object>();
 
     public BuilderImpl() {
     }
 
        
     public Response build() {
-        Response r = new ResponseImpl(status, entity);
-        MetadataMap m = new MetadataMap();
+        ResponseImpl r = new ResponseImpl(status, entity);
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
         m.putAll(metadata);
         r.addMetadata(m);
         reset();
@@ -61,11 +65,12 @@
     }
 
     public Response.Builder type(MediaType type) {
-        return null;
+        return type(type.toString());
     }
 
     public Response.Builder type(String type) {
-        return null;
+        metadata.putSingle("Content-Type", type);
+        return this;
     }
 
     public Response.Builder language(String language) {
@@ -78,34 +83,56 @@
     }
 
     public Response.Builder contentLocation(URI location) {
-        return null;
+        metadata.putSingle("Content-Location", location.toString());
+        return this;
     }
 
     public Response.Builder tag(EntityTag tag) {
-        return null;
+        return tag(tag.toString());
     }
 
     public Response.Builder tag(String tag) {
-        return null;
+        metadata.putSingle("ETag", tag.toString());
+        return this;
     }
 
     public Response.Builder lastModified(Date lastModified) {
-        return null;
+        metadata.putSingle("Last-Modified", lastModified.toString());
+        return this;
     }
 
     public Response.Builder cacheControl(CacheControl cacheControl) {
-        return null;
+        metadata.putSingle("Cache-Control", cacheControl.toString());
+        return this;
     }
 
     public Response.Builder cookie(NewCookie cookie) {
-        return null;
+        metadata.putSingle("Cookie", cookie.toString());
+        return this;
     }
 
+    @SuppressWarnings("unchecked")
     public Response.Builder header(String name, Object value) {
-        // TODO: we need to use HeaderProviders to have headers serialized
+        HeaderProvider hp = 
+            ProviderFactory.getInstance().createHeaderProvider(value.getClass());
+        metadata.putSingle(name, hp.toString(value));
+        return this;
+    }
+
+    
+    @Override
+    public Response.Builder variant(Variant variant) {
+        // TODO Auto-generated method stub
         return null;
     }
 
+
+    @Override
+    public Builder variants(List<Variant> variants) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+    
     private void reset() {
         metadata.clear();
         entity = null;

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DOMSourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DOMSourceProvider.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DOMSourceProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/DOMSourceProvider.java Fri Feb 22 12:52:08 2008
@@ -25,7 +25,9 @@
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -37,12 +39,17 @@
 
 import org.w3c.dom.Document;
 
-
 import org.xml.sax.SAXException;
 
-public class DOMSourceProvider implements  EntityProvider<DOMSource> {
+@Provider
+public class DOMSourceProvider implements 
+    MessageBodyReader<DOMSource>, MessageBodyWriter<DOMSource> {
 
-    public boolean supports(Class<?> type) {
+    public boolean isWriteable(Class<?> type) {
+        return DOMSource.class.isAssignableFrom(type);
+    }
+    
+    public boolean isReadable(Class<?> type) {
         return DOMSource.class.isAssignableFrom(type);
     }
     
@@ -74,5 +81,9 @@
         } catch (TransformerException te) {
             te.printStackTrace();
         }
+    }
+    
+    public long getSize(DOMSource source) {
+        return -1;
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java Fri Feb 22 12:52:08 2008
@@ -27,21 +27,33 @@
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlRootElement;
 
-public final class JAXBElementProvider implements EntityProvider<Object>  {
+@Provider
+public final class JAXBElementProvider 
+    implements MessageBodyReader<Object>, MessageBodyWriter<Object>  {
 
     static Map<Class, JAXBContext> jaxbContexts = new WeakHashMap<Class, JAXBContext>();
 
-    public boolean supports(Class<?> type) {
+    public boolean isWriteable(Class<?> type) {
+        return type.getAnnotation(XmlRootElement.class) != null;
+    }
+    
+    public boolean isReadable(Class<?> type) {
         return type.getAnnotation(XmlRootElement.class) != null;
     }
 
+    public long getSize(Object o) {
+        return -1;
+    }
+    
     public Object readFrom(Class<Object> type, MediaType m, MultivaluedMap<String, String> headers,
                            InputStream is) {
         try {
@@ -57,29 +69,6 @@
 
     public void writeTo(Object obj, MediaType m, MultivaluedMap<String, Object> headers, OutputStream os) {
         try {
-            //Looks like we do not need to deal with Array and List as multiple root elements 
-            //is not allowed in a plain-old-xml binding anyway.
-/*            if (obj.getClass().isArray() || obj instanceof List) {
-                Class<?> cls = null;
-                Object objArray;
-                if (obj instanceof List) {
-                    List l = (List)obj;
-                    objArray = l.toArray(new Object[l.size()]);
-                    cls = null;
-                } else {
-                    objArray = obj;
-                    cls = objArray.getClass().getComponentType();
-                }
-                int len = Array.getLength(objArray);
-                for (int x = 0; x < len; x++) {
-                    Object o = Array.get(objArray, x);
-                    JAXBContext context = getJAXBContext(o.getClass());
-                    Marshaller marshaller = context.createMarshaller();
-                    marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
-                    marshaller.marshal(new JAXBElement(new QName(null, o.getClass().getSimpleName()),
-                                                       cls == null ? o.getClass() : cls, o), os);
-                }
-            } else {*/
             JAXBContext context = getJAXBContext(obj.getClass());
             Marshaller marshaller = context.createMarshaller();
             marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java Fri Feb 22 12:52:08 2008
@@ -30,7 +30,9 @@
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.EntityProvider;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
@@ -46,12 +48,22 @@
 
 @ProduceMime("application/json")
 @ConsumeMime("application/json")
-public final class JSONProvider implements EntityProvider<Object>  {
+@Provider
+public final class JSONProvider 
+    implements MessageBodyReader<Object>, MessageBodyWriter<Object>  {
 
     static Map<Class, JAXBContext> jaxbContexts = new WeakHashMap<Class, JAXBContext>();
 
-    public boolean supports(Class<?> type) {
+    public boolean isWriteable(Class<?> type) {
         return type.getAnnotation(XmlRootElement.class) != null;
+    }
+    
+    public boolean isReadable(Class<?> type) {
+        return type.getAnnotation(XmlRootElement.class) != null;
+    }
+    
+    public long getSize(Object o) {
+        return -1;
     }
 
     public Object readFrom(Class<Object> type, MediaType m, MultivaluedMap<String, String> headers,



Mime
View raw message