cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r724440 - in /cxf/branches/2.1.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/...
Date Mon, 08 Dec 2008 18:36:43 GMT
Author: sergeyb
Date: Mon Dec  8 10:36:41 2008
New Revision: 724440

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

........
  r722117 | sergeyb | 2008-12-01 16:36:47 +0000 (Mon, 01 Dec 2008) | 1 line
  
  JAXRS : support for custom provider media types plus few other minor changes
........

Added:
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
      - copied unchanged from r722117, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Dec  8 10:36:41 2008
@@ -1 +1 @@
-/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327,719354-719680,720053,720119,720218,720238,720293-720316,720497,721221,721241,721501,722129,723024,723338,723716,723778,723791,724333,724372
+/cxf/trunk:686333-686363,686764,686820,687096,687194,687363,687387,687463,687543,687722,687798,687814,687817,687891,687910,687914,688086,688102,688133,688596,688735,688870,689572,689596,689855,689924,690067,690289,691246,691271,691295,691338,691355,691488,691602,691646,691706,691728,692116,692157,692310,692466,692499,693653,693819,694179,694263,694417,694716,694744,694747,694795,694869,694981,694987,694993,695041,695096,695396,695484,695537,695552,695561,695619,695684,695835,695840,695868,695935,695977,696016,696094,696433,696720,697085,697868,698128,699289,700261,700507,700602,700981,701316,701783,701830,701862,702187,702205-702248,702267,702547,702561,702580,702602,702609,702616,702653,702656,702957,703191,703239,703309,703501,703513,703548,704584,704937,704997,705150,705235,705274,705340,705446,705548,705614,705692,705708,706482,706631,706675,706900,706909,707034,707089,707100,707902,708035,708044,708074,708410,708417,708550,708554,709353-709354,709425,710076,710150,71015
 4,711193,711388,711410,711490,711635,711949,711975,712194,712198,712238,712272,712299,712312,712670,712893,713082,713095-713096,713099,713584,713597,713737,713804,713899,714167-714168,714245,714255,717937-717961,718281-718448,718565,718620,718640,718665,718970,719017,719210,719215-719218,719222-719273,719305,719327,719354-719680,720053,720119,720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,723024,723338,723716,723778,723791,724333,724372

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

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PathSegmentImpl.java Mon Dec  8 10:36:41 2008
@@ -46,5 +46,9 @@
         int index = path.indexOf(';');
         return index != -1 ? path.substring(0, index) : path;
     }
+    
+    public String getOriginalPath() {
+        return path;
+    }
 
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java Mon Dec  8 10:36:41 2008
@@ -77,6 +77,13 @@
     }
     
     private static String updatePath(String path, String address) {
+        if (address.startsWith("http")) {
+            int idx = address.indexOf('/', 7);
+            if (idx != -1) {
+                address = address.substring(idx);
+            }
+        }
+        
         if (path.startsWith(address)) {
             path = path.substring(address.length());
             if (!path.startsWith("/")) {
@@ -94,7 +101,6 @@
             return;
         }
         
-        String path = (String)message.get(Message.REQUEST_URI);
         
         RequestPreprocessor rp = 
             ProviderFactory.getInstance(baseAddress).getRequestPreprocessor();
@@ -108,8 +114,9 @@
         if (requestContentType == null) {
             requestContentType = "*/*";
         }
-        
-        path = updatePath(path, baseAddress);
+
+        String rawPath = (String)message.get(Message.REQUEST_URI);        
+        rawPath = updatePath(rawPath, baseAddress);
         
         //1. Matching target resource class
         Service service = message.getExchange().get(Service.class);
@@ -124,12 +131,14 @@
         message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
 
         MultivaluedMap<String, String> values = new MetadataMap<String, String>();
-        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, path, values);
+        ClassResourceInfo resource = JAXRSUtils.selectResourceClass(resources, 
+                                          rawPath, 
+                                          values);
         if (resource == null) {
             org.apache.cxf.common.i18n.Message errorMsg = 
                 new org.apache.cxf.common.i18n.Message("NO_ROOT_EXC", 
                                                    BUNDLE, 
-                                                   path);
+                                                   rawPath);
             LOG.severe(errorMsg.toString());
 
             throw new WebApplicationException(404);
@@ -150,7 +159,9 @@
                 
                 if (ori != null) {
                     values = new MetadataMap<String, String>();
-                    resource = JAXRSUtils.selectResourceClass(resources, path, values);
+                    resource = JAXRSUtils.selectResourceClass(resources, 
+                                                              rawPath, 
+                                                              values);
                 }
                 ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), 
                                                   httpMethod, values, requestContentType, acceptContentTypes);
