cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r630316 [2/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
Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImpl.java Fri Feb 22 12:52:08 2008
@@ -26,32 +26,40 @@
 
 import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.ProduceMime;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response.Builder;
-import javax.ws.rs.ext.EntityProvider;
 import javax.ws.rs.ext.HeaderProvider;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.ProviderFactory;
 
 import org.apache.cxf.jaxrs.JAXRSUtils;
 
 
-
-//NOTE: ProviderFactory should provide a method that can pass in media types
 public class ProviderFactoryImpl extends ProviderFactory {
-    protected List<EntityProvider> defaultEntityProviders = new ArrayList<EntityProvider>();
-    protected List<EntityProvider> userEntityProviders = new ArrayList<EntityProvider>();
+    protected List<MessageBodyReader> defaultMessageReaders = new ArrayList<MessageBodyReader>();
+    protected List<MessageBodyWriter> defaultMessageWriters = new ArrayList<MessageBodyWriter>();
+    protected List<MessageBodyReader> userMessageReaders = new ArrayList<MessageBodyReader>();
+    protected List<MessageBodyWriter> userMessageWriters = new ArrayList<MessageBodyWriter>();
+    
     protected List<HeaderProvider> headerProviders = new ArrayList<HeaderProvider>();    
 
     public ProviderFactoryImpl() {
-        //TODO: search for EntityProviders from classpath or config file.
-        defaultEntityProviders.add(new JAXBElementProvider());
-        defaultEntityProviders.add(new JSONProvider());
-        defaultEntityProviders.add(new StringProvider());
-        defaultEntityProviders.add(new DOMSourceProvider());
-        defaultEntityProviders.add(new AtomFeedProvider());
-        defaultEntityProviders.add(new AtomEntryProvider());
-        sort(defaultEntityProviders);
+        // TODO : this needs to be done differently,
+        // we need to use cxf-jaxrs-extensions
+        setProviders(defaultMessageReaders,
+                     defaultMessageWriters,
+                     new JSONProvider(),
+                     new JAXBElementProvider(),
+                     new StringProvider(),
+                     new DOMSourceProvider(),
+                     new AtomFeedProvider(),
+                     new AtomEntryProvider());
+        headerProviders.add(new MediaTypeHeaderProvider());
     }
     
+    
+    
     public <T> T createInstance(Class<T> type) {
         if (type.isAssignableFrom(Builder.class)) {
             return type.cast(new BuilderImpl());
@@ -59,36 +67,41 @@
         return null;
     }
    
-    @SuppressWarnings("unchecked")
-    public <T> EntityProvider<T> createEntityProvider(Class<T> type) {
-        
-        //Try user provided providers
-        EntityProvider<T> ep = chooseEntityProvider(userEntityProviders, type);
+    @Override
+    public <T> MessageBodyReader<T> createMessageBodyReader(Class<T> bodyType, MediaType mediaType) {
+        // Try user provided providers
+        MessageBodyReader<T> mr = chooseMessageReader(userMessageReaders, 
+                                                      bodyType,
+                                                      mediaType);
         
         //If none found try the default ones
-        if (ep == null) {
-            ep = chooseEntityProvider(defaultEntityProviders, type);
+        if (mr == null) {
+            mr = chooseMessageReader(defaultMessageReaders,
+                                     bodyType,
+                                     mediaType);
         }     
         
-        return ep;
+        return mr;
     }
 
-    @SuppressWarnings("unchecked")
-    public <T> EntityProvider<T> createEntityProvider(Class<T> type, String[] requestedMimeTypes,
-                                                      boolean isConsumeMime) {
-
-      //Try user defined providers
-        EntityProvider<T> ep = chooseEntityProvider(userEntityProviders, 
-                                                    type, requestedMimeTypes, isConsumeMime);
+    @Override
+    public <T> MessageBodyWriter<T> createMessageBodyWriter(Class<T> bodyType, MediaType mediaType) {
+        // Try user provided providers
+        MessageBodyWriter<T> mw = chooseMessageWriter(userMessageWriters,
+                                                      bodyType,
+                                                      mediaType);
         
         //If none found try the default ones
-        if (ep == null) {
-            ep = chooseEntityProvider(defaultEntityProviders, type, requestedMimeTypes, isConsumeMime);
+        if (mw == null) {
+            mw = chooseMessageWriter(defaultMessageWriters,
+                                     bodyType,
+                                     mediaType);
         }     
         
-        return ep;
+        return mw;
     }
     
+    
     @SuppressWarnings("unchecked")
     public <T> HeaderProvider<T> createHeaderProvider(Class<T> type) {
         for (HeaderProvider<T> hp : headerProviders) {
@@ -100,16 +113,25 @@
         return null;
     }
     
-    public boolean registerUserEntityProvider(EntityProvider e) {
-        userEntityProviders.add(e);
-        sort(userEntityProviders);
-        return true;
+       
+    private void setProviders(List<MessageBodyReader> readers, 
+                              List<MessageBodyWriter> writers, 
+                              Object... providers) {
+        
+        for (Object o : providers) {
+            if (MessageBodyReader.class.isAssignableFrom(o.getClass())) {
+                readers.add((MessageBodyReader)o); 
+            }
+            
+            if (MessageBodyWriter.class.isAssignableFrom(o.getClass())) {
+                writers.add((MessageBodyWriter)o); 
+            }
+        }
+        
+        sortReaders(readers);
+        sortWriters(writers);
     }
     
-    public boolean deregisterUserEntityProvider(EntityProvider e) {
-        return userEntityProviders.remove(e);
-    }
-   
     /*
      * sorts the available providers according to the media types they declare
      * support for. Sorting of media types follows the general rule: x/y < * x < *,
@@ -117,71 +139,42 @@
      * provider that lists *. Quality parameter values are also used such that
      * x/y;q=1.0 < x/y;q=0.7.
      */    
-    private void sort(List<EntityProvider> entityProviders) {
-        Collections.sort(entityProviders, new EntityProviderComparator());
+    private void sortReaders(List<MessageBodyReader> entityProviders) {
+        Collections.sort(entityProviders, new MessageBodyReaderComparator());
     }
     
+    private void sortWriters(List<MessageBodyWriter> entityProviders) {
+        Collections.sort(entityProviders, new MessageBodyWriterComparator());
+    }
     
-    private static class EntityProviderComparator implements Comparator<EntityProvider> {
-        public int compare(EntityProvider e1, EntityProvider e2) {
-            ConsumeMime c = e1.getClass().getAnnotation(ConsumeMime.class);
-            String[] mimeType1 = {"*/*"};
-            if (c != null) {
-                mimeType1 = c.value();               
-            }
-            
-            ConsumeMime c2 = e2.getClass().getAnnotation(ConsumeMime.class);
-            String[] mimeType2 = {"*/*"};
-            if (c2 != null) {
-                mimeType2 = c2.value();               
-            }
-
-            return compareString(mimeType1[0], mimeType2[0]);
-            
-        }
         
-        private int compareString(String str1, String str2) {
-            if (!str1.startsWith("*/") && str2.startsWith("*/")) {
-                return -1;
-            } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
-                return 1;
-            } 
-            
-            return str1.compareTo(str2);
-        }
-    }
-
+    
     /**
-     * Choose the first Entity provider that matches the requestedMimeTypes 
+     * Choose the first body reader provider that matches the requestedMimeType 
      * for a sorted list of Entity providers
      * Returns null if none is found.
      * @param <T>
-     * @param entityProviders
+     * @param messageBodyReaders
      * @param type
-     * @param requestedMimeTypes
-     * @param isConsumeMime
+     * @param requestedMimeType
      * @return
      */
-    private EntityProvider chooseEntityProvider(List<EntityProvider> entityProviders, Class<?> type, 
-                                                 String[] requestedMimeTypes, boolean isConsumeMime) {
-        for (EntityProvider<?> ep : entityProviders) {
-            String[] supportedMimeTypes = {"*/*"};            
-            if (isConsumeMime) {
-                ConsumeMime c = ep.getClass().getAnnotation(ConsumeMime.class);
-                if (c != null) {
-                    supportedMimeTypes = c.value();               
-                }           
-            } else {
-                ProduceMime c = ep.getClass().getAnnotation(ProduceMime.class);
-                if (c != null) {
-                    supportedMimeTypes = c.value();               
-                }                  
+    private <T> MessageBodyReader<T> chooseMessageReader(
+        List<MessageBodyReader> readers, Class<T> type, MediaType mediaType) {
+        for (MessageBodyReader<T> ep : readers) {
+            
+            if (!ep.isReadable(type)) {
+                continue;
             }
             
-            String[] availableMimeTypes = JAXRSUtils.intersectMimeTypes(requestedMimeTypes,
-                                                                        supportedMimeTypes);
+            List<MediaType> supportedMediaTypes =
+                JAXRSUtils.getConsumeTypes(ep.getClass().getAnnotation(ConsumeMime.class));
+            
+            List<MediaType> availableMimeTypes = 
+                JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
+                                              supportedMediaTypes);
 
-            if (availableMimeTypes.length != 0 && ep.supports(type)) {
+            if (availableMimeTypes.size() != 0) {
                 return ep;
             }
         }     
@@ -190,42 +183,142 @@
         
     }
     
+        
     /**
-     * Choose the first Entity provider that matches the type for a sorted list of Entity providers
+     * Choose the first body writer provider that matches the requestedMimeType 
+     * for a sorted list of Entity providers
      * Returns null if none is found.
      * @param <T>
-     * @param entityProviders
+     * @param messageBodyWriters
      * @param type
+     * @param requestedMimeType
      * @return
      */
-    @SuppressWarnings("unchecked")
-    private <T> EntityProvider<T> chooseEntityProvider(List<EntityProvider> entityProviders, Class<T> type) {
-        
-        for (EntityProvider<T> ep : entityProviders) {
-            if (ep.supports(type)) {
+    private <T> MessageBodyWriter<T> chooseMessageWriter(
+        List<MessageBodyWriter> writers, Class<T> type, MediaType mediaType) {
+        for (MessageBodyWriter<T> ep : writers) {
+            if (!ep.isWriteable(type)) {
+                continue;
+            }
+            List<MediaType> supportedMediaTypes =
+                JAXRSUtils.getProduceTypes(ep.getClass().getAnnotation(ProduceMime.class));
+            
+            List<MediaType> availableMimeTypes = 
+                JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
+                                              supportedMediaTypes);
+
+            if (availableMimeTypes.size() != 0) {
                 return ep;
             }
-        }           
+        }     
+        
         return null;
+        
+    }
+    
+        
+    public boolean registerUserEntityProvider(Object o) {
+        setProviders(userMessageReaders, userMessageWriters, o);
+        return true;
     }
     
+    public boolean deregisterUserEntityProvider(Object o) {
+        boolean result = false;
+        if (o instanceof MessageBodyReader) {
+            result = userMessageReaders.remove(o);
+        }
+        return o instanceof MessageBodyReader 
+               ? result && userMessageWriters.remove(o) : result;
+                                               
+    }
     
-    public List<EntityProvider> getDefaultEntityProviders() {
-        return defaultEntityProviders;
+    public List<MessageBodyReader> getDefaultMessageReaders() {
+        return defaultMessageReaders;
     }
 
-
-    public List<EntityProvider> getUserEntityProviders() {
-        return userEntityProviders;
+    public List<MessageBodyWriter> getDefaultMessageWriters() {
+        return defaultMessageWriters;
+    }
+    
+    public List<MessageBodyReader> getUserMessageReaders() {
+        return userMessageReaders;
+    }
+    
+    public List<MessageBodyWriter> getUserMessageWriters() {
+        return userMessageWriters;
     }
 
     /**
      * Use for injection of entityProviders
      * @param entityProviders the entityProviders to set
      */
-    public void setUserEntityProviders(List<EntityProvider> userEntityProviders) {
-        this.userEntityProviders = userEntityProviders;
-        sort(this.userEntityProviders);
+    public void setUserEntityProviders(List<?> userProviders) {
+        setProviders(userMessageReaders,
+                     userMessageWriters,
+                     userProviders.toArray());
+    }
+
+    private static class MessageBodyReaderComparator 
+        implements Comparator<MessageBodyReader> {
+        
+        public int compare(MessageBodyReader e1, MessageBodyReader e2) {
+            ConsumeMime c = e1.getClass().getAnnotation(ConsumeMime.class);
+            String[] mimeType1 = {"*/*"};
+            if (c != null) {
+                mimeType1 = c.value();               
+            }
+            
+            ConsumeMime c2 = e2.getClass().getAnnotation(ConsumeMime.class);
+            String[] mimeType2 = {"*/*"};
+            if (c2 != null) {
+                mimeType2 = c2.value();               
+            }
+    
+            return compareString(mimeType1[0], mimeType2[0]);
+            
+        }
+
+        private int compareString(String str1, String str2) {
+            if (!str1.startsWith("*/") && str2.startsWith("*/")) {
+                return -1;
+            } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
+                return 1;
+            } 
+            
+            return str1.compareTo(str2);
+        }
     }
+    
+    private static class MessageBodyWriterComparator 
+        implements Comparator<MessageBodyWriter> {
+        
+        public int compare(MessageBodyWriter e1, MessageBodyWriter e2) {
+            ProduceMime c = e1.getClass().getAnnotation(ProduceMime.class);
+            String[] mimeType1 = {"*/*"};
+            if (c != null) {
+                mimeType1 = c.value();               
+            }
+            
+            ProduceMime c2 = e2.getClass().getAnnotation(ProduceMime.class);
+            String[] mimeType2 = {"*/*"};
+            if (c2 != null) {
+                mimeType2 = c2.value();               
+            }
+    
+            return compareString(mimeType1[0], mimeType2[0]);
+            
+        }
+        
+        private int compareString(String str1, String str2) {
+            if (!str1.startsWith("*/") && str2.startsWith("*/")) {
+                return -1;
+            } else if (str1.startsWith("*/") && !str2.startsWith("*/")) {
+                return 1;
+            } 
+            
+            return str1.compareTo(str2);
+        }
+    }
+    
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ResponseImpl.java Fri Feb 22 12:52:08 2008
@@ -22,9 +22,7 @@
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 
-import org.apache.cxf.message.Message;
-
-public final class ResponseImpl implements Response {
+public final class ResponseImpl extends Response {
     private final int status;
     private final Object entity;
     private MultivaluedMap<String, Object> metadata;
@@ -43,7 +41,7 @@
         return status;
     }
 
-    public void addMetadata(MultivaluedMap<String, Object> meta) { 
+    void addMetadata(MultivaluedMap<String, Object> meta) { 
         this.metadata = meta;
     }
     
@@ -52,9 +50,4 @@
         return metadata;
     }
     
-    public void serializeMetadata(Message m) {
-        
-        m.put(Message.PROTOCOL_HEADERS, metadata);
-        
-    }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java Fri Feb 22 12:52:08 2008
@@ -23,16 +23,29 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+
 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.cxf.helpers.IOUtils;
 
-public final class StringProvider implements EntityProvider<String>  {
+@Provider
+public final class StringProvider 
+    implements MessageBodyWriter<String>, MessageBodyReader<String>  {
 
-    public boolean supports(Class<?> type) {
+    public boolean isWriteable(Class<?> type) {
+        return type == String.class;
+    }
+    
+    public boolean isReadable(Class<?> type) {
         return type == String.class;
+    }
+    
+    public long getSize(String s) {
+        return s.length();
     }
 
     public String readFrom(Class<String> type, MediaType m, MultivaluedMap<String, String> headers,

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSUtilsTest.java Fri Feb 22 12:52:08 2008
@@ -19,15 +19,21 @@
 package org.apache.cxf.jaxrs;
 
 import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.MethodDispatcher;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
+import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.junit.Assert;
@@ -35,13 +41,24 @@
 import org.junit.Test;
 
 public class JAXRSUtilsTest extends Assert {
+    
     public class Customer {
-        @ProduceMime("text/xml")   
+        @ProduceMime("text/xml")
+        @ConsumeMime("text/xml")
         public void test() {
             // complete
         }
         
         @ProduceMime("text/xml")   
+        public void getItAsXML() {
+            // complete
+        }
+        @ProduceMime("text/plain")   
+        public void getItPlain() {
+            // complete
+        }
+        
+        @ProduceMime("text/xml")   
         public void testQuery(@QueryParam("query") String queryString, @QueryParam("query") int queryInt) {
             // complete
         }
@@ -155,119 +172,185 @@
     @Test
     public void testIntersectMimeTypes() throws Exception {
         //test basic
-        String[] methodMimeTypes = new String[]{"application/mytype", "application/xml", "application/json"};
-        String acceptContentType = "application/json";
-        String[] candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);  
+        List<MediaType> methodMimeTypes = new ArrayList<MediaType>(
+             JAXRSUtils.parseMediaTypes("application/mytype,application/xml,application/json"));
+        
+        MediaType acceptContentType = MediaType.parse("application/json");
+        List <MediaType> candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, 
+                                                 MediaType.parse("application/json"));  
 
-        assertEquals(1, candidateList.length);
-        assertTrue(candidateList[0].equals("application/json"));
+        assertEquals(1, candidateList.size());
+        assertTrue(candidateList.get(0).toString().equals("application/json"));
         
         //test basic       
-        methodMimeTypes = new String[]{"application/mytype", "application/json", "application/xml"};
-        acceptContentType = "application/json";
-        candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);  
+        methodMimeTypes = JAXRSUtils.parseMediaTypes(
+            "application/mytype, application/json, application/xml");
+        candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, 
+                                                      MediaType.parse("application/json"));  
 
-        assertEquals(1, candidateList.length);
-        assertTrue(candidateList[0].equals("application/json"));
+        assertEquals(1, candidateList.size());
+        assertTrue(candidateList.get(0).toString().equals("application/json"));
         
         //test accept wild card */*       
-        methodMimeTypes = new String[]{"application/mytype", "application/json", "application/xml"};
-        acceptContentType = "*/*";
-        candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);  
+        candidateList = JAXRSUtils.intersectMimeTypes(
+            "application/mytype,application/json,application/xml", "*/*");  
 
-        assertEquals(3, candidateList.length);
+        assertEquals(3, candidateList.size());
         
         //test accept wild card application/*       
-        methodMimeTypes = new String[]{"text/html", "text/xml", "application/xml"};
-        acceptContentType = "text/*";
+        methodMimeTypes = JAXRSUtils.parseMediaTypes("text/html,text/xml,application/xml");
+        acceptContentType = MediaType.parse("text/*");
         candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);  
 
-        assertEquals(2, candidateList.length);
-        for (String type : candidateList) {
-            assertTrue("text/html".equals(type) || "text/xml".equals(type));            
+        assertEquals(2, candidateList.size());
+        for (MediaType type : candidateList) {
+            assertTrue("text/html".equals(type.toString()) 
+                       || "text/xml".equals(type.toString()));            
         }
         
         //test produce wild card */*
-        methodMimeTypes = new String[]{"*/*"};
-        acceptContentType = "application/json";
-        candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);  
+        candidateList = JAXRSUtils.intersectMimeTypes("*/*", "application/json");
 
-        assertEquals(1, candidateList.length);
-        assertTrue("application/json".equals(candidateList[0]));
+        assertEquals(1, candidateList.size());
+        assertTrue("application/json".equals(candidateList.get(0).toString()));
         
         //test produce wild card application/*
-        methodMimeTypes = new String[]{"application/*"};
-        acceptContentType = "application/json";
-        candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);  
+        candidateList = JAXRSUtils.intersectMimeTypes("application/*", "application/json");  
 
-        assertEquals(1, candidateList.length);
-        assertTrue("application/json".equals(candidateList[0]));        
+        assertEquals(1, candidateList.size());
+        assertTrue("application/json".equals(candidateList.get(0).toString()));        
         
         //test produce wild card */*, accept wild card */*
-        methodMimeTypes = new String[]{"*/*"};
-        acceptContentType = "*/*";
-        candidateList = JAXRSUtils.intersectMimeTypes(methodMimeTypes, acceptContentType);  
+        candidateList = JAXRSUtils.intersectMimeTypes("*/*", "*/*");  
 
-        assertEquals(1, candidateList.length);
-        assertTrue("*/*".equals(candidateList[0]));
+        assertEquals(1, candidateList.size());
+        assertTrue("*/*".equals(candidateList.get(0).toString()));
     }
     
     @Test
     public void testIntersectMimeTypesTwoArray() throws Exception {
         //test basic
-        String[] acceptedMimeTypes = new String[] {"application/mytype", "application/xml",
-                                                   "application/json"};
-        String[] providerMimeTypes = new String[] {"*/*"};
-
-        String[] candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, providerMimeTypes);
-
-        assertEquals(3, candidateList.length);
-        for (String type : candidateList) {
-            assertTrue("application/mytype".equals(type) || "application/xml".equals(type)
-                       || "application/json".equals(type));
+        List <MediaType> acceptedMimeTypes = 
+            JAXRSUtils.parseMediaTypes("application/mytype, application/xml, application/json");
+        
+        List <MediaType> candidateList = 
+            JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, JAXRSUtils.ALL_TYPES);
+
+        assertEquals(3, candidateList.size());
+        for (MediaType type : candidateList) {
+            assertTrue("application/mytype".equals(type.toString()) 
+                       || "application/xml".equals(type.toString())
+                       || "application/json".equals(type.toString()));
         }
         
         //test basic
-        acceptedMimeTypes = new String[] {"*/*"};
-        providerMimeTypes = new String[] {"application/mytype", "application/xml", "application/json"};
+        acceptedMimeTypes = Collections.singletonList(JAXRSUtils.ALL_TYPES);
+        List<MediaType> providerMimeTypes = 
+            JAXRSUtils.parseMediaTypes("application/mytype, application/xml, application/json");
 
         candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, providerMimeTypes);
 
-        assertEquals(3, candidateList.length);
-        for (String type : candidateList) {
-            assertTrue("application/mytype".equals(type) || "application/xml".equals(type)
-                       || "application/json".equals(type));
+        assertEquals(3, candidateList.size());
+        for (MediaType type : candidateList) {
+            assertTrue("application/mytype".equals(type.toString()) 
+                       || "application/xml".equals(type.toString())
+                       || "application/json".equals(type.toString()));
         }
         
         //test empty
-        acceptedMimeTypes = new String[] {"application/mytype", "application/xml"};
-        providerMimeTypes = new String[] {"application/json"};
-
-        candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, providerMimeTypes);
+        acceptedMimeTypes = JAXRSUtils.parseMediaTypes("application/mytype,application/xml");
+        
+        candidateList = JAXRSUtils.intersectMimeTypes(acceptedMimeTypes, 
+                                                      MediaType.parse("application/json"));
 
-        assertEquals(0, candidateList.length);
+        assertEquals(0, candidateList.size());
+    }
+    
+    @Test
+    public void testParseMediaTypes() throws Exception {
+        List<MediaType> types = JAXRSUtils.parseMediaTypes("*");
+        assertTrue(types.size() == 1 
+                   && types.get(0).equals(JAXRSUtils.ALL_TYPES));
+        types = JAXRSUtils.parseMediaTypes("text/*");
+        assertTrue(types.size() == 1 && types.get(0).equals(new MediaType("text", "*")));
+        types = JAXRSUtils.parseMediaTypes("text/*,text/plain;q=.2,text/xml,TEXT/BAR");
+        assertTrue(types.size() == 4
+                   && "text/*".equals(types.get(0).toString())
+                   && "text/plain;q=.2".equals(types.get(1).toString())
+                   && "text/xml".equals(types.get(2).toString())
+                   && "text/bar".equals(types.get(3).toString()));
+        
+    }
+    
+    @Test
+    public void testSortMediaTypes() throws Exception {
+        List<MediaType> types = 
+            JAXRSUtils.sortMediaTypes("text/*,text/plain;q=.2,text/xml,TEXT/BAR");
+        assertTrue(types.size() == 4
+                   && "text/bar".equals(types.get(0).toString())
+                   && "text/plain;q=.2".equals(types.get(1).toString())
+                   && "text/xml".equals(types.get(2).toString())
+                   && "text/*".equals(types.get(3).toString()));
+    }
+    
+    @Test
+    public void testCompareMediaTypes() throws Exception {
+        MediaType m1 = MediaType.parse("text/xml");
+        MediaType m2 = MediaType.parse("text/*");
+        assertTrue("text/xml is more specific than text/*", 
+                   JAXRSUtils.compareMediaTypes(m1, m2) < 0);
+        assertTrue("text/* is less specific than text/*", 
+                   JAXRSUtils.compareMediaTypes(m2, m1) > 0);
+        assertTrue("text/xml should be equal to itself", 
+                   JAXRSUtils.compareMediaTypes(m1, new MediaType("text", "xml")) == 0);
+        assertTrue("text/* should be equal to itself", 
+                   JAXRSUtils.compareMediaTypes(m2, new MediaType("text", "*")) == 0);
+        
+        assertTrue("text/plain is alphabetically earlier than text/xml", 
+                   JAXRSUtils.compareMediaTypes(MediaType.parse("text/plain"), m1) < 0);
+        assertTrue("text/xml is alphabetically later than text/plain", 
+                   JAXRSUtils.compareMediaTypes(m1, MediaType.parse("text/plain")) > 0);
+        assertTrue("*/* is less specific than text/xml", 
+                   JAXRSUtils.compareMediaTypes(JAXRSUtils.ALL_TYPES, m1) > 0);
+        assertTrue("*/* is less specific than text/xml", 
+                   JAXRSUtils.compareMediaTypes(m1, JAXRSUtils.ALL_TYPES) < 0);
+        assertTrue("*/* is less specific than text/*", 
+                   JAXRSUtils.compareMediaTypes(JAXRSUtils.ALL_TYPES, m2) > 0);
+        assertTrue("*/* is less specific than text/*", 
+                   JAXRSUtils.compareMediaTypes(m2, JAXRSUtils.ALL_TYPES) < 0);
+        
+        MediaType m3 = MediaType.parse("text/xml;q=0.2");
+        assertTrue("text/xml should be more preferred than than text/xml;q=0.2", 
+                   JAXRSUtils.compareMediaTypes(m1, m3) < 0);
+        MediaType m4 = MediaType.parse("text/xml;q=.3");
+        assertTrue("text/xml;q=.3 should be more preferred than than text/xml;q=0.2", 
+                   JAXRSUtils.compareMediaTypes(m4, m3) < 0);
     }
     
     @Test
     public void testAcceptTypesMatch() throws Exception {
         
         Method m = Customer.class.getMethod("test", new Class[]{});
+        ClassResourceInfo cr = new ClassResourceInfo(Customer.class);
         
-        assertTrue("Accept types with multiple values can not be matched properly",
-                   JAXRSUtils.matchMimeTypes(null, "text/xml,text/bar", m));
-        assertTrue("Accept types with multiple values can not be matched properly",
-                   JAXRSUtils.matchMimeTypes(null, "text/foo, text/bar, text/xml ", m));
-        assertTrue("Accept types with multiple values can not be matched properly",
-                   JAXRSUtils.matchMimeTypes(null, "text/bar,text/xml", m));
-        assertTrue("Accept types with multiple values can not be matched properly",
-                   JAXRSUtils.matchMimeTypes(null, "text/*", m));
-        assertTrue("Accept types with multiple values can not be matched properly",
-                   JAXRSUtils.matchMimeTypes(null, "*/*", m));
-        assertTrue("Accept types with multiple values can not be matched properly",
-                   JAXRSUtils.matchMimeTypes(null, null, m));
-        
-        
+        assertTrue("text/xml can not be matched",
+                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES, 
+                                             new MediaType("text", "xml"), 
+                                             new OperationResourceInfo(m, cr)));
+        assertTrue("text/xml can not be matched",
+                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES, 
+                                             new MediaType("text", "*"), 
+                                             new OperationResourceInfo(m, cr)));
+        assertTrue("text/xml can not be matched",
+                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES, 
+                                             new MediaType("*", "*"), 
+                                             new OperationResourceInfo(m, cr)));
+        assertFalse("text/plain was matched",
+                   JAXRSUtils.matchMimeTypes(JAXRSUtils.ALL_TYPES, 
+                                             new MediaType("text", "plain"), 
+                                             new OperationResourceInfo(m, cr)));
     }
+ 
     
     @Test
     public void testQueryParameters() throws Exception {
@@ -276,7 +359,9 @@
         MessageImpl messageImpl = new MessageImpl();
         
         messageImpl.put(Message.QUERY_STRING, "query=24");
-        List<Object> params = JAXRSUtils.processParameters(m, null, messageImpl);
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null),
+                                                           null, 
+                                                           messageImpl);
         assertEquals("Query Parameter was not matched correctly", "24", params.get(0));
         assertEquals("Primitive Query Parameter was not matched correctly", 24, params.get(1));
         
@@ -290,9 +375,48 @@
         MessageImpl messageImpl = new MessageImpl();
         
         messageImpl.put(Message.QUERY_STRING, "query=first&query2=second");
-        List<Object> params = JAXRSUtils.processParameters(m, null, messageImpl);
+        List<Object> params = JAXRSUtils.processParameters(new OperationResourceInfo(m, null), 
+                                                           null, messageImpl);
         assertEquals("First Query Parameter of multiple was not matched correctly", "first", params.get(0));
         assertEquals("Second Query Parameter of multiple was not matched correctly", 
                      "second", params.get(1));    
+    }
+    
+    @Test
+    public void testSelectResourceMethod() throws Exception {
+        ClassResourceInfo cri = new ClassResourceInfo(Customer.class);
+        OperationResourceInfo ori1 = new OperationResourceInfo(
+                                         Customer.class.getMethod("getItAsXML", new Class[]{}), 
+                                         cri);
+        ori1.setHttpMethod("GET");
+        ori1.setURITemplate(new URITemplate("/"));
+        OperationResourceInfo ori2 = new OperationResourceInfo(
+                                         Customer.class.getMethod("getItPlain", new Class[]{}), 
+                                         cri);
+        ori2.setHttpMethod("GET");
+        ori2.setURITemplate(new URITemplate("/"));
+        MethodDispatcher md = new MethodDispatcher(); 
+        md.bind(ori1, Customer.class.getMethod("getItAsXML", new Class[]{}));
+        md.bind(ori2, Customer.class.getMethod("getItPlain", new Class[]{}));
+        cri.setMethodDispatcher(md);
+        
+        OperationResourceInfo ori = JAXRSUtils.findTargetMethod(cri, "/", "GET", null, 
+                                               "*/*", "text/plain");
+        
+        assertSame(ori, ori2);
+        
+        ori = JAXRSUtils.findTargetMethod(cri, "/", "GET", null, 
+                                              "*/*", "text/xml");
+                         
+        assertSame(ori, ori1);
+        
+        ori = JAXRSUtils.findTargetMethod(cri, "/", "GET", null, 
+                                          "*/*", "*,text/plain,text/xml");
+                     
+        assertSame(ori, ori2);
+        ori = JAXRSUtils.findTargetMethod(cri, "/", "GET", null, 
+                                          "*/*", "*,x/y,text/xml,text/plain");
+                     
+        assertSame(ori, ori2);
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/MetadataMapTest.java Fri Feb 22 12:52:08 2008
@@ -31,7 +31,7 @@
     
     @Test
     public void testPutSingle() {
-        MetadataMap m = new MetadataMap();
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
         List<Object> value1 = new ArrayList<Object>();
         value1.add("bar");
         value1.add("foo");
@@ -45,7 +45,7 @@
     
     @Test
     public void testAddAndGetFirst() {
-        MetadataMap m = new MetadataMap();
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
         m.add("baz", "bar");
         
         List<Object> value = m.get("baz");

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomEntryProviderTest.java Fri Feb 22 12:52:08 2008
@@ -66,10 +66,17 @@
     }
     
     @Test
-    public void testSupports() {
-        assertTrue(afd.supports(Entry.class));
-        assertTrue(afd.supports(FOMEntry.class));
-        assertFalse(afd.supports(Feed.class));
+    public void testWriteable() {
+        assertTrue(afd.isWriteable(Entry.class));
+        assertTrue(afd.isWriteable(FOMEntry.class));
+        assertFalse(afd.isWriteable(Feed.class));
+    }
+    
+    @Test
+    public void testReadable() {
+        assertTrue(afd.isReadable(Entry.class));
+        assertTrue(afd.isReadable(FOMEntry.class));
+        assertFalse(afd.isReadable(Feed.class));
     }
     
     @Test

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomFeedProviderTest.java Fri Feb 22 12:52:08 2008
@@ -64,10 +64,17 @@
     }
     
     @Test
-    public void testSupports() {
-        assertTrue(afd.supports(Feed.class));
-        assertTrue(afd.supports(FOMFeed.class));
-        assertFalse(afd.supports(Entry.class));
+    public void testWriteable() {
+        assertTrue(afd.isWriteable(Feed.class));
+        assertTrue(afd.isWriteable(FOMFeed.class));
+        assertFalse(afd.isWriteable(Entry.class));
+    }
+    
+    @Test
+    public void testReadable() {
+        assertTrue(afd.isReadable(Feed.class));
+        assertTrue(afd.isReadable(FOMFeed.class));
+        assertFalse(afd.isReadable(Entry.class));
     }
     
     @Test

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/BuilderImplTest.java Fri Feb 22 12:52:08 2008
@@ -34,25 +34,25 @@
     @Test
     public void testOkBuild() {
       
-        checkBuild(Response.Builder.ok().build(),
-                          200, null, new MetadataMap());
+        checkBuild(Response.ok().build(),
+                          200, null, new MetadataMap<String, Object>());
         
     }
     
     @Test
     public void testCreatedNoEntity() throws Exception {
         
-        MetadataMap m = new MetadataMap();
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
         m.putSingle("Location", "http://foo");
         
-        checkBuild(Response.Builder.created(new URI("http://foo")).build(),
+        checkBuild(Response.created(new URI("http://foo")).build(),
                    201, null, m);
         
         
     }
     
     private void checkBuild(Response r, int status, Object entity, 
-                            MetadataMap meta) {
+                            MetadataMap<String, Object> meta) {
         ResponseImpl ri = (ResponseImpl)r;
         assertEquals("Wrong status", ri.getStatus(), status);
         assertSame("Wrong entity", ri.getEntity(), entity);

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryImplTest.java Fri Feb 22 12:52:08 2008
@@ -27,7 +27,8 @@
 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.ProviderFactory;
 import javax.xml.bind.annotation.XmlRootElement;
 
@@ -51,77 +52,78 @@
         pf.registerUserEntityProvider(new TestStringProvider());
         pf.registerUserEntityProvider(new StringProvider());
         
-        List<EntityProvider> providers = pf.getUserEntityProviders();
+        List<MessageBodyReader> readers = pf.getUserMessageReaders();
 
-        assertTrue(indexOf(providers, TestStringProvider.class) < indexOf(providers, StringProvider.class));
+        assertTrue(indexOf(readers, TestStringProvider.class) 
+                   < indexOf(readers, StringProvider.class));
+        
+        List<MessageBodyWriter> writers = pf.getUserMessageWriters();
+
+        assertTrue(indexOf(writers, TestStringProvider.class) 
+                   < indexOf(writers, StringProvider.class));
+        
         //REVISIT the compare algorithm
         //assertTrue(indexOf(providers, JSONProvider.class) < indexOf(providers, TestStringProvider.class));
     }
     
     @Test
     public void testGetStringProvider() throws Exception {
-        String[] methodMimeTypes = {"text/html"};
-        EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(String.class, methodMimeTypes, false);
-        assertTrue(provider instanceof StringProvider);
+        verifyProvider(String.class, StringProvider.class, "text/html");
     }
     
+    
+    private void verifyProvider(Class<?> type, Class<?> provider, String mediaType,
+                                String errorMessage) 
+        throws Exception {
+        
+        MediaType mType = MediaType.parse(mediaType);
+        
+        MessageBodyReader reader = ProviderFactory.getInstance()
+            .createMessageBodyReader(type, mType);
+        assertTrue(errorMessage, provider == reader.getClass());
+    
+        MessageBodyWriter writer = ProviderFactory.getInstance()
+            .createMessageBodyWriter(type, mType);
+        assertTrue(errorMessage, provider == writer.getClass());
+    }
+    
+    
+    private void verifyProvider(Class<?> type, Class<?> provider, String mediaType) 
+        throws Exception {
+        verifyProvider(type, provider, mediaType, "Unexpected provider found");
+        
+    }
+       
     @Test
     public void testGetStringProviderWildCard() throws Exception {
-        String[] methodMimeTypes = {"text/*"};
-        EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(String.class, methodMimeTypes, false);
-        assertTrue(provider instanceof StringProvider);
+        verifyProvider(String.class, StringProvider.class, "text/*");
     }
     
     @Test
     public void testGetAtomProvider() throws Exception {
-        String[] methodMimeTypes = {"application/atom+xml"};
-        EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(Feed.class, methodMimeTypes, false);
-        assertTrue(provider instanceof AtomFeedProvider);
-        
-        provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(Feed.class, methodMimeTypes, true);
-        assertTrue(provider instanceof AtomFeedProvider);
-        
-        provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(Entry.class, methodMimeTypes, false);
-        assertTrue(provider instanceof AtomEntryProvider);
-        
-        provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(Entry.class, methodMimeTypes, true);
-        assertTrue(provider instanceof AtomEntryProvider);
+        verifyProvider(Entry.class, AtomEntryProvider.class, "application/atom+xml");
+        verifyProvider(Feed.class, AtomFeedProvider.class, "application/atom+xml");
     }
     
     @Test
     public void testGetStringProviderUsingProviderDeclaration() throws Exception {
-        String[] methodMimeTypes = {"text/html"};
         ProviderFactoryImpl pf = (ProviderFactoryImpl)ProviderFactory.getInstance();
         pf.registerUserEntityProvider(new TestStringProvider());
-        EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(String.class, methodMimeTypes, false);
-        assertTrue(provider instanceof TestStringProvider);
+        verifyProvider(String.class, TestStringProvider.class, "text/html");
     }    
     
     @Test
     public void testGetJSONProviderConsumeMime() throws Exception {
-        String[] methodMimeTypes = {"application/json"};
-        EntityProvider provider = ((ProviderFactoryImpl)ProviderFactory.getInstance())
-        .createEntityProvider(org.apache.cxf.jaxrs.resources.Book.class, methodMimeTypes, true);
-        assertTrue(provider instanceof JSONProvider);
+        verifyProvider(org.apache.cxf.jaxrs.resources.Book.class, JSONProvider.class, 
+                       "application/json");
     }
     
     @Test
     public void testRegisterCustomJSONEntityProvider() throws Exception {
         ProviderFactoryImpl pf = (ProviderFactoryImpl)ProviderFactory.getInstance();
         pf.registerUserEntityProvider(new CustomJSONProvider());
-        
-        String[] methodMimeTypes = {"application/json"};
-        EntityProvider provider = pf.createEntityProvider(org.apache.cxf.jaxrs.resources.Book.class, 
-                                                          methodMimeTypes, 
-                                                          true);
-        assertTrue("User Registered provider was not returned first", provider instanceof CustomJSONProvider);
+        verifyProvider(org.apache.cxf.jaxrs.resources.Book.class, CustomJSONProvider.class, 
+                       "application/json", "User-registered provider was not returned first");
     }
     
     @Test
@@ -129,17 +131,13 @@
         ProviderFactoryImpl pf = (ProviderFactoryImpl)ProviderFactory.getInstance();
         pf.registerUserEntityProvider(new CustomWidgetProvider());
         
-        String[] methodMimeTypes = {"application/widget"};
-        EntityProvider provider = pf.createEntityProvider(org.apache.cxf.jaxrs.resources.Book.class, 
-                                                          methodMimeTypes, 
-                                                          true);
-        assertTrue("User Registered provider was not returned first", 
-                   provider instanceof CustomWidgetProvider);
+        verifyProvider(org.apache.cxf.jaxrs.resources.Book.class, CustomWidgetProvider.class, 
+                       "application/widget", "User-registered provider was not returned first");
     }
     
-    private int indexOf(List<EntityProvider> providers, Class providerType) {
+    private int indexOf(List<? extends Object> providers, Class providerType) {
         int index = 0;
-        for (EntityProvider p : providers) {
+        for (Object p : providers) {
             if (p.getClass().isAssignableFrom(providerType)) {
                 break;
             }
@@ -150,11 +148,20 @@
     
     @ConsumeMime("text/html")
     @ProduceMime("text/html")
-    private final class TestStringProvider implements EntityProvider<String>  {
+    private final class TestStringProvider 
+        implements MessageBodyReader<String>, MessageBodyWriter<String>  {
 
-        public boolean supports(Class<?> type) {
+        public boolean isReadable(Class<?> type) {
             return type == String.class;
         }
+        
+        public boolean isWriteable(Class<?> type) {
+            return type == String.class;
+        }
+        
+        public long getSize(String s) {
+            return s.length();
+        }
 
         public String readFrom(Class<String> type, MediaType m, MultivaluedMap<String, String> headers,
                                InputStream is) {
@@ -179,11 +186,20 @@
     
     @ConsumeMime("application/json")
     @ProduceMime("application/json")
-    private final class CustomJSONProvider implements EntityProvider<String>  {
+    private final class CustomJSONProvider 
+        implements MessageBodyReader<String>, MessageBodyWriter<String>  {
 
-        public boolean supports(Class<?> type) {
+        public boolean isReadable(Class<?> type) {
             return type.getAnnotation(XmlRootElement.class) != null;
         }
+        
+        public boolean isWriteable(Class<?> type) {
+            return type.getAnnotation(XmlRootElement.class) != null;
+        }
+        
+        public long getSize(String s) {
+            return s.length();
+        }
 
         public String readFrom(Class<String> type, MediaType m, MultivaluedMap<String, String> headers,
                                InputStream is) {    
@@ -200,11 +216,21 @@
     
     @ConsumeMime("application/widget")
     @ProduceMime("application/widget")
-    private final class CustomWidgetProvider implements EntityProvider<String>  {
+    private final class CustomWidgetProvider
+        implements MessageBodyReader<String>, MessageBodyWriter<String>  {
 
-        public boolean supports(Class<?> type) {
+        public boolean isReadable(Class<?> type) {
+            return type.getAnnotation(XmlRootElement.class) != null;
+        }
+        
+        public boolean isWriteable(Class<?> type) {
             return type.getAnnotation(XmlRootElement.class) != null;
         }
+        
+        public long getSize(String s) {
+            return s.length();
+        }
+
 
         public String readFrom(Class<String> type, MediaType m, MultivaluedMap<String, String> headers,
                                InputStream is) {    

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ResponseImplTest.java Fri Feb 22 12:52:08 2008
@@ -20,8 +20,6 @@
 package org.apache.cxf.jaxrs.provider;
 
 import org.apache.cxf.jaxrs.MetadataMap;
-import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -35,11 +33,10 @@
         assertEquals("Wrong status", ri.getStatus(), 200);
         assertSame("Wrong entity", entity, ri.getEntity());
         
-        MetadataMap meta = new MetadataMap();
-        Message m = new MessageImpl();
+        MetadataMap<String, Object> meta = new MetadataMap<String, Object>();
         ri.addMetadata(meta);
-        ri.serializeMetadata(m);
-        assertSame("Wrong metadata", meta, m.get(Message.PROTOCOL_HEADERS));
+        ri.getMetadata();
+        assertSame("Wrong metadata", meta, ri.getMetadata());
     }
 
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/Book.java Fri Feb 22 12:52:08 2008
@@ -22,9 +22,9 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.xml.bind.annotation.XmlRootElement;
 
 
@@ -52,13 +52,13 @@
         return id;
     }
     
-    @UriTemplate("chapters/{chapterid}/")
-    @HttpMethod("GET")
+    @Path("chapters/{chapterid}/")
+    @GET
     public Chapter getChapter(@UriParam("id")int chapterid) {
         return chapters.get(new Long(chapterid));
     }   
 
-    @HttpMethod("GET")
+    @GET
     public String getState() {
         return "";
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookNoSubResource.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookNoSubResource.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookNoSubResource.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookNoSubResource.java Fri Feb 22 12:52:08 2008
@@ -22,9 +22,9 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.xml.bind.annotation.XmlRootElement;
 
 
@@ -52,8 +52,8 @@
         return id;
     }
     
-    @UriTemplate("chapters/{chapterid}/")
-    @HttpMethod("GET")
+    @Path("chapters/{chapterid}/")
+    @GET
     public Chapter getChapter(@UriParam("id")int chapterid) {
         return chapters.get(new Long(chapterid));
     }   

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStore.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStore.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStore.java Fri Feb 22 12:52:08 2008
@@ -20,36 +20,38 @@
 
 package org.apache.cxf.jaxrs.resources;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.ws.rs.core.Response;
 
-@UriTemplate("/bookstore/")
+@Path("/bookstore/")
 public class BookStore {
 
     public BookStore() {
     }
 
-    @UriTemplate("/books/{bookId}/")
+    @Path("/books/{bookId}/")
     public Book getBook(@UriParam("bookId") String id) {
         return null;
     }
 
-    @HttpMethod("POST")
-    @UriTemplate("/books")
+    @POST
+    @Path("/books")
     public Response addBook(Book book) {
         return null;
     }
 
-    @HttpMethod("PUT")
-    @UriTemplate("/books/")
+    @PUT
+    @Path("/books/")
     public Response updateBook(Book book) {
         return null;
     }
 
-    @HttpMethod("DELETE")
-    @UriTemplate("/books/{bookId}/")
+    @DELETE
+    @Path("/books/{bookId}/")
     public Response deleteBook(@UriParam("bookId") String id) {
         return null;
     }

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreNoSubResource.java Fri Feb 22 12:52:08 2008
@@ -20,46 +20,49 @@
 
 package org.apache.cxf.jaxrs.resources;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.ws.rs.core.Response;
 
-@UriTemplate("/bookstore/")
+@Path("/bookstore/")
 public class BookStoreNoSubResource {
 
     public BookStoreNoSubResource() {
     }
 
-    @HttpMethod("GET")
-    @UriTemplate("/books/{bookId}/")
+    @GET
+    @Path("/books/{bookId}/")
     @ProduceMime("application/xml")
     public Book getBook(@UriParam("bookId") String id) {
         return null;
     }    
     
-    @HttpMethod("GET")
-    @UriTemplate("/books/{bookId}/")
+    @GET
+    @Path("/books/{bookId}/")
     @ProduceMime("application/json")
     public Book getBookJSON(@UriParam("bookId") String id) {
         return null;
     } 
 
-    @HttpMethod("POST")
-    @UriTemplate("/books")
+    @POST
+    @Path("/books")
     public Response addBook(Book book) {
         return null;
     }
 
-    @HttpMethod("PUT")
-    @UriTemplate("/books/")
+    @PUT
+    @Path("/books/")
     public Response updateBook(Book book) {
         return null;
     }
 
-    @HttpMethod("DELETE")
-    @UriTemplate("/books/{bookId}/")
+    @Path("/books/{bookId}/")
+    @DELETE
     public Response deleteBook(@UriParam("bookId") String id) {
         return null;
     }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java Fri Feb 22 12:52:08 2008
@@ -19,7 +19,7 @@
 
 package org.apache.cxf.systest.jaxrs;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.GET;
 import javax.ws.rs.ProduceMime;
 
 import org.apache.abdera.model.Entry;
@@ -34,7 +34,7 @@
     
     
     
-    @HttpMethod("GET")
+    @GET
     @ProduceMime("application/atom+xml")
     public Entry getAsEntry() {
         try {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java Fri Feb 22 12:52:08 2008
@@ -27,10 +27,11 @@
 import java.util.Map;
 
 import javax.ws.rs.ConsumeMime;
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
 
@@ -41,7 +42,7 @@
 import org.apache.cxf.customer.book.BookNotFoundDetails;
 import org.apache.cxf.customer.book.BookNotFoundFault;
 
-@UriTemplate("/bookstore/")
+@Path("/bookstore/")
 public class AtomBookStore {
 
     private Map<Long, Book> books = new HashMap<Long, Book>();
@@ -54,8 +55,8 @@
         System.out.println("----books: " + books.size());
     }
     
-    @HttpMethod("GET")
-    @UriTemplate("/books/feed")
+    @GET
+    @Path("/books/feed")
     @ProduceMime("application/atom+xml")
     public Feed getBooksAsFeed() {
         Factory factory = Abdera.getNewFactory();
@@ -76,8 +77,8 @@
         return f;
     }
     
-    @HttpMethod("POST")
-    @UriTemplate("/books/feed")
+    @POST
+    @Path("/books/feed")
     @ConsumeMime("application/atom+xml")
     public Response addBookAsEntry(Entry e) {
         try {
@@ -89,14 +90,14 @@
             
             // this code is broken as Response does not
             URI uri = new URI("http://localhost:9080/bookstore/books/entries/" + b.getId());
-            return Response.Builder.created(uri).build();
+            return Response.created(uri).build();
         } catch (Exception ex) {
-            return Response.Builder.serverError().build();
+            return Response.serverError().build();
         }
     }
     
-    @HttpMethod("GET")
-    @UriTemplate("/books/entries/{bookId}/")
+    @GET
+    @Path("/books/entries/{bookId}/")
     @ProduceMime("application/atom+xml")
     public Entry getBookAsEntry(@UriParam("bookId") String id) throws BookNotFoundFault {
         System.out.println("----invoking getBook with id: " + id);
@@ -115,7 +116,7 @@
         return null;
     }
     
-    @UriTemplate("/books/subresources/{bookId}/")
+    @Path("/books/subresources/{bookId}/")
     public AtomBook getBook(@UriParam("bookId") String id) throws BookNotFoundFault {
         System.out.println("----invoking getBook with id: " + id);
         Book book = books.get(Long.parseLong(id));

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BadgerFishProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BadgerFishProvider.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BadgerFishProvider.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BadgerFishProvider.java Fri Feb 22 12:52:08 2008
@@ -29,7 +29,8 @@
 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.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
@@ -45,14 +46,23 @@
 
 @ProduceMime("application/json")
 @ConsumeMime("application/json")
-public final class BadgerFishProvider implements EntityProvider<Object>  {
+public final class BadgerFishProvider 
+    implements MessageBodyReader<Object>, MessageBodyWriter<Object>  {
 
     static Map<Class, JAXBContext> jaxbContexts = new WeakHashMap<Class, JAXBContext>();
 
-    public boolean supports(Class<?> type) {
+    public boolean isReadable(Class<?> type) {
+        return type.getAnnotation(XmlRootElement.class) != null;
+    }
+    
+    public boolean isWriteable(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 {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Book.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Book.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/Book.java Fri Feb 22 12:52:08 2008
@@ -22,9 +22,9 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.xml.bind.annotation.XmlRootElement;
 
 
@@ -54,8 +54,8 @@
         return id;
     }
     
-    @HttpMethod("GET")
-    @UriTemplate("chapters/{chapterid}/")    
+    @GET
+    @Path("chapters/{chapterid}/")    
     public Chapter getChapter(@UriParam("chapterid")int chapterid) {
         System.out.println("----invoking getChapter with chapterid: " + chapterid);
 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Fri Feb 22 12:52:08 2008
@@ -24,10 +24,13 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.ws.rs.core.Response;
 import javax.xml.transform.dom.DOMSource;
 
@@ -35,7 +38,7 @@
 import org.apache.cxf.customer.book.BookNotFoundFault;
 import org.apache.cxf.helpers.XMLUtils;
 
-@UriTemplate("/bookstore/")
+@Path("/bookstore/")
 public class BookStore {
 
     private Map<Long, Book> books = new HashMap<Long, Book>();
@@ -48,9 +51,20 @@
         System.out.println("----books: " + books.size());
     }
 
-    @HttpMethod("GET")
-    @UriTemplate("/books/{bookId}/")
+    @GET
+    @Path("/books/{bookId}/")
     public Book getBook(@UriParam("bookId") String id) throws BookNotFoundFault {
+        return doGetBook(id);
+    }
+    
+    @GET
+    @Path("/books/{bookId}/")
+    @ProduceMime("application/json")
+    public Book getBookAsJSON(@UriParam("bookId") String id) throws BookNotFoundFault {
+        return doGetBook(id);
+    }
+    
+    private Book doGetBook(String id) throws BookNotFoundFault {
         System.out.println("----invoking getBook with id: " + id);
         Book book = books.get(Long.parseLong(id));
         if (book != null) {
@@ -62,7 +76,7 @@
         }
     }
     
-    @UriTemplate("/booksubresource/{bookId}/")
+    @Path("/booksubresource/{bookId}/")
     public Book getBookSubResource(@UriParam("bookId") String id) throws BookNotFoundFault {
         System.out.println("----invoking getBookSubResource with id: " + id);
         Book book = books.get(Long.parseLong(id));
@@ -75,8 +89,8 @@
         }
     }
     
-    @HttpMethod("GET")
-    @UriTemplate("/booknames/{bookId}/")
+    @GET
+    @Path("/booknames/{bookId}/")
     @ProduceMime("text/*")
     public String getBookName(@UriParam("bookId") int id) throws BookNotFoundFault {
         System.out.println("----invoking getBookName with id: " + id);
@@ -90,19 +104,19 @@
         }
     }
 
-    @HttpMethod("POST")
-    @UriTemplate("/books")
+    @POST
+    @Path("/books")
     @ProduceMime("text/xml")
     public Response addBook(Book book) {
         System.out.println("----invoking addBook, book name is: " + book.getName());
         book.setId(++bookId);
         books.put(book.getId(), book);
 
-        return Response.Builder.ok(book).build();
+        return Response.ok(book).build();
     }
 
-    @HttpMethod("PUT")
-    @UriTemplate("/books/")
+    @PUT
+    @Path("/books/")
     public Response updateBook(Book book) {
         System.out.println("----invoking updateBook, book name is: " + book.getName());
         Book b = books.get(book.getId());
@@ -110,24 +124,24 @@
         Response r;
         if (b != null) {
             books.put(book.getId(), book);
-            r = Response.Builder.ok().build();
+            r = Response.ok().build();
         } else {
-            r = Response.Builder.notModified().build();
+            r = Response.notModified().build();
         }
 
         return r;
     }
     
-    @HttpMethod("PUT")
-    @UriTemplate("/bookswithdom/")
+    @PUT
+    @Path("/bookswithdom/")
     public DOMSource updateBook(DOMSource ds) {
         System.out.println("----invoking updateBook with DOMSource");
         XMLUtils.printDOM(ds.getNode());
         return ds;
     }
     
-    @HttpMethod("PUT")
-    @UriTemplate("/bookswithjson/")
+    @PUT
+    @Path("/bookswithjson/")
     public Response updateBookJSON(Book book) {
         System.out.println("----invoking updateBook, book name is: " + book.getName());
         Book b = books.get(book.getId());
@@ -135,32 +149,32 @@
         Response r;
         if (b != null) {
             books.put(book.getId(), book);
-            r = Response.Builder.ok().build();
+            r = Response.ok().build();
         } else {
-            r = Response.Builder.notModified().build();
+            r = Response.notModified().build();
         }
 
         return r;
     }
 
-    @HttpMethod("DELETE")
-    @UriTemplate("/books/{bookId}/")
+    @DELETE
+    @Path("/books/{bookId}/")
     public Response deleteBook(@UriParam("bookId") String id) {
         System.out.println("----invoking deleteBook with bookId: " + id);
         Book b = books.get(Long.parseLong(id));
 
         Response r;
         if (b != null) {
-            r = Response.Builder.ok().build();
+            r = Response.ok().build();
         } else {
-            r = Response.Builder.notModified().build();
+            r = Response.notModified().build();
         }
 
         return r;
     }
 
-    @HttpMethod("GET")
-    @UriTemplate("/cd/{CDId}/")
+    @GET
+    @Path("/cd/{CDId}/")
     public CD getCD(@UriParam("CDId") String id) {
         System.out.println("----invoking getCD with cdId: " + id);
         CD cd = cds.get(Long.parseLong(id));
@@ -168,8 +182,8 @@
         return cd;
     }
 
-    @HttpMethod("GET")
-    @UriTemplate("/cdwithmultitypes/{CDId}/")
+    @GET
+    @Path("/cdwithmultitypes/{CDId}/")
     @ProduceMime({"application/xml", "application/json" }) 
     public CD getCDWithMultiContentTypes(@UriParam("CDId") String id) {
         System.out.println("----invoking getCDWithMultiContentTypes with cdId: " + id);
@@ -178,8 +192,8 @@
         return cd;
     }
     
-    @HttpMethod("GET")
-    @UriTemplate("/cds/")
+    @GET
+    @Path("/cds/")
     public CDs getCDs() {
         System.out.println("----invoking getCDs");
         CDs c = new CDs();

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Fri Feb 22 12:52:08 2008
@@ -56,7 +56,17 @@
         InputStream expected = getClass()
             .getResourceAsStream("resources/expected_get_book123.txt");
 
-        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in)); 
+        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
+        
+        connect = url.openConnection();
+        connect.addRequestProperty("Accept", "application/xml,application/json");
+        in = connect.getInputStream();
+        assertNotNull(in);           
+
+        expected = getClass()
+            .getResourceAsStream("resources/expected_get_book123json.txt");
+
+        assertEquals(getStringFromInputStream(expected), getStringFromInputStream(in));
     }
     
     @Test

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java Fri Feb 22 12:52:08 2008
@@ -33,7 +33,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly",
-                   launchServer(BookServerResourceCreatedSpringProviders.class, true));
+                   launchServer(BookServerResourceCreatedSpringProviders.class));
     }
     
     @Test

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java Fri Feb 22 12:52:08 2008
@@ -21,6 +21,7 @@
 
 import java.io.InputStream;
 import java.net.URL;
+import java.net.URLConnection;
 
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CachedOutputStream;
@@ -40,8 +41,9 @@
         String endpointAddress =
             "http://localhost:9080/bookstore/books/123"; 
         URL url = new URL(endpointAddress);
-        InputStream in = url.openStream();
-        assertNotNull(in);           
+        URLConnection connect = url.openConnection();
+        connect.addRequestProperty("Accept", "application/json");
+        InputStream in = connect.getInputStream();           
 
         InputStream expected = getClass()
             .getResourceAsStream("resources/expected_get_book123json.txt");

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/PetStore.java Fri Feb 22 12:52:08 2008
@@ -21,14 +21,14 @@
 package org.apache.cxf.systest.jaxrs;
 
 
-import javax.ws.rs.HttpMethod;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
 import javax.ws.rs.ProduceMime;
 import javax.ws.rs.UriParam;
-import javax.ws.rs.UriTemplate;
 import javax.ws.rs.core.Response;
 
 
-@UriTemplate("/petstore/")
+@Path("/petstore/")
 public class PetStore {
 
     public static final  String CLOSED = "The Pet Store is closed"; 
@@ -37,13 +37,13 @@
         System.out.println("Petstore constructed");
     }
 
-    @HttpMethod("GET")
-    @UriTemplate("/pets/{petId}/")
+    @GET
+    @Path("/pets/{petId}/")
     @ProduceMime("text/xml")
     public Response getStatus(@UriParam("petId") String petId) throws Exception {
         System.out.println("----invoking getStatus on the petStore for id: " + petId);
         
-        return Response.Builder.ok(CLOSED).build();
+        return Response.ok(CLOSED).build();
     }
 }
 

Modified: incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java?rev=630316&r1=630315&r2=630316&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java (original)
+++ incubator/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/customization/CustomizationParser.java Fri Feb 22 12:52:08 2008
@@ -256,19 +256,6 @@
             if (targetNode != wsdlNode) {
                 nodeSelector.addNamespaces(targetNode);
             }
-            /*
-            String pfx = nodeSelector.getNamespaceContext().getPrefix(targetNode.getNamespaceURI());
-            int count = 0;
-            while (StringUtils.isEmpty(pfx)) {
-                pfx = "wsdl" + (count == 0 ? "" : count);
-                if (nodeSelector.getNamespaceContext().getNamespaceURI(pfx) != null) {
-                    count++;
-                }
-            }
-            pfx += ":";
-            Node node = nodeSelector.queryNode(targetNode, "//" + pfx + "definitions");
-            */
-
             
             copyBindingsToWsdl(targetNode, bindings, nodeSelector.getNamespaceContext());
         }



Mime
View raw message