cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r756439 [1/2] - in /cxf/branches/2.1.x-fixes: ./ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/...
Date Fri, 20 Mar 2009 12:57:14 GMT
Author: sergeyb
Date: Fri Mar 20 12:57:13 2009
New Revision: 756439

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

........
  r752520 | sergeyb | 2009-03-11 16:54:20 +0000 (Wed, 11 Mar 2009) | 1 line
  
  JAXRS : getting rid of ProviderFactory singletons
........
  r752970 | sergeyb | 2009-03-12 18:53:27 +0000 (Thu, 12 Mar 2009) | 1 line
  
  JAXRS : encoding related fixes
........

Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java   (props changed)
    cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java   (props changed)
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/XMLSource.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.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/URITemplate.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/SourceProvider.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/client/WebClientTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.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/HttpUtilsTest.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/JAXRSClientServerBookTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 20 12:57:13 2009
@@ -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-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732773,732827,732829,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737237,737246,737299,737356,737494,737498,737761,737817,737849,737855,737994,738166,738178,738201,738210,738242,738244,738265,738516,738583,738863,738937,738983,739366-739367,739451-739452,739799-739800,739867,739876-739877,739922,739937,739990,740045,740108,740154,740186,740197,740255,740706,740730,740810,740844,740886,740902,740923,740994,741058,741124,741152,741188,741521,741529,741879,742914,743087,743439,743441,743459,743469,743825,743965,743967,744104-744138,744175,744195,744237,744756,745214,745243,745472,745474,745560,745578,745586,745592,745638,745950,746012,746019-746020,746256,746266,746306,746357,746373-746374,746947,747026,747070,747217,74
 7386,747390,747406-747407,747454,747649,747766,747806-747846,747986,748159,748192-748193,748223,748305,748313,748597,748603-748604,748768,749420,749449,749454-749456,749505,749511,749513,749584,749596,749767,749771,749799,749890,749963,750010,750059-750060,750302,750522,750591,750663,750689,750935,750948,751067-751110,751233,751527,751567,751576,751607,751732,751740,751787,751828,751840,751972-751974,752099,752122,752132,752136,752280,752435,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752992,753205,753293,753335,753338,753388,755153,755514,755806
+/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-719680,720053,720119-720218,720238,720293-720316,720497,721221,721241,721501,722117,722129,722412,722988,723024,723338,723378,723716-723791,724333-724372,724433-724438,724449,724481,724485,724668,724780,724782,724785,724793,724795,724940,725071,725316,725332,725335,725348,725364,725418,725425-725426,725455,725506,725554,725562,725651,725671,725688,725754,725773,725799,725839,726342,726524,726631,726634,726637,726639,726692,726724,726769,726992,727096,727445,727521,727568,727692,727754,727781,727792,728070,728087,728696,728897,729051,729430,729449,729460,729863,730082,730139,730889,730891,731598,731604,731615,731631,731635,732036,732050,732320,732363,732411,732450,
 732710,732773,732827,732829,733512,733582,733901,734367,734462,734666,734762,734772,734812,734836,734965,735113,735252,735722-735723,735729,735734,735751,735782,735787,735987,736332,736343,736352,736358-736362,736408,736423,736448,736491,736621,736726,736736,736738-736739,736766,736825,736852,737032,737046,737061,737069,737124,737237,737246,737299,737356,737494,737498,737761,737817,737849,737855,737994,738166,738178,738201,738210,738242,738244,738265,738516,738583,738863,738937,738983,739366-739367,739451-739452,739799-739800,739867,739876-739877,739922,739937,739990,740045,740108,740154,740186,740197,740255,740706,740730,740810,740844,740886,740902,740923,740994,741058,741124,741152,741188,741521,741529,741879,742914,743087,743439,743441,743459,743469,743825,743965,743967,744104-744138,744175,744195,744237,744756,745214,745243,745472,745474,745560,745578,745586,745592,745638,745950,746012,746019-746020,746256,746266,746306,746357,746373-746374,746947,747026,747070,747217,74
 7386,747390,747406-747407,747454,747649,747766,747806-747846,747986,748159,748192-748193,748223,748305,748313,748597,748603-748604,748768,749420,749449,749454-749456,749505,749511,749513,749584,749596,749767,749771,749799,749890,749963,750010,750059-750060,750302,750522,750591,750663,750689,750935,750948,751067-751110,751233,751527,751567,751576,751607,751732,751740,751787,751828,751840,751972-751974,752099,752122,752132,752136,752280,752435,752520,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752970,752992,753205,753293,753335,753338,753388,755153,755514,755806

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

Propchange: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 20 12:57:13 2009
@@ -1 +1 @@
-/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,752435,755514,755806
+/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/WrapperHelperCompiler.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,752435,752520,752970,755514,755806

Propchange: cxf/branches/2.1.x-fixes/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 20 12:57:13 2009
@@ -1 +1 @@
-/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,752435,755514,755806
+/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBWrapperHelperTest.java:743825,744104-744138,745472,745474,746947,747026,747070,747390,747407,747806-747846,748193,748597,749596,749963,750010,750522,750663,750948,752099,752280,752435,752520,752970,755514,755806

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/AbstractJAXRSFactoryBean.java Fri Mar 20 12:57:13 2009
@@ -36,6 +36,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingInfo;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -209,4 +210,16 @@
             throw new WebApplicationException(Response.Status.NOT_FOUND);
         }
     }
+    
+    protected ProviderFactory setupFactory(Endpoint ep) { 
+        ProviderFactory factory = ProviderFactory.getInstance(); 
+        if (entityProviders != null) {
+            factory.setUserProviders(entityProviders); 
+        }
+        if (schemaLocations != null) {
+            factory.setSchemaLocations(schemaLocations);
+        }
+        ep.put(ProviderFactory.class.getName(), factory);
+        return factory;
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java Fri Mar 20 12:57:13 2009
@@ -46,7 +46,6 @@
 import org.apache.cxf.jaxrs.model.OperationResourceInfoStack;
 import org.apache.cxf.jaxrs.model.URITemplate;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
-import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
@@ -106,8 +105,6 @@
                                             exchange.getInMessage());
         }
 