@@ -170,7 +181,9 @@
             message.getExchange().put(Message.ACCEPT_CONTENT_TYPE, acceptContentTypes);
             if (ori != null) {
                 values = new MetadataMap<String, String>();
-                resource = JAXRSUtils.selectResourceClass(resources, path, values);
+                resource = JAXRSUtils.selectResourceClass(resources, 
+                                                          rawPath, 
+                                                          values);
             }
             ori = JAXRSUtils.findTargetMethod(resource, values.getFirst(URITemplate.FINAL_MATCH_GROUP), 
                                               httpMethod, values, requestContentType, acceptContentTypes);
@@ -178,7 +191,7 @@
         }
 
         
-        LOG.fine("Request path is: " + path);
+        LOG.fine("Request path is: " + rawPath);
         LOG.fine("Request HTTP method is: " + httpMethod);
         LOG.fine("Request contentType is: " + requestContentType);
         LOG.fine("Accept contentType is: " + acceptTypes);
@@ -187,7 +200,7 @@
             org.apache.cxf.common.i18n.Message errorMsg = 
                 new org.apache.cxf.common.i18n.Message("NO_OP_EXC", 
                                                    BUNDLE, 
-                                                   path,
+                                                   rawPath,
                                                    requestContentType,
                                                    acceptTypes);
             LOG.severe(errorMsg.toString());

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java Mon Dec  8 10:36:41 2008
@@ -198,7 +198,7 @@
         List<MediaType> acceptContentTypes = 
             (List<MediaType>)exchange.get(Message.ACCEPT_CONTENT_TYPE);
         if (acceptContentTypes == null) {
-            acceptContentTypes = JAXRSUtils.sortMediaTypes("*/*");
+            acceptContentTypes = Collections.singletonList(MediaType.valueOf("*/*"));
         }        
         return JAXRSUtils.intersectMimeTypes(acceptContentTypes, produceTypes);
         

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfoComparator.java Mon Dec  8 10:36:41 2008
@@ -20,9 +20,6 @@
 package org.apache.cxf.jaxrs.model;
 
 import java.util.Comparator;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
 
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 
@@ -51,17 +48,14 @@
             return g1 < g2 ? 1 : -1;
         }
         
-        List<MediaType> mimeType1 = e1.getConsumeTypes();
-        List<MediaType> mimeType2 = e2.getConsumeTypes();
         
-        int result = JAXRSUtils.compareMediaTypes(mimeType1.get(0), 
-                                                  mimeType2.get(0));
+        int result = JAXRSUtils.compareSortedMediaTypes(
+                          e1.getConsumeTypes(), 
+                          e2.getConsumeTypes());
         if (result == 0) {
             //use the media type of output data as the secondary key.
-            List<MediaType> mimeTypeP1 = e1.getProduceTypes();
-            List<MediaType> mimeTypeP2 = e2.getProduceTypes();
-            result =  JAXRSUtils.compareMediaTypes(mimeTypeP1.get(0), 
-                                                mimeTypeP2.get(0));
+            result = JAXRSUtils.compareSortedMediaTypes(e1.getProduceTypes(), 
+                                                        e2.getProduceTypes());
         }
         
         return result;

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java Mon Dec  8 10:36:41 2008
@@ -28,6 +28,10 @@
 
 import javax.ws.rs.Path;
 import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
+
+import org.apache.cxf.jaxrs.utils.HttpUtils;
+import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 
 public final class URITemplate {
     
@@ -133,7 +137,29 @@
 
         Matcher m = templateRegexPattern.matcher(uri);
         if (!m.matches()) {
-            return false;
+            if (uri.contains(";")) {
+                // we might be trying to match one or few path segments containing matrix
+                // parameters against a clear path segment as in @Path("base").
+                List<PathSegment> pList = JAXRSUtils.getPathSegments(template, false);
+                List<PathSegment> uList = JAXRSUtils.getPathSegments(uri, false);
+                StringBuilder sb = new StringBuilder();
+                for (int i = 0; i < uList.size(); i++) {
+                    sb.append('/');
+                    if (pList.size() > i && pList.get(i).getPath().indexOf('{') != -1) {
+                        // if it's URI template variable then keep the original value
+                        sb.append(HttpUtils.fromPathSegment(uList.get(i)));
+                    } else {
+                        sb.append(uList.get(i).getPath());
+                    }
+                }
+                uri = sb.toString();
+                m = templateRegexPattern.matcher(uri);
+                if (!m.matches()) {
+                    return false;
+                }
+            } else {
+                return false;
+            }
         }
 
         // Assign the matched template values to template variables

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java Mon Dec  8 10:36:41 2008
@@ -51,7 +51,7 @@
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
 
-public abstract class AbstractJAXBProvider 
+public abstract class AbstractJAXBProvider extends AbstractConfigurableProvider
     implements MessageBodyReader<Object>, MessageBodyWriter<Object> {
     
     protected static final ResourceBundle BUNDLE = BundleUtils.getBundle(AbstractJAXBProvider.class);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/FormEncodingReaderProvider.java Mon Dec  8 10:36:41 2008
@@ -38,7 +38,7 @@
 
 @ConsumeMime("application/x-www-form-urlencoded")
 @Provider
-public final class FormEncodingReaderProvider implements MessageBodyReader<Object> {
+public class FormEncodingReaderProvider implements MessageBodyReader<Object> {
 
     private FormValidator validator;
     

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JAXBElementProvider.java Mon Dec  8 10:36:41 2008
@@ -49,6 +49,14 @@
     
     private Map<String, Object> mProperties = new HashMap<String, Object>();
     
+    public void setConsumeMediaTypes(List<String> types) {
+        super.setConsumeMediaTypes(types);
+    }
+    
+    public void setProduceMediaTypes(List<String> types) {
+        super.setProduceMediaTypes(types);
+    }
+    
     public void setSchemas(List<String> locations) {
         super.setSchemaLocations(locations);
     }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/JSONProvider.java Mon Dec  8 10:36:41 2008
@@ -54,7 +54,7 @@
 @ProduceMime("application/json")
 @ConsumeMime("application/json")
 @Provider
-public final class JSONProvider extends AbstractJAXBProvider  {
+public class JSONProvider extends AbstractJAXBProvider  {
     
     private static final String JAXB_DEFAULT_NAMESPACE = "##default";
     private static final String JAXB_DEFAULT_NAME = "##default";
@@ -63,6 +63,14 @@
     private boolean serializeAsArray;
     private List<String> arrayKeys;
     
+    public void setConsumeMediaTypes(List<String> types) {
+        super.setConsumeMediaTypes(types);
+    }
+    
+    public void setProduceMediaTypes(List<String> types) {
+        super.setProduceMediaTypes(types);
+    }
+    
     public void setSchemas(List<String> locations) {
         super.setSchemaLocations(locations);
     }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ProviderFactory.java Mon Dec  8 10:36:41 2008
@@ -30,8 +30,6 @@
 import java.util.List;
 import java.util.Map;
 
-import javax.ws.rs.ConsumeMime;
-import javax.ws.rs.ProduceMime;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.ExceptionMapper;
@@ -52,10 +50,8 @@
     
     private static final Map<String, ProviderFactory> FACTORIES = 
         new HashMap<String, ProviderFactory>();
-    
-    static {
-        FACTORIES.put("/", new ProviderFactory());
-    }
+    private static final ProviderFactory DEFAULT_FACTORY = new ProviderFactory(); 
+    private static final String SLASH = "/"; 
     
     private List<ProviderInfo<MessageBodyReader>> defaultMessageReaders = 
         new ArrayList<ProviderInfo<MessageBodyReader>>();
@@ -80,6 +76,10 @@
     private ProviderFactory() {
         // TODO : this needs to be done differently,
         // we need to use cxf-jaxrs-extensions
+        
+        // TODO : make sure the default providers are shared between multiple
+        // factories
+        
         setProviders(defaultMessageReaders,
                      defaultMessageWriters,
                      userContextResolvers,
@@ -102,6 +102,10 @@
     }
     
     public static ProviderFactory getInstance(String baseAddress) {
+        if (SLASH.equals(baseAddress)) {
+            return DEFAULT_FACTORY;
+        }
+        
         ProviderFactory pf = null;
         synchronized (ProviderFactory.class) { 
             pf = FACTORIES.get(baseAddress);
@@ -341,8 +345,7 @@
             return false;
         }
         
-        List<MediaType> supportedMediaTypes =
-            JAXRSUtils.getConsumeTypes(ep.getClass().getAnnotation(ConsumeMime.class));
+        List<MediaType> supportedMediaTypes = JAXRSUtils.getProviderConsumeTypes(ep);
         
         List<MediaType> availableMimeTypes = 
             JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
@@ -391,8 +394,7 @@
             return false;
         }
         
-        List<MediaType> supportedMediaTypes =
-            JAXRSUtils.getProduceTypes(ep.getClass().getAnnotation(ProduceMime.class));
+        List<MediaType> supportedMediaTypes = JAXRSUtils.getProviderProduceTypes(ep);
         
         List<MediaType> availableMimeTypes = 
             JAXRSUtils.intersectMimeTypes(Collections.singletonList(mediaType),
@@ -402,25 +404,6 @@
         
     }
     
-    public boolean deregisterEntityProvide(Object o) {
-        
-        if (o instanceof MessageBodyReader) {
-            return userMessageReaders.remove(o);
-        }
-        if (o instanceof MessageBodyWriter) {
-            return userMessageWriters.remove(o);
-        }
-        if (o instanceof ContextResolver) {
-            return userContextResolvers.remove(o);
-        }
-        if (o instanceof RequestHandler) {
-            return requestHandlers.remove(o);
-        }
-        
-        return false;
-                                               
-    }
-    
     List<ProviderInfo<MessageBodyReader>> getDefaultMessageReaders() {
         return Collections.unmodifiableList(defaultMessageReaders);
     }
@@ -466,31 +449,13 @@
                            ProviderInfo<MessageBodyReader> p2) {
             MessageBodyReader e1 = p1.getProvider();
             MessageBodyReader e2 = p2.getProvider();
-            
-            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();               
-            }
+            List<MediaType> types1 = JAXRSUtils.getProviderConsumeTypes(e1);
+            types1 = JAXRSUtils.sortMediaTypes(types1);
+            List<MediaType> types2 = JAXRSUtils.getProviderConsumeTypes(e2);
+            types2 = JAXRSUtils.sortMediaTypes(types2);
     
-            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 JAXRSUtils.compareSortedMediaTypes(types1, types2);
             
-            return str1.compareTo(str2);
         }
     }
     
@@ -502,30 +467,13 @@
             MessageBodyWriter e1 = p1.getProvider();
             MessageBodyWriter e2 = p2.getProvider();
             
-            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();               
-            }
+            List<MediaType> types1 =
+                JAXRSUtils.sortMediaTypes(JAXRSUtils.getProviderProduceTypes(e1));
+            List<MediaType> types2 =
+                JAXRSUtils.sortMediaTypes(JAXRSUtils.getProviderProduceTypes(e2));
     
-            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 JAXRSUtils.compareSortedMediaTypes(types1, types2);
             
-            return str1.compareTo(str2);
         }
     }
     

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/StringProvider.java Mon Dec  8 10:36:41 2008
@@ -35,7 +35,7 @@
 import org.apache.cxf.helpers.IOUtils;
 
 @Provider
-public final class StringProvider 
+public class StringProvider 
     implements MessageBodyWriter<String>, MessageBodyReader<String>  {
 
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/XMLBeansJSONProvider.java Mon Dec  8 10:36:41 2008
@@ -50,7 +50,7 @@
 @ProduceMime("application/json")
 @ConsumeMime("application/json")
 @Provider
-public final class XMLBeansJSONProvider extends XMLBeansElementProvider {
+public class XMLBeansJSONProvider extends XMLBeansElementProvider {
 
     /** {@inheritDoc} */
     @Override

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/HttpUtils.java Mon Dec  8 10:36:41 2008
@@ -20,14 +20,17 @@
 package org.apache.cxf.jaxrs.utils;
 
 import java.net.URI;
+import java.util.List;
+import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.PathSegment;
 
+import org.apache.cxf.jaxrs.impl.PathSegmentImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 
 public final class HttpUtils {
-    
     private static final String LOCAL_IP_ADDRESS = "127.0.0.1";
     private static final String LOCAL_HOST = "localhost";
     
@@ -51,4 +54,23 @@
         }
         return u;
     }
+    
+    
+    public static String fromPathSegment(PathSegment ps) {
+        if (PathSegmentImpl.class.isAssignableFrom(ps.getClass())) {
+            return ((PathSegmentImpl)ps).getOriginalPath();
+        }
+        StringBuilder sb = new StringBuilder();
+        sb.append(ps.getPath());
+        for (Map.Entry<String, List<String>> entry : ps.getMatrixParameters().entrySet()) {
+            for (String value : entry.getValue()) {
+                sb.append(';').append(entry.getKey());
+                if (value != null) {
+                    sb.append('=').append(value);
+                }
+            }
+        }
+        return sb.toString();
+    }
+    
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/InjectionUtils.java Mon Dec  8 10:36:41 2008
@@ -142,6 +142,10 @@
     
     public static Object handleParameter(String value, Class<?> pClass, boolean pathParam) {
         
+        if (value == null) {
+            return null;
+        }
+        
         if (pathParam) {
             PathSegment ps = new PathSegmentImpl(value, false);    
             if (PathSegment.class.isAssignableFrom(pClass)) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/JAXRSUtils.java Mon Dec  8 10:36:41 2008
@@ -67,6 +67,7 @@
 import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWorkers;
+import javax.ws.rs.ext.MessageBodyWriter;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
@@ -80,11 +81,11 @@
 import org.apache.cxf.jaxrs.impl.RequestImpl;
 import org.apache.cxf.jaxrs.impl.SecurityContextImpl;
 import org.apache.cxf.jaxrs.impl.UriInfoImpl;
-import org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfoComparator;
 import org.apache.cxf.jaxrs.model.URITemplate;
+import org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
@@ -107,9 +108,52 @@
                 theList.add(new PathSegmentImpl(path, decode));
             }
         }
+        int len = thePath.length();
+        if (len > 1 && thePath.charAt(len - 1) == '/') {
+            theList.add(new PathSegmentImpl("", false));
+        }
         return theList;
     }
 
+    @SuppressWarnings("unchecked")
+    private static String[] getUserMediaTypes(Object provider, String methodName) {
+        String[] values = null;
+        if (AbstractConfigurableProvider.class.isAssignableFrom(provider.getClass())) {
+            try {
+                Method m = provider.getClass().getMethod(methodName, new Class[]{});
+                List<String> types = (List<String>)m.invoke(provider, new Object[]{});
+                if (types != null) {
+                    values =  types.size() > 0 ? types.toArray(new String[]{})
+                                               : new String[]{"*/*"};
+                }
+            } catch (Exception ex) {
+                System.out.println();
+            }
+        }
+        return values;
+    }
+    
+    @SuppressWarnings("unchecked")
+    public static List<MediaType> getProviderConsumeTypes(MessageBodyReader provider) {
+        String[] values = getUserMediaTypes(provider, "getConsumeMediaTypes");
+        
+        if (values == null) {
+            ConsumeMime c = provider.getClass().getAnnotation(ConsumeMime.class);
+            values = c == null ? new String[]{"*/*"} : c.value();
+        }
+        return JAXRSUtils.getMediaTypes(values);
+    }
+    
+    public static List<MediaType> getProviderProduceTypes(MessageBodyWriter provider) {
+        String[] values = getUserMediaTypes(provider, "getProduceMediaTypes");
+        
+        if (values == null) {
+            ProduceMime c = provider.getClass().getAnnotation(ProduceMime.class);
+            values = c == null ? new String[]{"*/*"} : c.value();
+        }
+        return JAXRSUtils.getMediaTypes(values);
+    }
+    
     public static List<MediaType> getMediaTypes(String[] values) {
         List<MediaType> supportedMimeTypes = new ArrayList<MediaType>(values.length);
         for (int i = 0; i < values.length; i++) {
@@ -136,7 +180,6 @@
         ClassResourceInfo cri = ori.getClassResourceInfo();
         InjectionUtils.injectContextMethods(requestObject, cri, message);
         // Param methods
-        String relativePath = (String)message.get(JAXRSInInterceptor.RELATIVE_PATH);
         MultivaluedMap<String, String> values = 
             (MultivaluedMap<String, String>)message.get(URITemplate.TEMPLATE_PARAMETERS);
         for (Method m : cri.getParameterMethods()) {
@@ -145,7 +188,6 @@
                                                 m.getGenericParameterTypes()[0],
                                                 message,
                                                 values,
-                                                relativePath,
                                                 ori);
             if (o != null) { 
                 InjectionUtils.injectThroughMethod(requestObject, m, o);
@@ -158,7 +200,6 @@
                                                 f.getGenericType(),
                                                 message,
                                                 values,
-                                                relativePath,
                                                 ori);
             if (o != null) { 
                 InjectionUtils.injectFieldValue(f, requestObject, o);
@@ -268,6 +309,18 @@
                           : getMediaTypes(pm.value());
     }
     
+    public static int compareSortedMediaTypes(List<MediaType> mts1, List<MediaType> mts2) {
+        int size1 = mts1.size();
+        int size2 = mts2.size();
+        for (int i = 0; i < size1 && i < size2; i++) {
+            int result = compareMediaTypes(mts1.get(i), mts2.get(i));
+            if (result != 0) {
+                return result;
+            }
+        }
+        return size1 == size2 ? 0 : size1 < size2 ? -1 : 1;
+    }
+    
     public static int compareMediaTypes(MediaType mt1, MediaType mt2) {
         
         if (mt1.equals(mt2)) {
@@ -345,8 +398,6 @@
                                            OperationResourceInfo ori) {
         InputStream is = message.getContent(InputStream.class);
 
-        String path = (String)message.get(JAXRSInInterceptor.RELATIVE_PATH);
-        
         if (parameterAnns == null 
             || !AnnotationUtils.isMethodParamAnnotations(parameterAnns)) {
             
@@ -373,7 +424,6 @@
                                             parameterType,
                                             message,
                                             values,
-                                            path,
                                             ori);
         }
     }
@@ -383,7 +433,6 @@
                                             Type genericParam,
                                             Message message,
                                             MultivaluedMap<String, String> values,
-                                            String path,
                                             OperationResourceInfo ori) {
        
         boolean isEncoded = AnnotationUtils.isEncoded(anns, ori);
@@ -393,8 +442,8 @@
         
         PathParam pathParam = AnnotationUtils.getAnnotation(anns, PathParam.class);
         if (pathParam != null) {
-            result = readFromUriParam(pathParam, parameterClass, genericParam, path, 
-                                    values, defaultValue, !isEncoded);
+            result = readFromUriParam(message, pathParam, parameterClass, genericParam, 
+                                      values, defaultValue, !isEncoded);
         } 
         
         QueryParam qp = AnnotationUtils.getAnnotation(anns, QueryParam.class);
@@ -558,13 +607,14 @@
         return null;
     }
 
-    private static Object readFromUriParam(PathParam uriParamAnnotation,
+    private static Object readFromUriParam(Message m,
+                                           PathParam uriParamAnnotation,
                                            Class<?> paramType,
                                            Type genericType,
-                                           String path,
                                            MultivaluedMap<String, String> values,
                                            String defaultValue,
                                            boolean  decoded) {
+        
         String parameterName = uriParamAnnotation.value();
         if ("".equals(parameterName)) {
             return InjectionUtils.handleBean(paramType, values, true);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/URITemplateTest.java Mon Dec  8 10:36:41 2008
@@ -46,6 +46,53 @@
     }
     
     @Test
+    public void testMatchWithMatrixAndTemplate() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/customers/{id}",
+                                                  false);
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        boolean match = uriTemplate.match("/customers/123;123456/", values);
+        assertTrue(match);
+        String value = values.getFirst("id");
+        assertEquals("123;123456", value);
+    }
+    
+    @Test
+    public void testMatchWithMatrixOnClearPath1() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/customers/{id}",
+                                                  false);
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        boolean match = uriTemplate.match("/customers;123456/123/", values);
+        assertTrue(match);
+        String value = values.getFirst("id");
+        assertEquals("123", value);
+    }
+    
+    @Test
+    public void testMatchWithMatrixOnClearPath2() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/customers/{id}/orders/{order}",
+                                                  false);
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        assertTrue(uriTemplate.match("/customers;123456/123/orders;456/3", values));
+        assertEquals("123", values.getFirst("id"));
+        assertEquals("3", values.getFirst("order"));
+    }
+    
+    @Test
+    public void testMatchWithMatrixOnClearPath3() throws Exception {
+        URITemplate uriTemplate = new URITemplate("/{id}/customers/",
+                                                  false);
+        MultivaluedMap<String, String> values = new MetadataMap<String, String>();
+        
+        boolean match = uriTemplate.match("/123/customers;123456/", values);
+        assertTrue(match);
+        String value = values.getFirst("id");
+        assertEquals("123", value);
+    }
+    
+    @Test
     public void testMatchBasicTwoParametersVariation1() throws Exception {
         URITemplate uriTemplate = new URITemplate("/customers/{name}/{department}",
                                                   false);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryTest.java Mon Dec  8 10:36:41 2008
@@ -27,6 +27,7 @@
 import java.lang.reflect.Type;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import javax.ws.rs.ConsumeMime;
@@ -105,6 +106,28 @@
     }
     
     @Test