-        String baseAddress = HttpUtils.getOriginalAddress(exchange.getInMessage());
-
         List<Object> params = null;
         if (request instanceof List) {
             params = CastUtils.cast((List<?>)request);
@@ -125,10 +122,9 @@
             result = invoke(exchange, resourceObject, methodToInvoke, params);
         } catch (Fault ex) {
             Response excResponse = JAXRSUtils.convertFaultToResponse(ex.getCause(), 
-                                                                     baseAddress,
                                                                      exchange.getInMessage());
             if (excResponse == null) {
-                ProviderFactory.getInstance(baseAddress).clearThreadLocalProxies();
+                ProviderFactory.getInstance(exchange.getInMessage()).clearThreadLocalProxies();
                 ClassResourceInfo criRoot =
                     (ClassResourceInfo)exchange.get(JAXRSInInterceptor.ROOT_RESOURCE_CLASS);
                 if (criRoot != null) {
@@ -195,7 +191,6 @@
                 return this.invoke(exchange, newParams, newResourceObjects);
             } catch (WebApplicationException ex) {
                 Response excResponse = JAXRSUtils.convertFaultToResponse(ex, 
-                                                                         baseAddress,
                                                                          exchange.getInMessage());
                 return new MessageContentsList(excResponse);
             }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java Fri Mar 20 12:57:13 2009
@@ -94,14 +94,9 @@
                 ep.getService().setInvoker(invoker);
             }
             
-            if (entityProviders != null) {
-                ProviderFactory.getInstance(getAddress()).setUserProviders(entityProviders); 
-            }
-            if (schemaLocations != null) {
-                ProviderFactory.getInstance(getAddress()).setSchemaLocations(schemaLocations);
-            }
+            ProviderFactory factory = setupFactory(ep);
             
-            ProviderFactory.getInstance(getAddress()).setRequestPreprocessor(
+            factory.setRequestPreprocessor(
                 new RequestPreprocessor(languageMappings, extensionMappings));
             
             

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java Fri Mar 20 12:57:13 2009
@@ -78,13 +78,15 @@
     protected List<Interceptor> outInterceptors = new ModCountCopyOnWriteArrayList<Interceptor>();
     protected ConduitSelector conduitSelector;
     protected Bus bus;
-    
+
     private MultivaluedMap<String, String> requestHeaders = new MetadataMap<String, String>();
     private ResponseBuilder responseBuilder;
     
     private URI baseURI;
     private UriBuilder currentBuilder;
 
+    
+    
     protected AbstractClient(URI baseURI, URI currentURI) {
         this.baseURI = baseURI;
         this.currentBuilder = new UriBuilderImpl(currentURI).encode(true);
@@ -272,7 +274,7 @@
         
         MediaType contentType = MediaType.valueOf(headers.getFirst("Content-Type")); 
         
-        MessageBodyWriter mbw = ProviderFactory.getInstance(baseURI.getPath()).createMessageBodyWriter(
+        MessageBodyWriter mbw = ProviderFactory.getInstance(m).createMessageBodyWriter(
             cls, type, anns, contentType, m);
         if (mbw == null) {
             mbw = ProviderFactory.getInstance().createMessageBodyWriter(
@@ -307,7 +309,7 @@
         
         MediaType contentType = getResponseContentType(r);
         
-        MessageBodyReader mbr = ProviderFactory.getInstance(baseURI.getPath()).createMessageBodyReader(
+        MessageBodyReader mbr = ProviderFactory.getInstance(inMessage).createMessageBodyReader(
             cls, type, anns, contentType, inMessage);
         if (mbr == null) {
             ProviderFactory.getInstance().createMessageBodyReader(
@@ -424,6 +426,7 @@
         exchange.setOutMessage(m);
         exchange.put(Bus.class, bus);
         exchange.put(MessageObserver.class, new ClientMessageObserver());
+        exchange.put(Endpoint.class, conduitSelector.getEndpoint());
         exchange.setOneWay(false);
         m.setExchange(exchange);
         

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientProxyImpl.java Fri Mar 20 12:57:13 2009
@@ -52,7 +52,6 @@
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
-import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.ParameterType;
 import org.apache.cxf.message.Message;
@@ -170,16 +169,13 @@
         return index;
     }
     
-    private static void checkResponse(String basePath, Method m, Response r) throws Throwable {
+    private static void checkResponse(Method m, Response r, Message message) throws Throwable {
         
         int status = r.getStatus();
         
         if (status >= 400) {
             
-            ResponseExceptionMapper<?> mapper = findExceptionMapper(m, basePath);
-            if (mapper == null) {
-                mapper = findExceptionMapper(m, "/");
-            }
+            ResponseExceptionMapper<?> mapper = findExceptionMapper(m, message);
             if (mapper != null) {
                 Throwable t = mapper.fromResponse(r);
                 if (t != null) {
@@ -191,8 +187,8 @@
         }
     }
     
-    private static ResponseExceptionMapper<?> findExceptionMapper(Method m, String base) {
-        ProviderFactory pf = ProviderFactory.getInstance(base);
+    private static ResponseExceptionMapper<?> findExceptionMapper(Method m, Message message) {
+        ProviderFactory pf = ProviderFactory.getInstance(message);
         for (Class<?> exType : m.getExceptionTypes()) {
             ResponseExceptionMapper<?> mapper = pf.createResponseExceptionMapper(exType);
             if (mapper != null) {
@@ -241,7 +237,7 @@
         List<Parameter> indexList =  getParameters(map, key);
         List<Object> list = new ArrayList<Object>(indexList.size());
         for (Parameter p : indexList) {
-            list.add(encode(p, params[p.getIndex()].toString()));
+            list.add(params[p.getIndex()].toString());
         }
         return list;
     }
@@ -258,7 +254,7 @@
         List<Parameter> qs = getParameters(map, ParameterType.QUERY);
         for (Parameter p : qs) {
             if (params[p.getIndex()] != null) {
-                ub.queryParam(p.getValue(), encode(p, params[p.getIndex()].toString()));
+                ub.queryParam(p.getValue(), params[p.getIndex()].toString());
             }
         }
     }
@@ -268,7 +264,7 @@
         List<Parameter> mx = getParameters(map, ParameterType.MATRIX);
         for (Parameter p : mx) {
             if (params[p.getIndex()] != null) {
-                ub.matrixParam(p.getValue(), encode(p, params[p.getIndex()].toString()));
+                ub.matrixParam(p.getValue(), params[p.getIndex()].toString());
             }
         }
     }
@@ -315,50 +311,38 @@
             reportInvalidResourceMethod(ori.getMethodToInvoke(), "NO_CONTEXT_PARAMETERS");
         }
         
-        boolean isEncoded = AnnotationUtils.isEncoded(anns, ori);
         PathParam a = AnnotationUtils.getAnnotation(anns, PathParam.class); 
         if (a != null) {
-            return new Parameter(ParameterType.PATH, index, a.value(), isEncoded);
+            return new Parameter(ParameterType.PATH, index, a.value());
         } 
         
         QueryParam q = AnnotationUtils.getAnnotation(anns, QueryParam.class);
         if (q != null) {
-            return new Parameter(ParameterType.QUERY, index, q.value(), isEncoded);
+            return new Parameter(ParameterType.QUERY, index, q.value());
         }
         
         MatrixParam m = AnnotationUtils.getAnnotation(anns, MatrixParam.class);
         if (m != null) {
-            return new Parameter(ParameterType.MATRIX, index, m.value(), isEncoded);
+            return new Parameter(ParameterType.MATRIX, index, m.value());
         }  
     
         HeaderParam h = AnnotationUtils.getAnnotation(anns, HeaderParam.class);
         if (h != null) {
-            return new Parameter(ParameterType.HEADER, index, h.value(), isEncoded);
+            return new Parameter(ParameterType.HEADER, index, h.value());
         }  
         
         Parameter p = null;
         CookieParam c = AnnotationUtils.getAnnotation(anns, CookieParam.class);
         if (c != null) {
-            p = new Parameter(ParameterType.COOKIE, index, c.value(), isEncoded);
+            p = new Parameter(ParameterType.COOKIE, index, c.value());
         } else {
-            p = new Parameter(ParameterType.REQUEST_BODY, index, null, isEncoded); 
+            p = new Parameter(ParameterType.REQUEST_BODY, index, null); 
         }
         
         return p;
         
     }
     
-    private static String encode(Parameter p, String value) {
-        if (p.isEncoded()) {
-            return value;
-        }
-        if (p.getType() == ParameterType.PATH || p.getType() == ParameterType.MATRIX) {
-            return HttpUtils.pathEncode(value);
-        } else {
-            return HttpUtils.urlEncode(value); 
-        }
-    }
-    
     private Object doChainedInvocation(URI uri, MultivaluedMap<String, String> headers, 
                           OperationResourceInfo ori, Object[] params, int bodyIndex, 
                           MultivaluedMap<ParameterType, Parameter> types) throws Throwable {
@@ -390,7 +374,7 @@
         throws Throwable {
         Response r = setResponseBuilder(connect).clone().build();
         Method method = ori.getMethodToInvoke();
-        checkResponse(getBaseURI().getPath(), method, r);
+        checkResponse(method, r, inMessage);
         if (method.getReturnType() == Void.class) { 
             return null;
         }
@@ -413,13 +397,11 @@
         private ParameterType type;
         private int ind;
         private String aValue;
-        private boolean isEncoded;
         
-        public Parameter(ParameterType type, int ind, String aValue, boolean encoded) {
+        public Parameter(ParameterType type, int ind, String aValue) {
             this.type = type;
             this.ind = ind;
             this.aValue = aValue; 
-            this.isEncoded = encoded;
         }
         
         public int getIndex() {
@@ -433,10 +415,6 @@
         public ParameterType getType() {
             return type;
         }
-        
-        public boolean isEncoded() {
-            return isEncoded;
-        }
     }
 
     // TODO : what we really need to do is to refactor JAXRSOutInterceptor so that

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java Fri Mar 20 12:57:13 2009
@@ -35,7 +35,6 @@
 import org.apache.cxf.jaxrs.JAXRSServiceImpl;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.provider.ProviderFactory;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.service.Service;
 
@@ -162,11 +161,6 @@
         if (headers != null) {
             client.headers(headers);
         }
-        if (entityProviders != null) {
-            ProviderFactory.getInstance().setUserProviders(entityProviders); 
-        }
-        if (schemaLocations != null) {
-            ProviderFactory.getInstance().setSchemaLocations(schemaLocations);
-        }
+        setupFactory(ep);
     }
 } 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/WebClient.java Fri Mar 20 12:57:13 2009
@@ -202,6 +202,7 @@
     }
     
     public <T> T invoke(String httpMethod, Object body, Class<T> responseClass) {
+        
         Response r = doInvoke(httpMethod, body, responseClass);
         
         if (r.getStatus() >= 400) {
@@ -228,6 +229,7 @@
         for (Object o : values) {
             getCurrentBuilder().queryParam(name, o.toString());
         }
+        
         return this;
     }
     
@@ -378,6 +380,7 @@
         try {
             ResponseBuilder rb = setResponseBuilder(conn).clone();
             Response currentResponse = rb.clone().build();
+            
             Object entity = readBody(currentResponse, conn, m, responseClass, responseClass,
                                      new Annotation[]{});
             rb.entity(entity);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/XMLSource.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/XMLSource.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/XMLSource.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/XMLSource.java Fri Mar 20 12:57:13 2009
@@ -42,11 +42,16 @@
 public class XMLSource {
     
     private InputSource source; 
+    private RuntimeException exceptionToThrow;
     
     public XMLSource(InputStream is) {
         source = new InputSource(is);
     }
     
+    public void setException(RuntimeException ex) {
+        exceptionToThrow = ex; 
+    }
+    
     public <T> T getNode(String expression, Class<T> cls) {
         return getNode(expression, CastUtils.cast(Collections.emptyMap(), String.class, String.class), cls);
     }
@@ -57,6 +62,9 @@
         try {
             Node node = (Node)xpath.evaluate(expression, source, XPathConstants.NODE);
             if (node == null) {
+                if (exceptionToThrow != null) {
+                    throw exceptionToThrow;
+                }
                 return null;
             }
             DOMSource ds = new DOMSource(node);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java Fri Mar 20 12:57:13 2009
@@ -33,11 +33,17 @@
     private Map<K, List<V>> m;
     
     public MetadataMap() {
-        this(new LinkedHashMap<K, List<V>>());
+        this.m = new LinkedHashMap<K, List<V>>();
     }
     
     public MetadataMap(Map<K, List<V>> store) {
-        this.m = store;
+        
+        this.m = new LinkedHashMap<K, List<V>>();
+        if (store != null) {
+            for (Map.Entry<K, List<V>> entry : store.entrySet()) {
+                m.put(entry.getKey(), new ArrayList<V>(entry.getValue()));
+            }
+        }
     }
     
     public void add(K key, V value) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ProvidersImpl.java Fri Mar 20 12:57:13 2009
@@ -39,13 +39,13 @@
     
     public <T> MessageBodyReader<T> getMessageBodyReader(
          Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
-        return ProviderFactory.getInstance((String)m.get(Message.BASE_PATH)).createMessageBodyReader(
+        return ProviderFactory.getInstance(m).createMessageBodyReader(
             type, genericType, annotations, mediaType, m);
     }
 
     public <T> MessageBodyWriter<T> getMessageBodyWriter(
         Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
-        return ProviderFactory.getInstance((String)m.get(Message.BASE_PATH)).createMessageBodyWriter(
+        return ProviderFactory.getInstance(m).createMessageBodyWriter(
                    type, genericType, annotations, mediaType, m);
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriBuilderImpl.java Fri Mar 20 12:57:13 2009
@@ -31,8 +31,6 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import javax.ws.rs.Path;
 import javax.ws.rs.core.MultivaluedMap;
@@ -46,7 +44,6 @@
 
 public class UriBuilderImpl extends UriBuilder {
     
-    private static final Pattern DECODE_PATTERN = Pattern.compile("%[0-9a-fA-F][0-9a-fA-F]");
     
     private boolean encode;
     private String scheme;
@@ -88,7 +85,7 @@
     public URI build(Object... values) throws IllegalArgumentException, UriBuilderException {
         if (encode) {
             for (int i = 0; i < values.length; i++) {
-                values[i] = decodePartiallyEncoded(values[i].toString());
+                values[i] = HttpUtils.encodePartiallyEncoded(values[i].toString(), false);
             }
         }
         return doBuild(encode, values);
@@ -96,14 +93,45 @@
 
     private URI doBuild(boolean fromEncoded, Object... values) {
         try {
-            String path = buildPath(fromEncoded);
-            path = substituteVarargs(path, values);
-            return new URI(scheme, userInfo, host, port, path, buildQuery(), fragment);
+            String thePath = buildPath(fromEncoded);
+            thePath = substituteVarargs(thePath, values);
+            return buildURI(fromEncoded, thePath);
         } catch (URISyntaxException ex) {
             throw new UriBuilderException("URI can not be built", ex);
         }
     }
     
+    private URI buildURI(boolean fromEncoded, String thePath) throws URISyntaxException {
+        String theQuery = buildQuery(fromEncoded);
+        // TODO : do encodePartiallyEncoded only once here, do not do it inside buildPath()
+        // buildFromEncoded and buildFromEncodedMap - we'll need to be careful such that 
+        // path '/' seperators are not encoded so probably we'll need to create PathSegments
+        // again if fromEncoded is set
+        if (fromEncoded) {
+            StringBuilder b = new StringBuilder();
+            b.append(scheme).append("://");
+            if (userInfo != null) {
+                b.append(userInfo).append('@');
+            }
+            b.append(host);
+            if (port != -1) {
+                b.append(':').append(port);    
+            }
+            if (thePath != null && thePath.length() > 0) {
+                b.append(thePath.startsWith("/") ? thePath : '/' + thePath);
+            }
+            if (theQuery != null && theQuery.length() != 0) {
+                b.append('?').append(theQuery);
+            }
+            if (fragment != null) {
+                b.append('#').append(fragment);
+            }
+            return new URI(b.toString());
+        } else {
+            return new URI(scheme, userInfo, host, port, thePath, theQuery, fragment);
+        }
+    }
+    
     private String substituteVarargs(String path, Object... values) {
         Map<String, String> varValueMap = new HashMap<String, String>();
         URITemplate templ = new URITemplate(path);
@@ -127,20 +155,21 @@
         if (encode) {
             Map<String, String> decodedMap = new HashMap<String, String>(map.size());
             for (Map.Entry<String, ? extends Object> entry : map.entrySet()) {
-                decodedMap.put(entry.getKey(), decodePartiallyEncoded(entry.getValue().toString()));
+                decodedMap.put(entry.getKey(), 
+                               HttpUtils.encodePartiallyEncoded(entry.getValue().toString(), false));
             }
             return doBuildFromMap(decodedMap, encode);
         } else {
             return doBuildFromMap(map, encode);
         }
     }
-
+    
     private URI doBuildFromMap(Map<String, ? extends Object> map, boolean fromEncoded) 
         throws IllegalArgumentException, UriBuilderException {
         try {
-            String path = buildPath(fromEncoded);
-            path = substituteMapped(path, map);
-            return new URI(scheme, userInfo, host, port, path, buildQuery(), fragment);
+            String thePath = buildPath(fromEncoded);
+            thePath = substituteMapped(thePath, map);
+            return buildURI(fromEncoded, thePath);
         } catch (URISyntaxException ex) {
             throw new UriBuilderException("URI can not be built", ex);
         }
@@ -392,9 +421,9 @@
         scheme = uri.getScheme();
         port = uri.getPort();
         host = uri.getHost();
-        setPathAndMatrix(uri.getPath());
+        setPathAndMatrix(uri.getRawPath());
         fragment = uri.getFragment();
-        query = JAXRSUtils.getStructuredParams(uri.getQuery(), "&", true);
+        query = JAXRSUtils.getStructuredParams(uri.getRawQuery(), "&", false);
         userInfo = uri.getUserInfo();
     }
 
@@ -414,6 +443,7 @@
             PathSegment ps = iter.next();
             String p = ps.getPath();
             if (p.length() != 0 || !iter.hasNext()) {
+                p = fromEncoded ? new URITemplate(p).encodeLiteralCharacters() : p;
                 if (!p.startsWith("/")) {
                     sb.append('/');
                 }
@@ -427,26 +457,8 @@
         return sb.toString();
     }
 
-    private String buildQuery() {
-        return buildParams(query, '&', false);
-    }
-
-    /**
-     * Decode partially encoded string. Decode only values that matches patter "percent char followed by two
-     * hexadecimal digits".
-     * 
-     * @param encoded fully or partially encoded string.
-     * @return decoded string
-     */
-    private String decodePartiallyEncoded(String encoded) {
-        Matcher m = DECODE_PATTERN.matcher(encoded);
-        StringBuffer sb = new StringBuffer();
-        while (m.find()) {
-            String found = m.group();
-            m.appendReplacement(sb, HttpUtils.pathDecode(found));
-        }
-        m.appendTail(sb);
-        return sb.toString();
+    private String buildQuery(boolean fromEncoded) {
+        return buildParams(query, '&', fromEncoded);
     }
 
     /**
@@ -459,13 +471,14 @@
      */
     private String buildParams(MultivaluedMap<String, String> map, char separator,
                                       boolean fromEncoded) {
+        boolean isQuery = separator == '&';
         StringBuilder b = new StringBuilder();
         for (Iterator<Map.Entry<String, List<String>>> it = map.entrySet().iterator(); it.hasNext();) {
             Map.Entry<String, List<String>> entry = it.next();
             for (Iterator<String> sit = entry.getValue().iterator(); sit.hasNext();) {
                 String val = sit.next();
                 if (fromEncoded) {
-                    val = decodePartiallyEncoded(val);
+                    val = HttpUtils.encodePartiallyEncoded(val, isQuery);
                 }
                 b.append(entry.getKey()).append('=').append(val);
                 if (sit.hasNext() || it.hasNext()) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/UriInfoImpl.java Fri Mar 20 12:57:13 2009
@@ -163,7 +163,7 @@
                         sum += "/" + (decode ? HttpUtils.pathDecode(v) : v);
                     }
                 }
-                UriBuilder ub = UriBuilder.fromPath(sum);
+                UriBuilder ub = UriBuilder.fromPath(sum).encode(decode);
                 objects.addAll(invocation.getTemplateValues());
                 uris.add(ub.build(objects.toArray()).normalize().getPath());
             }

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -61,15 +61,12 @@
 
     public void handleMessage(Message message) {
         
-        
-        String originalAddress = HttpUtils.getOriginalAddress(message);
-        
         try {
-            processRequest(message, originalAddress);
+            processRequest(message);
         } catch (RuntimeException ex) {
-            Response excResponse = JAXRSUtils.convertFaultToResponse(ex, originalAddress, message);
+            Response excResponse = JAXRSUtils.convertFaultToResponse(ex, message);
             if (excResponse == null) {
-                ProviderFactory.getInstance(originalAddress).clearThreadLocalProxies();
+                ProviderFactory.getInstance(message).clearThreadLocalProxies();
                 throw ex;
             }
             message.getExchange().put(Response.class, excResponse);
@@ -78,15 +75,14 @@
         
     }
     
-    private void processRequest(Message message, String originalAddress) {
+    private void processRequest(Message message) {
         
         if (message.getExchange().get(OperationResourceInfo.class) != null) {
             // it's a suspended invocation;
             return;
         }
         
-        RequestPreprocessor rp = 
-            ProviderFactory.getInstance(originalAddress).getRequestPreprocessor();
+        RequestPreprocessor rp = ProviderFactory.getInstance(message).getRequestPreprocessor();
         if (rp != null) {
             rp.preprocess(message, new UriInfoImpl(message, null));
         }
@@ -129,8 +125,7 @@
         String httpMethod = (String)message.get(Message.HTTP_REQUEST_METHOD);
         OperationResourceInfo ori = null;     
         
-        List<ProviderInfo<RequestHandler>> shs = 
-            ProviderFactory.getInstance(originalAddress).getRequestHandlers();
+        List<ProviderInfo<RequestHandler>> shs = ProviderFactory.getInstance(message).getRequestHandlers();
         for (ProviderInfo<RequestHandler> sh : shs) {
             String newAcceptTypes = (String)message.get(Message.ACCEPT_CONTENT_TYPE);
             if (!acceptTypes.equals(newAcceptTypes) || ori == null) {

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -45,7 +45,6 @@
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.provider.ProviderFactory;
-import org.apache.cxf.jaxrs.utils.HttpUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
 import org.apache.cxf.message.Exchange;
@@ -65,11 +64,10 @@
 
     public void handleMessage(Message message) {
         
-        String baseAddress = HttpUtils.getOriginalAddress(message.getExchange().getInMessage());
         try {
-            processResponse(message, baseAddress);
+            processResponse(message);
         } finally {
-            ProviderFactory.getInstance(baseAddress).clearThreadLocalProxies();
+            ProviderFactory.getInstance(message).clearThreadLocalProxies();
             ClassResourceInfo cri =
                 (ClassResourceInfo)message.getExchange().get(JAXRSInInterceptor.ROOT_RESOURCE_CLASS);
             if (cri != null) {
@@ -80,7 +78,7 @@
 
     }
     
-    private void processResponse(Message message, String baseAddress) {
+    private void processResponse(Message message) {
         
         MessageContentsList objs = MessageContentsList.getContentsList(message);
         if (objs == null || objs.size() == 0) {
@@ -101,7 +99,7 @@
                 .getName());
 
             List<ProviderInfo<ResponseHandler>> handlers = 
-                ProviderFactory.getInstance(baseAddress).getResponseHandlers();
+                ProviderFactory.getInstance(message).getResponseHandlers();
             for (ProviderInfo<ResponseHandler> rh : handlers) {
                 Response r = rh.getProvider().handleResponse(message, ori, response);
                 if (r != null) {
@@ -109,7 +107,7 @@
                 }
             }
             
-            serializeMessage(message, response, ori, baseAddress, true);        
+            serializeMessage(message, response, ori, true);        
             
         } else {
             message.put(Message.RESPONSE_CODE, 204);
@@ -120,7 +118,6 @@
     private void serializeMessage(Message message, 
                                   Response response, 
                                   OperationResourceInfo ori,
-                                  String baseAddress,
                                   boolean firstTry) {
         message.put(Message.RESPONSE_CODE, response.getStatus());
         Map<String, List<String>> theHeaders = 
@@ -148,7 +145,7 @@
         MessageBodyWriter writer = null;
         MediaType responseType = null;
         for (MediaType type : availableContentTypes) { 
-            writer = ProviderFactory.getInstance(baseAddress)
+            writer = ProviderFactory.getInstance(message)
                 .createMessageBodyWriter(targetType, 
                       invoked != null ? invoked.getGenericReturnType() : null, 
                       invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
@@ -191,9 +188,9 @@
             }
             
         } catch (IOException ex) {
-            handleWriteException(message, response, ori, baseAddress, ex, responseObj, firstTry);
+            handleWriteException(message, response, ori, ex, responseObj, firstTry);
         } catch (Throwable ex) {
-            handleWriteException(message, response, ori, baseAddress, ex, responseObj, firstTry);
+            handleWriteException(message, response, ori, ex, responseObj, firstTry);
         }
     }
     
@@ -247,15 +244,14 @@
     private void handleWriteException(Message message, 
                                          Response response, 
                                          OperationResourceInfo ori,
-                                         String baseAddress,
                                          Throwable ex,
                                          Object responseObj,
                                          boolean firstTry) {
         OutputStream out = message.getContent(OutputStream.class);
         if (firstTry) {
-            Response excResponse = JAXRSUtils.convertFaultToResponse(ex, baseAddress, message);
+            Response excResponse = JAXRSUtils.convertFaultToResponse(ex, message);
             if (excResponse != null) {
-                serializeMessage(message, excResponse, ori, baseAddress, false);
+                serializeMessage(message, excResponse, ori, false);
             }
         } else {
             message.put(Message.RESPONSE_CODE, 500);

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -268,6 +268,24 @@
         return sb.toString();
     }
 
+    /**
+     * Encoded literal characters surrounding template variables, 
+     * ex. "a {id} b" will be encoded to "a%20{id}%20b" 
+     * @return encoded value
+     */
+    public String encodeLiteralCharacters() {
+        StringBuilder sb = new StringBuilder();
+        Matcher matcher = TEMPLATE_NAMES_PATTERN.matcher(template);
+        int i = 0;
+        while (matcher.find()) {
+            sb.append(HttpUtils.encodePartiallyEncoded(template.substring(i, matcher.start()), false));
+            sb.append('{').append(matcher.group(1)).append('}');
+            i = matcher.end();
+        }
+        sb.append(HttpUtils.encodePartiallyEncoded(template.substring(i, template.length()), false));
+        return sb.toString();
+    }
+    
     public static URITemplate createTemplate(ClassResourceInfo cri, Path path) {
 
         if (path == null) {

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -26,10 +26,8 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.ContextResolver;
@@ -37,6 +35,7 @@
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
 import org.apache.cxf.jaxrs.ext.ParameterHandler;
 import org.apache.cxf.jaxrs.ext.RequestHandler;
@@ -51,11 +50,7 @@
 
 public final class ProviderFactory {
     
-    private static final Map<String, ProviderFactory> FACTORIES = 
-        new HashMap<String, ProviderFactory>();
     private static final ProviderFactory SHARED_FACTORY = new ProviderFactory();
-    private static final ProviderFactory DEFAULT_FACTORY = new ProviderFactory(); 
-    private static final String SLASH = "/"; 
     
     static {
         SHARED_FACTORY.setProviders(new JAXBElementProvider(),
@@ -91,25 +86,14 @@
     }
     
     public static ProviderFactory getInstance() {
-        return getInstance("/");
+        return new ProviderFactory();
     }
     
-    public static ProviderFactory getInstance(String baseAddress) {
-        if (SLASH.equals(baseAddress)) {
-            return DEFAULT_FACTORY;
-        }
-        
-        ProviderFactory pf = null;
-        synchronized (ProviderFactory.class) { 
-            pf = FACTORIES.get(baseAddress);
-            if (pf == null) {
-                pf = new ProviderFactory();
-                FACTORIES.put(baseAddress, pf);
-            }
-        }
-        return pf;
+    public static ProviderFactory getInstance(Message m) {
+        Endpoint e = m.getExchange().get(Endpoint.class);
+        return (ProviderFactory)e.get(ProviderFactory.class.getName());
     }
-
+    
     public static ProviderFactory getSharedInstance() {
         return SHARED_FACTORY;
     }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/SourceProvider.java Fri Mar 20 12:57:13 2009
@@ -45,6 +45,8 @@
 
 import org.w3c.dom.Document;
 
+import org.apache.cxf.jaxrs.client.XMLSource;
+
 @Provider
 @ProduceMime({"application/xml", "text/xml" })
 @ConsumeMime({"application/xml", "text/xml" })
@@ -56,7 +58,7 @@
     }
     
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations) {
-        return Source.class.isAssignableFrom(type);
+        return Source.class.isAssignableFrom(type) || XMLSource.class.isAssignableFrom(type);
     }
     
     public Object readFrom(Class<Object> source, Type genericType, Annotation[] annotations, MediaType m,  
@@ -79,6 +81,8 @@
         } else if (StreamSource.class.isAssignableFrom(source)
                    || Source.class.isAssignableFrom(source)) {
             return new StreamSource(is);
+        } else if (XMLSource.class.isAssignableFrom(source)) {
+            return new XMLSource(is);
         }
         
         throw new IOException("Unrecognized source");

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -29,6 +29,8 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.core.PathSegment;
@@ -45,7 +47,7 @@
     
     private static final String LOCAL_IP_ADDRESS = "127.0.0.1";
     private static final String LOCAL_HOST = "localhost";
-    
+    private static final Pattern ENCODE_PATTERN = Pattern.compile("%[0-9a-fA-F][0-9a-fA-F]");
     
     private HttpUtils() {
     }
@@ -73,12 +75,42 @@
         
         String result = urlEncode(value);
         // URLEncoder will encode '+' to %2B but will turn ' ' into '+'
+        // We need to retain '+' and encode ' ' as %20
         if (result.indexOf('+') != -1) {
             result = result.replace("+", "%20");
         }
+        if (result.indexOf("%2B") != -1) {
+            result = result.replace("%2B", "+");
+        }
+
         return result;
     }
     
+    /**
+     * Encodes partially encoded string. Encode all values but those matching pattern 
+     * "percent char followed by two hexadecimal digits".
+     * 
+     * @param encoded fully or partially encoded string.
+     * @return fully encoded string
+     */
+    public static String encodePartiallyEncoded(String encoded, boolean query) {
+        if (encoded.length() == 0) {
+            return encoded;
+        }
+        Matcher m = ENCODE_PATTERN.matcher(encoded);
+        StringBuffer sb = new StringBuffer();
+        int i = 0;
+        while (m.find()) {
+            String before = encoded.substring(i, m.start());
+            sb.append(query ? HttpUtils.urlEncode(before) : HttpUtils.pathEncode(before));
+            sb.append(m.group());
+            i = m.end();            
+        }
+        String tail = encoded.substring(i, encoded.length());
+        sb.append(query ? HttpUtils.urlEncode(tail) : HttpUtils.pathEncode(tail));
+        return sb.toString();
+    }
+    
     public static SimpleDateFormat getHttpDateFormat() {
         SimpleDateFormat dateFormat = 
             new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -167,7 +167,7 @@
     public static Object handleParameter(String value, 
                                          Class<?> pClass, 
                                          ParameterType pType,
-                                         String basePath) {
+                                         Message message) {
         
         if (value == null) {
             return null;
@@ -209,8 +209,8 @@
             result = evaluateFactoryMethod(value, pClass, pType, methodNames[1]);
         }
         
-        if (basePath != null) {
-            ParameterHandler<?> pm = ProviderFactory.getInstance(basePath)
+        if (message != null) {
+            ParameterHandler<?> pm = ProviderFactory.getInstance(message)
                 .createParameterHandler(pClass);
             if (pm != null) {
                 result = pm.fromString(value);
@@ -260,7 +260,7 @@
     }
     
     public static Object handleBean(Class<?> paramType, MultivaluedMap<String, String> values,
-                                    ParameterType pType, String basePath) {
+                                    ParameterType pType, Message message) {
         Object bean = null;
         try {
             bean = paramType.newInstance();
@@ -277,7 +277,7 @@
                     && m.getParameterTypes().length == 1) {
                     Object paramValue = handleParameter(entry.getValue().get(0), 
                                                         m.getParameterTypes()[0],
-                                                        pType, basePath);
+                                                        pType, message);
                     if (paramValue != null) {
                         injectThroughMethod(bean, m, paramValue);
                         injected = true;
@@ -291,7 +291,7 @@
             for (Field f : paramType.getFields()) {
                 if (f.getName().equalsIgnoreCase(entry.getKey())) {
                     Object paramValue = handleParameter(entry.getValue().get(0), 
-                                                        f.getType(), pType, basePath);
+                                                        f.getType(), pType, message);
                     if (paramValue != null) {
                         injectFieldValue(f, bean, paramValue);
                         break;
@@ -305,14 +305,14 @@
     
     @SuppressWarnings("unchecked")
     public static Object injectIntoList(Type genericType, List<String> values,
-                                        boolean decoded, ParameterType pathParam, String basePath) {
+                                        boolean decoded, ParameterType pathParam, Message message) {
         Class<?> realType = InjectionUtils.getActualType(genericType);
         values = checkPathSegment(values, realType, pathParam);
         List theValues = new ArrayList();
         for (String r : values) {
             String value = decodeValue(r, decoded, pathParam);
             
-            Object o = InjectionUtils.handleParameter(value, realType, pathParam, basePath);
+            Object o = InjectionUtils.handleParameter(value, realType, pathParam, message);
             if (o != null) {
                 theValues.add(o);
             }
@@ -326,7 +326,7 @@
     public static Object injectIntoSet(Type genericType, List<String> values, 
                                        boolean sorted, 
                                        boolean decoded, 
-                                       ParameterType pathParam, String basePath) {
+                                       ParameterType pathParam, Message message) {
         Class<?> realType = InjectionUtils.getActualType(genericType);
         
         values = checkPathSegment(values, realType, pathParam);
@@ -334,7 +334,7 @@
         Set theValues = sorted ? new TreeSet() : new HashSet();
         for (String r : values) {
             String value = decodeValue(r, decoded, pathParam);
-            Object o = InjectionUtils.handleParameter(value, realType, pathParam, basePath);
+            Object o = InjectionUtils.handleParameter(value, realType, pathParam, message);
             if (o != null) {
                 theValues.add(o);
             }
@@ -368,7 +368,7 @@
                                                String defaultValue,
                                                boolean decoded,
                                                ParameterType pathParam,
-                                               String basePath) {
+                                               Message message) {
         
         if (paramValues == null) {
             if (defaultValue != null) {
@@ -385,13 +385,13 @@
         
         if (List.class.isAssignableFrom(paramType)) {
             return InjectionUtils.injectIntoList(genericType, paramValues, decoded, pathParam,
-                                                 basePath);
+                                                 message);
         } else if (Set.class.isAssignableFrom(paramType)) {
             return InjectionUtils.injectIntoSet(genericType, paramValues, false, decoded, pathParam,
-                                                basePath);
+                                                message);
         } else if (SortedSet.class.isAssignableFrom(paramType)) {
             return InjectionUtils.injectIntoSet(genericType, paramValues, true, decoded, pathParam,
-                                                basePath);
+                                                message);
         } else {
             String result = null;
             if (paramValues.size() > 0) {
@@ -401,7 +401,7 @@
             }
             if (result != null) {
                 result = decodeValue(result, decoded, pathParam);
-                return InjectionUtils.handleParameter(result, paramType, pathParam, basePath);
+                return InjectionUtils.handleParameter(result, paramType, pathParam, message);
             } else {
                 return null;
             }

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -507,13 +507,11 @@
                 }
             }
             
-            String basePath = HttpUtils.getOriginalAddress(m);
-            
             if ("".equals(key)) {
                 return InjectionUtils.handleBean(pClass, 
                                                  params, 
                                                  ParameterType.MATRIX,
-                                                 basePath);
+                                                 m);
             } else {
                 List<String> values = params.get(key);
                 return InjectionUtils.createParameterObject(values, 
@@ -522,7 +520,7 @@
                                                             defaultValue,
                                                             false,
                                                             ParameterType.MATRIX,
-                                                            basePath);
+                                                            m);
             }
         }
         
@@ -545,14 +543,13 @@
         if (values != null && values.isEmpty()) {
             values = null;
         }
-        String basePath = HttpUtils.getOriginalAddress(m);
         return InjectionUtils.createParameterObject(values, 
                                                     pClass, 
                                                     genericType,
                                                     defaultValue,
                                                     false,
                                                     ParameterType.HEADER,
-                                                    basePath);
+                                                    m);
              
         
     }
@@ -573,8 +570,7 @@
             return c;
         }
         
-        String basePath = HttpUtils.getOriginalAddress(m);
-        return InjectionUtils.handleParameter(c.getValue(), pClass, ParameterType.COOKIE, basePath);
+        return InjectionUtils.handleParameter(c.getValue(), pClass, ParameterType.COOKIE, m);
     }
     
     public static <T> T createContextValue(Message m, Type genericType, Class<T> clazz) {
@@ -613,7 +609,7 @@
     
     public static ContextResolver<?> createContextResolver(Type genericType, Message m) {
         if (genericType instanceof ParameterizedType) {
-            return ProviderFactory.getInstance(HttpUtils.getOriginalAddress(m)).createContextResolver(
+            return ProviderFactory.getInstance(m).createContextResolver(
                       ((ParameterizedType)genericType).getActualTypeArguments()[0], m);
         }
         return null;
@@ -652,10 +648,9 @@
                                            String defaultValue,
                                            boolean  decoded) {
         
-        String basePath = HttpUtils.getOriginalAddress(m);
         String parameterName = uriParamAnnotation.value();
         if ("".equals(parameterName)) {
-            return InjectionUtils.handleBean(paramType, values, ParameterType.PATH, basePath);
+            return InjectionUtils.handleBean(paramType, values, ParameterType.PATH, m);
         } else {
             List<String> results = values.get(parameterName);
             return InjectionUtils.createParameterObject(results, 
@@ -664,7 +659,7 @@
                                                     defaultValue,
                                                     decoded,
                                                     ParameterType.PATH,
-                                                    basePath);
+                                                    m);
         }
     }
     
@@ -679,11 +674,10 @@
                                           boolean decode) {
         String queryName = queryParam.value();
 
-        String basePath = HttpUtils.getOriginalAddress(m);
         if ("".equals(queryName)) {
             return InjectionUtils.handleBean(paramType, 
                                              new UriInfoImpl(m, null).getQueryParameters(),
-                                             ParameterType.QUERY, basePath);
+                                             ParameterType.QUERY, m);
         } else {
             List<String> results = getStructuredParams((String)m.get(Message.QUERY_STRING),
                                        "&",
@@ -694,7 +688,7 @@
                                                         genericType,
                                                         defaultValue,
                                                         false,
-                                                        ParameterType.QUERY, basePath);
+                                                        ParameterType.QUERY, m);
              
         }
     }
@@ -744,7 +738,7 @@
         
         MessageBodyReader provider = null;
         for (MediaType type : types) { 
-            provider = ProviderFactory.getInstance(HttpUtils.getOriginalAddress(m))
+            provider = ProviderFactory.getInstance(m)
                 .createMessageBodyReader(targetTypeClass,
                                          parameterType,
                                          parameterAnnotations,
@@ -908,10 +902,10 @@
     }
     
     @SuppressWarnings("unchecked")
-    public static Response convertFaultToResponse(Throwable ex, String baseAddress, Message inMessage) {
+    public static Response convertFaultToResponse(Throwable ex, Message inMessage) {
         
         ExceptionMapper mapper = 
-            ProviderFactory.getInstance(baseAddress).createExceptionMapper(ex.getClass(), inMessage);
+            ProviderFactory.getInstance(inMessage).createExceptionMapper(ex.getClass(), inMessage);
         if (mapper != null) {
             Response excResponse = mapper.toResponse(ex);
             if (excResponse != null) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java Fri Mar 20 12:57:13 2009
@@ -27,6 +27,14 @@
 
 public class WebClientTest extends Assert {
 
+    @Test
+    public void testEncoding() {
+        URI u = WebClient.create("http://foo").path("bar+ %2B").matrix("a", "value+ ")
+            .query("b", "bv+ ").getCurrentURI();
+        System.out.println("'" + u.toString() + "'");
+        assertEquals("http://foo/bar+%20%2B;a=value+%20?b=bv%2B+", u.toString());
+    }
+    
     @Test 
     public void testBaseCurrentPath() {
         assertEquals(URI.create("http://foo"), WebClient.create("http://foo").getBaseURI());

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java Fri Mar 20 12:57:13 2009
@@ -68,6 +68,50 @@
     }
     
     @Test
+    public void testClone() throws Exception {
+        URI uri = new URI("http://bar");
+        URI newUri = new UriBuilderImpl(uri).clone().build();   
+        assertEquals("URI is not built correctly", "http://bar", newUri.toString());
+    }
+    
+    @Test
+    public void testClonePctEncodedFromUri() throws Exception {
+        URI uri = new URI("http://bar/foo%20");
+        URI newUri = new UriBuilderImpl(uri).encode(true).clone().build();   
+        assertEquals("URI is not built correctly", "http://bar/foo%20", newUri.toString());
+    }
+    
+    @Test
+    public void testClonePctEncoded() throws Exception {
+        URI uri = new URI("http://bar");
+        URI newUri = new UriBuilderImpl(uri)
+            .path("{a}").path("{b}")
+            .matrixParam("m", "m1 ")
+            .matrixParam("m", "m2+%20")
+            .queryParam("q", "q1 ")
+            .queryParam("q", "q2+q3%20")
+            .encode(true).clone().build("a+ ", "b%2B%20 ");   
+        assertEquals("URI is not built correctly", 
+                     "http://bar/a+%20/b%2B%20%20;m=m1%20;m=m2+%20?q=q1+&q=q2%2Bq3%20", 
+                     newUri.toString());
+    }
+    
+    @Test
+    public void testEncodedPathQueryFromExistingURI() throws Exception {
+        URI uri = new URI("http://bar/foo+%20%2B?q=a+b%20%2B");
+        URI newUri = new UriBuilderImpl(uri).encode(true).build();   
+        assertEquals("URI is not built correctly", 
+                     "http://bar/foo+%20%2B?q=a%2Bb%20%2B", newUri.toString());
+    }
+    
+    @Test
+    public void testEncodedAddedQuery() throws Exception {
+        URI uri = new URI("http://bar");
+        URI newUri = new UriBuilderImpl(uri).queryParam("q", "a+b%20%2B").encode(true).build();   
+        assertEquals("URI is not built correctly", "http://bar?q=a%2Bb%20%2B", newUri.toString());
+    }
+    
+    @Test
     public void testSchemeSpecificPart() throws Exception {
         URI uri = new URI("http://bar");
         URI newUri = new UriBuilderImpl(uri).scheme("https").schemeSpecificPart("foo/bar").build();
@@ -328,8 +372,6 @@
         assertEquals("URI is not built correctly", new URI("http://foo/bar;p1=v1;p1=v2"), newUri);
     }
 
-    
-    
     @Test
     public void testPctEncodedMatrixParam() throws Exception {
         URI uri = new URI("http://foo/bar");

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=756439&r1=756438&r2=756439&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 Fri Mar 20 12:57:13 2009
@@ -46,6 +46,7 @@
 
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
+import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.Customer;
 import org.apache.cxf.jaxrs.CustomerParameterHandler;
@@ -54,7 +55,11 @@
 import org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper;
 import org.apache.cxf.jaxrs.model.ProviderInfo;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
+import org.easymock.classextension.EasyMock;
 
 import org.junit.Assert;
 import org.junit.Before;
@@ -70,12 +75,23 @@
     
     @Test
     public void testMultipleFactories() {
-        assertSame(ProviderFactory.getInstance(), ProviderFactory.getInstance());
-        assertSame(ProviderFactory.getInstance("/"), ProviderFactory.getInstance("/"));
-        assertSame(ProviderFactory.getInstance(), ProviderFactory.getInstance("/"));
         assertNotSame(ProviderFactory.getInstance(), ProviderFactory.getSharedInstance());
-        assertSame(ProviderFactory.getInstance("/bar"), ProviderFactory.getInstance("/bar"));
-        assertNotSame(ProviderFactory.getInstance("/bar"), ProviderFactory.getInstance("/"));
+        assertSame(ProviderFactory.getSharedInstance(), ProviderFactory.getSharedInstance());
+        assertNotSame(ProviderFactory.getInstance(), ProviderFactory.getInstance());
+    }
+    
+    @Test
+    public void testGetFactoryInboundMessage() {
+        ProviderFactory factory = ProviderFactory.getInstance();
+        Message m = new MessageImpl();
+        Exchange e = new ExchangeImpl();
+        m.setExchange(e);
+        Endpoint endpoint = EasyMock.createMock(Endpoint.class);
+        endpoint.get(ProviderFactory.class.getName());
+        EasyMock.expectLastCall().andReturn(factory);
+        EasyMock.replay(endpoint);
+        e.put(Endpoint.class, endpoint);
+        assertSame(ProviderFactory.getInstance(m), factory);
     }
     
     @Test
@@ -186,25 +202,26 @@
         assertTrue(BinaryDataProvider.class == writer.getClass());
     }
     
-    private void verifyProvider(Class<?> type, Class<?> provider, String mediaType,
-                                String errorMessage) 
+    private void verifyProvider(ProviderFactory pf, Class<?> type, Class<?> provider, String mediaType) 
         throws Exception {
         
+        if (pf == null) {
+            pf = ProviderFactory.getInstance();
+        }
+        
         MediaType mType = MediaType.valueOf(mediaType);
         
-        MessageBodyReader reader = ProviderFactory.getInstance()
-            .createMessageBodyReader(type, null, null, mType, new MessageImpl());
-        assertSame(errorMessage, provider, reader.getClass());
+        MessageBodyReader reader = pf.createMessageBodyReader(type, null, null, mType, new MessageImpl());
+        assertSame("Unexpected provider found", provider, reader.getClass());
     
-        MessageBodyWriter writer = ProviderFactory.getInstance()
-            .createMessageBodyWriter(type, null, null, mType, new MessageImpl());
-        assertTrue(errorMessage, provider == writer.getClass());
+        MessageBodyWriter writer = pf.createMessageBodyWriter(type, null, null, mType, new MessageImpl());
+        assertTrue("Unexpected provider found", provider == writer.getClass());
     }
     
     
     private void verifyProvider(Class<?> type, Class<?> provider, String mediaType) 
         throws Exception {
-        verifyProvider(type, provider, mediaType, "Unexpected provider found");
+        verifyProvider(null, type, provider, mediaType);
         
     }
        
@@ -215,18 +232,19 @@
     
     @Test
     public void testGetAtomProvider() throws Exception {
-        ProviderFactory.getInstance().setUserProviders(
+        ProviderFactory factory = ProviderFactory.getInstance();
+        factory.setUserProviders(
              Arrays.asList(
                   new Object[]{new AtomEntryProvider(), new AtomFeedProvider()}));
-        verifyProvider(Entry.class, AtomEntryProvider.class, "application/atom+xml");
-        verifyProvider(Feed.class, AtomFeedProvider.class, "application/atom+xml");
+        verifyProvider(factory, Entry.class, AtomEntryProvider.class, "application/atom+xml");
+        verifyProvider(factory, Feed.class, AtomFeedProvider.class, "application/atom+xml");
     }
     
     @Test
     public void testGetStringProviderUsingProviderDeclaration() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         pf.registerUserProvider(new TestStringProvider());
-        verifyProvider(String.class, TestStringProvider.class, "text/html");
+        verifyProvider(pf, String.class, TestStringProvider.class, "text/html");
     }    
     
     @Test
@@ -239,8 +257,8 @@
     public void testRegisterCustomJSONEntityProvider() throws Exception {
         ProviderFactory pf = ProviderFactory.getInstance();
         pf.registerUserProvider(new CustomJSONProvider());
-        verifyProvider(org.apache.cxf.jaxrs.resources.Book.class, CustomJSONProvider.class, 
-                       "application/json", "User-registered provider was not returned first");
+        verifyProvider(pf, org.apache.cxf.jaxrs.resources.Book.class, CustomJSONProvider.class, 
+                       "application/json");
     }
     
     
@@ -259,8 +277,8 @@
         ProviderFactory pf = (ProviderFactory)ProviderFactory.getInstance();
         pf.registerUserProvider(new CustomWidgetProvider());
         
-        verifyProvider(org.apache.cxf.jaxrs.resources.Book.class, CustomWidgetProvider.class, 
-                       "application/widget", "User-registered provider was not returned first");
+        verifyProvider(pf, org.apache.cxf.jaxrs.resources.Book.class, CustomWidgetProvider.class, 
+                       "application/widget");
     }
     
     private int indexOf(List<? extends Object> providerInfos, Class providerType) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java?rev=756439&r1=756438&r2=756439&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/HttpUtilsTest.java Fri Mar 20 12:57:13 2009
@@ -42,7 +42,12 @@
      
     @Test
     public void testPathEncode() {
-        assertEquals("%2B%20", HttpUtils.pathEncode("+ "));
+        assertEquals("+%20", HttpUtils.pathEncode("+ "));
+    }
+    
+    @Test
+    public void testURLEncode() {
+        assertEquals("%2B+", HttpUtils.urlEncode("+ "));
     }
     
     @Test



Mime
View raw message