+    public void testSortEntityProvidersWithConfig() throws Exception {
+        ProviderFactory pf = ProviderFactory.getInstance();
+        JSONProvider json1 = new JSONProvider();
+        pf.registerUserProvider(json1);
+        JSONProvider json2 = new JSONProvider();
+        json2.setConsumeMediaTypes(Collections.singletonList("application/abc"));
+        json2.setProduceMediaTypes(Collections.singletonList("application/sbc"));
+        pf.registerUserProvider(json2);
+        
+        List<ProviderInfo<MessageBodyReader>> readers = pf.getUserMessageReaders();
+
+        assertTrue(indexOf(readers, json2) 
+                   < indexOf(readers, json1));
+        
+        List<ProviderInfo<MessageBodyWriter>> writers = pf.getUserMessageWriters();
+
+        assertTrue(indexOf(writers, json1) 
+                   < indexOf(writers, json2));
+        
+    }
+    
+    @Test
     public void testGetStringProvider() throws Exception {
         verifyProvider(String.class, StringProvider.class, "text/html");
     }
@@ -207,6 +230,17 @@
         return index;
     }
     
+    private int indexOf(List<? extends Object> providerInfos, Object provider) {
+        int index = 0;
+        for (Object pi : providerInfos) {
+            if (((ProviderInfo)pi).getProvider() == provider) {
+                break;
+            }
+            index++;
+        }
+        return index;
+    }
+    
     @ConsumeMime("text/html")
     @ProduceMime("text/html")
     private final class TestStringProvider 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/JAXRSUtilsTest.java Mon Dec  8 10:36:41 2008
@@ -421,6 +421,40 @@
     }
     
     @Test
+    public void testCompareSortedMediaTypes() throws Exception {
+        MediaType m1 = MediaType.valueOf("text/xml");
+        MediaType m2 = MediaType.valueOf("text/*");
+        assertTrue("text/xml is more specific than text/*", 
+                   JAXRSUtils.compareSortedMediaTypes(Collections.singletonList(m1), 
+                                                      Collections.singletonList(m2)) < 0);
+        assertTrue("text/* is less specific than text/xml", 
+                   JAXRSUtils.compareSortedMediaTypes(Collections.singletonList(m2), 
+                                                      Collections.singletonList(m1)) > 0);
+        
+        assertTrue("text/xml is the same as text/xml", 
+                   JAXRSUtils.compareSortedMediaTypes(Collections.singletonList(m1), 
+                                                      Collections.singletonList(m1)) == 0);
+        
+        List<MediaType> sortedList1 = new ArrayList<MediaType>();
+        sortedList1.add(m1);
+        sortedList1.add(m2);
+                
+        List<MediaType> sortedList2 = new ArrayList<MediaType>();
+        sortedList2.add(m1);
+        sortedList2.add(m2);
+        
+        assertTrue("lists should be equal", 
+                   JAXRSUtils.compareSortedMediaTypes(sortedList1, sortedList2) == 0);
+        
+        sortedList1.add(MediaType.valueOf("*/*"));
+        assertTrue("first list should be less specific", 
+                   JAXRSUtils.compareSortedMediaTypes(sortedList1, sortedList2) > 0);
+        sortedList1.add(MediaType.valueOf("*/*"));
+        assertTrue("second list should be more specific", 
+                   JAXRSUtils.compareSortedMediaTypes(sortedList2, sortedList1) < 0);
+    }
+    
+    @Test
     public void testAcceptTypesMatch() throws Exception {
         
         Method m = Customer.class.getMethod("test", new Class[]{});

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java Mon Dec  8 10:36:41 2008
@@ -30,6 +30,7 @@
 import javax.ws.rs.DELETE;
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
+import javax.ws.rs.MatrixParam;
 import javax.ws.rs.POST;
 import javax.ws.rs.PUT;
 import javax.ws.rs.Path;
@@ -62,7 +63,6 @@
 
     public BookStore() {
         init();
-        System.out.println("----books: " + books.size());
     }
     
     @GET
@@ -108,6 +108,14 @@
     }
     
     @GET
+    @Path("/segment/matrix")
+    public Book getBookByMatrixParams(@MatrixParam("first") String s1,
+                                      @MatrixParam("second") String s2) throws Exception {
+        
+        return doGetBook(s1 + s2);
+    }
+    
+    @GET
     @Path("/bookquery")
     public Book getBookByURLQuery(@QueryParam("urlid") String urlValue) throws Exception {
         String url2 = new URL(urlValue).toString();
@@ -185,7 +193,6 @@
     
     @Path("/booksubresource/{bookId}/")
     public Book getBookSubResource(@PathParam("bookId") String id) throws BookNotFoundFault {
-        System.out.println("----invoking getBookSubResource with id: " + id);
         Book book = books.get(Long.parseLong(id));
         if (book != null) {
             return book;
@@ -200,7 +207,6 @@
     @Path("/booknames/{bookId}/")
     @ProduceMime("text/*")
     public String getBookName(@PathParam("bookId") int id) throws BookNotFoundFault {
-        System.out.println("----invoking getBookName with id: " + id);
         Book book = books.get(new Long(id));
         if (book != null) {
             return book.getName();
@@ -216,7 +222,6 @@
     @ProduceMime("text/xml")
     @ConsumeMime("application/xml")
     public Response addBook(Book book) {
-        System.out.println("----invoking addBook, book name is: " + book.getName());
         book.setId(++bookId);
         books.put(book.getId(), book);
 
@@ -234,7 +239,6 @@
     @PUT
     @Path("/books/")
     public Response updateBook(Book book) {
-        System.out.println("----invoking updateBook, book name is: " + book.getName());
         Book b = books.get(book.getId());
 
         Response r;
@@ -251,7 +255,6 @@
     @PUT
     @Path("/bookswithdom/")
     public DOMSource updateBook(DOMSource ds) {
-        System.out.println("----invoking updateBook with DOMSource");
         XMLUtils.printDOM(ds.getNode());
         return ds;
     }
@@ -260,7 +263,6 @@
     @Path("/bookswithjson/")
     @ConsumeMime("application/json")
     public Response updateBookJSON(Book book) {
-        System.out.println("----invoking updateBook, book name is: " + book.getName());
         Book b = books.get(book.getId());
 
         Response r;
@@ -277,7 +279,6 @@
     @DELETE
     @Path("/books/{bookId}/")
     public Response deleteBook(@PathParam("bookId") String id) {
-        System.out.println("----invoking deleteBook with bookId: " + id);
         Book b = books.get(Long.parseLong(id));
 
         Response r;
@@ -319,7 +320,6 @@
     @GET
     @Path("/cd/{CDId}/")
     public CD getCD() {
-        System.out.println("----invoking getCD with cdId: " + currentCdId);
         CD cd = cds.get(Long.parseLong(currentCdId));
 
         return cd;
@@ -329,7 +329,6 @@
     @Path("/cdwithmultitypes/{CDId}/")
     @ProduceMime({"application/xml", "application/json" }) 
     public CD getCDWithMultiContentTypes(@PathParam("CDId") String id) {
-        System.out.println("----invoking getCDWithMultiContentTypes with cdId: " + id);
         CD cd = cds.get(Long.parseLong(id));
 
         return cd;
@@ -338,7 +337,6 @@
     @GET
     @Path("/cds/")
     public CDs getCDs() {
-        System.out.println("----invoking getCDs");
         CDs c = new CDs();
         c.setCD(cds.values());
         return c;

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSpring.java Mon Dec  8 10:36:41 2008
@@ -56,6 +56,7 @@
     
     @GET
     @Path("/books/{id}")
+    @ProduceMime({"application/jettison", "application/json" })
     public Book getBookById(@PathParam("id") Long id) {
         return books.get(id);
     }
@@ -96,7 +97,7 @@
     @POST
     @Path("books/convert")
     @ProduceMime("application/xml")
-    @ConsumeMime({"application/xml", "application/json" })
+    @ConsumeMime({"application/xml", "application/json", "application/jettison" })
     public Book convertBook(Book2 book) {
         // how to have Book2 populated ?
         Book b = new Book();

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java Mon Dec  8 10:36:41 2008
@@ -212,7 +212,21 @@
         getAndCompareAsStrings("http://localhost:9080/bookstore/segment/matrix;first=12;second=3",
                                "resources/expected_get_book123.txt",
                                "application/xml", 200);
-        
+        getAndCompareAsStrings("http://localhost:9080/bookstore;bar/segment;foo/"
+                               + "matrix;first=12;second=3;third",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
+    }
+    
+    @Test
+    public void testGetBookByMatrixParameters() throws Exception {
+        getAndCompareAsStrings("http://localhost:9080/bookstore/segment/matrix;first=12;second=3",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
+        getAndCompareAsStrings("http://localhost:9080/bookstore;bar/segment;foo;"
+                               + "first=12;second=3/matrix;third",
+                               "resources/expected_get_book123.txt",
+                               "application/xml", 200);
     }
     
     @Test

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerSpringBookTest.java Mon Dec  8 10:36:41 2008
@@ -54,7 +54,9 @@
     public void testGetBook123() throws Exception {
         String endpointAddress =
             "http://localhost:9080/bookstore/books/123"; 
-        getBook(endpointAddress, "resources/expected_get_book123json.txt"); 
+        getBook(endpointAddress, "resources/expected_get_book123json.txt");
+        getBook(endpointAddress, "resources/expected_get_book123json.txt",
+                "application/jettison");
     }
     
     @Test
@@ -91,9 +93,13 @@
     }
 
     private void getBook(String endpointAddress, String resource) throws Exception {
+        getBook(endpointAddress, resource, "application/json");
+    }
+    
+    private void getBook(String endpointAddress, String resource, String type) throws Exception {
         URL url = new URL(endpointAddress);
         URLConnection connect = url.openConnection();
-        connect.addRequestProperty("Accept", "application/json");
+        connect.addRequestProperty("Accept", type);
         InputStream in = connect.getInputStream();           
 
         InputStream expected = getClass().getResourceAsStream(resource);
@@ -164,6 +170,12 @@
                "application/json",
                "resources/add_book2json.txt",
                "resources/expected_get_book123.txt");
+        
+        doPost("http://localhost:9080/thebooks/bookstore/books/convert",
+               200,
+               "application/jettison",
+               "resources/add_book2json.txt",
+               "resources/expected_get_book123.txt");
     }
     
     private void doPost(String endpointAddress, int expectedStatus, String contentType,

Modified: cxf/branches/2.1.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml?rev=724440&r1=724439&r2=724440&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/resources/jaxrs/WEB-INF/beans.xml Mon Dec  8 10:36:41 2008
@@ -79,6 +79,11 @@
     <value>classpath:/org/apache/cxf/systest/jaxrs/book.xsd</value>
   </util:list>
   
+  <util:list id="jsonTypes">
+    <value>application/json</value>
+    <value>application/jettison</value>
+  </util:list>
+  
   <util:map id="jsonNamespaceMap" map-class="java.util.Hashtable">
        <entry key="http://www.example.org/books" value="b"/>
   </util:map> 
@@ -93,6 +98,9 @@
 
       <property name="serializeAsArray" value="true"/> 
       <property name="arrayKeys" ref="jsonKeys"/>
+      
+      <property name="produceMediaTypes" ref="jsonTypes"/>
+      <property name="consumeMediaTypes" ref="jsonTypes"/>
   </bean>
 </beans>
 <!-- END SNIPPET: beans -->



Mime
View raw message