cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r756410 [1/2] - in /cxf/branches/2.1.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/util/ rt/core/src/main/java/org/apache/cxf/bus/spring/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/databinding/jaxb/src/main/java/or...
Date Fri, 20 Mar 2009 10:46:39 GMT
Author: sergeyb
Date: Fri Mar 20 10:46:33 2009
New Revision: 756410

URL: http://svn.apache.org/viewvc?rev=756410&view=rev
Log:
Merged revisions 750522,750663,750948,752099,752280 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r750522 | sergeyb | 2009-03-05 17:52:17 +0000 (Thu, 05 Mar 2009) | 1 line
  
  JAXRS : fixing a bunch of exception-related issues on the outbound path
........
  r750663 | sergeyb | 2009-03-05 23:07:05 +0000 (Thu, 05 Mar 2009) | 1 line
  
  Minor updates to do with output buffering
........
  r750948 | sergeyb | 2009-03-06 15:54:07 +0000 (Fri, 06 Mar 2009) | 1 line
  
  JAXRS: client recursive subresource test
........
  r752099 | sergeyb | 2009-03-10 12:55:44 +0000 (Tue, 10 Mar 2009) | 1 line
  
  JAXRS: client api updates
........
  r752280 | sergeyb | 2009-03-10 21:47:47 +0000 (Tue, 10 Mar 2009) | 1 line
  
  CXF-2085 : optionally setting a thread context loader to that of the service object class loader
........

Added:
    cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java
      - copied, changed from r750522, cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/InvocationHandlerAware.java
      - copied unchanged from r752099, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/InvocationHandlerAware.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomOutInterceptor.java
      - copied unchanged from r750522, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomOutInterceptor.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerStreamingTest.java
      - copied, changed from r750522, cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerStreamingTest.java
Modified:
    cxf/branches/2.1.x-fixes/   (props changed)
    cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
    cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
    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/JAXRSInvoker.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/Client.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/JAXRSClientFactory.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/ext/MessageContext.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/Messages.properties
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.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/provider/AbstractConfigurableProvider.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/BinaryDataProvider.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/SourceProvider.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/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    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/provider/ProviderFactoryTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.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/BookStoreJaxrsJaxws.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookSubresource.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/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSHttpsBookTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/security/JAXRSSpringSecurityInterfaceTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/resources/jaxrs_atom/WEB-INF/beans.xml

Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Mar 20 10:46:33 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,750591,750689,750935,751067-751110,751233,751527,751567,751576,751607,751732,751740,751787,751828,751840,751972-751974,752122,752132,752136,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,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752992,753205,753293,753335,753338,753388,755153,755514,755806

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

Copied: cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java (from r750522, cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java?p2=cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java&p1=cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java&r1=750522&r2=756410&rev=756410&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java (original)
+++ cxf/branches/2.1.x-fixes/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java Fri Mar 20 10:46:33 2009
@@ -25,7 +25,6 @@
  */
 public final class SystemUtils {
     
-    public static final String OUT_BUFFERING = "org.apache.cxf.output.buffering";
     public static final String SPRING_VALIDATION_MODE = "org.apache.cxf.spring.validation.mode";
     
     private SystemUtils() {
@@ -33,22 +32,6 @@
     }
 
     /**
-     * Checks org.apache.cxf.output.buffering property value, defaults to false 
-     * @return true if output buffering is enabled
-     */
-    public static boolean isBufferingEnabled() { 
-        return Boolean.getBoolean(System.getProperty(OUT_BUFFERING, "false"));    
-    }
-    
-    /**
-     * Checks if org.apache.cxf.output.buffering property was explicitly set 
-     * @return true if it was set
-     */
-    public static boolean isBufferingSet() { 
-        return System.getProperty(OUT_BUFFERING) != null;    
-    }
-    
-    /**
      * Gets org.apache.cxf.spring.validation.mode property value if available 
      * @return Spring validation mode
      */

Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java (original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java Fri Mar 20 10:46:33 2009
@@ -34,6 +34,7 @@
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemUtils;
 import org.apache.cxf.configuration.Configurer;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 import org.springframework.beans.factory.xml.BeansDtdResolver;
@@ -231,10 +232,7 @@
         }
         reader.setNamespaceHandlerResolver(nsHandlerResolver);
         
-        String mode = System.getProperty("org.apache.cxf.spring.validation.mode");
-        if (mode == null) {
-            mode = System.getProperty("spring.validation.mode");
-        }
+        String mode = SystemUtils.getSpringValidationMode();
         if (null != mode) {
             reader.setValidationModeName(mode);
         }

Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java (original)
+++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractOutDatabindingInterceptor.java Fri Mar 20 10:46:33 2009
@@ -48,7 +48,7 @@
 public abstract class AbstractOutDatabindingInterceptor extends AbstractPhaseInterceptor<Message> {
 
     public static final String DISABLE_OUTPUTSTREAM_OPTIMIZATION = "disable.outputstream.optimization";
-    
+    public static final String OUT_BUFFERING = "org.apache.cxf.output.buffering";
     
     public AbstractOutDatabindingInterceptor(String phase) {
         super(phase);
@@ -72,8 +72,9 @@
         XMLStreamWriter xmlWriter = origXmlWriter;
         CachingXmlEventWriter cache = null;
         
-        if (shouldValidate(message) && !isRequestor(message)) {
-            //need to cache the events in case validation fails
+        // need to cache the events in case validation fails or buffering is enabled
+        if (shouldValidate(message) && !isRequestor(message)
+            || isBufferingEnabled(message)) {
             cache = new CachingXmlEventWriter();
             try {
                 cache.setNamespaceContext(origXmlWriter.getNamespaceContext());
@@ -126,6 +127,11 @@
     }
     
     
+    protected boolean isBufferingEnabled(Message m) {
+        Object en = m.getContextualProperty(OUT_BUFFERING);
+        return Boolean.TRUE.equals(en) || "true".equals(en);
+    }
+    
     protected boolean shouldValidate(Message m) {
         Object en = m.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
         return Boolean.TRUE.equals(en) || "true".equals(en);

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 10:46:33 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,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,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 10:46:33 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,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,755514,755806

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -57,7 +57,8 @@
 public class JAXRSInvoker extends AbstractInvoker {
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSServiceFactoryBean.class);
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSInvoker.class);
-
+    private static final String SERVICE_LOADER_AS_CONTEXT = "org.apache.cxf.serviceloader-context";
+    
     private List<Object> resourceObjects;
 
     public JAXRSInvoker() {
@@ -115,7 +116,11 @@
         }
 
         Object result = null;
+        ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
         try {
+            if (setServiceLoaderAsContextLoader(exchange.getInMessage())) {
+                Thread.currentThread().setContextClassLoader(resourceObject.getClass().getClassLoader());
+            }
             result = invoke(exchange, resourceObject, methodToInvoke, params);
         } catch (Fault ex) {
             Response excResponse = JAXRSUtils.convertFaultToResponse(ex.getCause(), 
@@ -131,6 +136,8 @@
                 throw ex;
             }
             return new MessageContentsList(excResponse);
+        } finally {
+            Thread.currentThread().setContextClassLoader(contextLoader);
         }
 
         if (ori.isSubResourceLocator()) {
@@ -194,6 +201,11 @@
         return result;
     }
 
+    private boolean setServiceLoaderAsContextLoader(Message inMessage) {
+        Object en = inMessage.getContextualProperty(SERVICE_LOADER_AS_CONTEXT);
+        return Boolean.TRUE.equals(en) || "true".equals(en);
+    }
+    
     public Object getServiceObject(Exchange exchange) {
         return getServiceObject(exchange, resourceObjects);
     }

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -68,7 +68,7 @@
 import org.apache.cxf.phase.PhaseManager;
 import org.apache.cxf.transport.MessageObserver;
 
-public class AbstractClient implements Client {
+public class AbstractClient implements Client, InvocationHandlerAware {
 
     protected static final MediaType WILDCARD = MediaType.valueOf("*/*");
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractClient.class);
@@ -90,14 +90,6 @@
         this.currentBuilder = new UriBuilderImpl(currentURI);
     }
     
-    protected AbstractClient(Client client, boolean inheritHeaders) {
-        this.baseURI = client.getCurrentURI();
-        this.currentBuilder = new UriBuilderImpl(client.getCurrentURI());
-        if (inheritHeaders) {
-            this.requestHeaders = client.getHeaders();
-        }
-    }
-    
     public Client header(String name, Object... values) {
         if (values == null) {
             throw new IllegalArgumentException();
@@ -197,11 +189,9 @@
     
     public Response getResponse() {
         if (responseBuilder == null) {
-            throw new IllegalStateException();
+            return null;
         }
-        Response r = responseBuilder.build();
-        responseBuilder = null;
-        return r;
+        return responseBuilder.build();
     }
     
     public Client reset() {
@@ -459,10 +449,11 @@
         public void onMessage(Message m) {
             
             Message message = conduitSelector.getEndpoint().getBinding().createMessage(m);
-            message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
+            message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
             message.put(Message.INBOUND_MESSAGE, Boolean.TRUE);
             PhaseInterceptorChain chain = setupInInterceptorChain(conduitSelector.getEndpoint());
             message.setInterceptorChain(chain);
+            message.getExchange().setInMessage(message);
             Bus origBus = BusFactory.getThreadDefaultBus(false);
             BusFactory.setThreadDefaultBus(bus);
 
@@ -475,4 +466,8 @@
         }
         
     }
+
+    public Object getInvocationHandler() {
+        return this;
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/Client.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/Client.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/Client.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/Client.java Fri Mar 20 10:46:33 2009
@@ -54,5 +54,9 @@
     URI getBaseURI();
     URI getCurrentURI();
     
+    /**
+     * Gets the response state if any
+     * @return JAXRS Response response
+     */
     Response getResponse();
 }

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -67,22 +67,24 @@
     
     private ClassResourceInfo cri;
     private boolean inheritHeaders;
+    private boolean isRoot;
     
-    public ClientProxyImpl(URI baseURI, URI currentURI, ClassResourceInfo cri, boolean inheritHeaders) {
+    public ClientProxyImpl(URI baseURI, URI currentURI, ClassResourceInfo cri, boolean isRoot, 
+                           boolean inheritHeaders) {
         super(baseURI, currentURI);
         this.cri = cri;
+        this.isRoot = isRoot;
         this.inheritHeaders = inheritHeaders;
     }
     
     public Object invoke(Object o, Method m, Object[] params) throws Throwable {
         
-        resetResponse();
-        
         Class<?> declaringClass = m.getDeclaringClass();
-        if (Client.class == declaringClass || Object.class == declaringClass) {
+        if (Client.class == declaringClass || InvocationHandlerAware.class == declaringClass
+            || Object.class == declaringClass) {
             return m.invoke(this, params);
         }
-        
+        resetResponse();
         OperationResourceInfo ori = cri.getMethodDispatcher().getOperationResourceInfo(m);
         if (ori == null) {
             reportInvalidResourceMethod(m, "INVALID_RESOURCE_METHOD");
@@ -95,7 +97,7 @@
         int bodyIndex = getBodyIndex(types, ori);
         
         UriBuilder builder = getCurrentBuilder().clone(); 
-        if (cri.isRoot()) {
+        if (isRoot) {
             builder.path(ori.getClassResourceInfo().getServiceClass());
         }
         builder.path(m);
@@ -114,7 +116,7 @@
             if (subCri == null) {
                 reportInvalidResourceMethod(m, "INVALID_SUBRESOURCE");
             }
-            ClientProxyImpl proxyImpl = new ClientProxyImpl(getBaseURI(), uri, subCri, inheritHeaders);
+            ClientProxyImpl proxyImpl = new ClientProxyImpl(getBaseURI(), uri, subCri, false, inheritHeaders);
             proxyImpl.setBus(bus);
             proxyImpl.setConduitSelector(conduitSelector);
             proxyImpl.setInInterceptors(inInterceptors);
@@ -132,11 +134,8 @@
         setRequestHeaders(headers, ori, types.containsKey(ParameterType.FORM), 
             bodyIndex == -1 ? null : params[bodyIndex].getClass(), m.getReturnType());
         
-        if (conduitSelector == null) {
-            return doDirectInvocation(uri, headers, ori, params, bodyIndex, types);
-        } else {
-            return doChainedInvocation(uri, headers, ori, params, bodyIndex, types);
-        }
+        return doChainedInvocation(uri, headers, ori, params, bodyIndex, types);
+        
     }
 
     private static MultivaluedMap<ParameterType, Parameter> getParametersInfo(OperationResourceInfo ori, 
@@ -351,33 +350,6 @@
         
     }
     
-    protected Object doDirectInvocation(URI uri, MultivaluedMap<String, String> headers, 
-        OperationResourceInfo ori, Object[] params, int bodyIndex, 
-        MultivaluedMap<ParameterType, Parameter> types) throws Throwable {
-
-        // TODO : we need to refactor bits of HTTPConduit such that it can be reused
-        
-        Message message = createSimpleMessage();
-        
-        HttpURLConnection connect = createHttpConnection(uri, ori.getHttpMethod());
-        setAllHeaders(headers, connect);
-        Method m = ori.getMethodToInvoke();
-        if (bodyIndex != -1 || types.containsKey(ParameterType.FORM)) {
-            if (bodyIndex != -1) {
-                writeBody(params[bodyIndex], message, params[bodyIndex].getClass(), 
-                          m.getGenericParameterTypes()[bodyIndex],
-                          m.getParameterAnnotations()[bodyIndex], headers, connect.getOutputStream());
-            } else {
-                MultivaluedMap<String, String> form = handleForm(types, params);
-                writeBody(form, message, form.getClass(), form.getClass(), m.getDeclaredAnnotations(),
-                          headers, connect.getOutputStream());
-            }
-        }
-        
-        return handleResponse(connect, message, ori);
-        
-    }
-    
     private Object doChainedInvocation(URI uri, MultivaluedMap<String, String> headers, 
                           OperationResourceInfo ori, Object[] params, int bodyIndex, 
                           MultivaluedMap<ParameterType, Parameter> types) throws Throwable {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java Fri Mar 20 10:46:33 2009
@@ -20,16 +20,11 @@
 
 import java.lang.reflect.InvocationHandler;
 import java.net.URI;
+import java.util.List;
 
-import javax.ws.rs.Path;
 import javax.ws.rs.core.MediaType;
 
-import org.apache.cxf.Bus;
-import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.common.util.ProxyHelper;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.utils.AnnotationUtils;
-import org.apache.cxf.jaxrs.utils.ResourceUtils;
 
 public final class JAXRSClientFactory {
     
@@ -49,58 +44,71 @@
      * Creates a proxy
      * @param baseURI baseURI
      * @param cls proxy class, if not interface then a CGLIB proxy will be created
-     * @param inheritHeaders if true then subresource proxies will inherit the headers
-     *        set on parent proxies 
+     * @param inheritHeaders if true then existing proxy headers will be inherited by 
+     *        subresource proxies if any
      * @return typed proxy
      */
     public static <T> T create(URI baseURI, Class<T> cls, boolean inheritHeaders) {
         
-        return create(baseURI, cls, inheritHeaders, false);
+        JAXRSClientFactoryBean bean = getBean(baseURI.toString(), cls, null);
+        bean.setInheritHeaders(inheritHeaders);
+        return bean.create(cls);
+        
     }
     
-    
     /**
      * Creates a proxy
-     * @param baseURI baseURI
+     * @param baseAddress baseAddress
      * @param cls proxy class, if not interface then a CGLIB proxy will be created
-     * @param config Spring configuration file location
+     * @param config classpath location of Spring configuration resource
      * @return typed proxy
      */
-    public static <T> T create(URI baseURI, Class<T> cls, String configLocation) {
-        SpringBusFactory bf = new SpringBusFactory();
-        Bus bus = bf.createBus(configLocation);
-        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
-        bean.setAddress(baseURI.toString());
-        bean.setServiceClass(cls);
-        bean.setBus(bus);
+    public static <T> T create(String baseAddress, Class<T> cls, String configLocation) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation);
         return bean.create(cls);
     }
     
+    
     /**
      * Creates a proxy
-     * @param baseURI baseURI
+     * @param baseAddress baseAddress
      * @param cls proxy class, if not interface then a CGLIB proxy will be created
-     * @param inheritHeaders if true then existing proxy headers will be inherited by 
-     *        subresource proxies if any
-     * @param direct if true then no bus and chains will be created
+     * @param providers list of providers
      * @return typed proxy
      */
-    public static <T> T create(URI baseURI, Class<T> cls, boolean inheritHeaders, boolean direct) {
-        
-        if (!direct) {
-            JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
-            bean.setAddress(baseURI.toString());
-            bean.setServiceClass(cls);
-            bean.setInheritHeaders(inheritHeaders);
-            return bean.create(cls);
-        } else {
-            boolean isRoot = AnnotationUtils.getClassAnnotation(cls, Path.class) != null;
-            ClassResourceInfo cri = ResourceUtils.createClassResourceInfo(cls, cls, isRoot, true);
-            
-            return cls.cast(ProxyHelper.getProxy(cls.getClassLoader(),
-                            new Class[]{cls, Client.class}, 
-                            new ClientProxyImpl(baseURI, baseURI, cri, inheritHeaders)));
-        }
+    public static <T> T create(String baseAddress, Class<T> cls, List<?> providers) {
+        return create(baseAddress, cls, providers, null);
+    }
+    
+    /**
+     * Creates a proxy
+     * @param baseAddress baseAddress
+     * @param cls proxy class, if not interface then a CGLIB proxy will be created
+     * @param providers list of providers
+     * @param config classpath location of Spring configuration resource
+     * @return typed proxy
+     */
+    public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, String configLocation) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation);
+        bean.setProviders(providers);
+        return bean.create(cls);
+    }
+    
+    /**
+     * Creates a proxy which will do basic authentication
+     * @param baseAddress baseAddress
+     * @param cls proxy class, if not interface then a CGLIB proxy will be created
+     * @param username username
+     * @param password password
+     * @param config classpath location of Spring configuration resource
+     * @return typed proxy
+     */
+    public static <T> T create(String baseAddress, Class<T> cls, String username,
+                               String password, String configLocation) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation);
+        bean.setUsername(username);
+        bean.setPassword(password);
+        return bean.create(cls);
     }
     
     /**
@@ -126,9 +134,6 @@
      * @return typed proxy
      */
     public static <T> T fromClient(Client client, Class<T> cls) {
-        if (cls.isAssignableFrom(client.getClass())) {
-            return cls.cast(client);
-        }
         return fromClient(client, cls, false);
     }
     
@@ -141,30 +146,25 @@
      * @return typed proxy
      */
     public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders) {
-        return fromClient(client, cls, inheritHeaders, false);
-    }
-    
-    /**
-     * Creates a proxy, baseURI will be set to Client currentURI
-     * @param client Client instance
-     * @param cls proxy class, if not interface then a CGLIB proxy will be created
-     * @param inheritHeaders if true then existing Client headers will be inherited by new proxy 
-     *        and subresource proxies if any 
-     * @param direct if true then no bus and chains will be created       
-     * @return typed proxy
-     */
-    public static <T> T fromClient(Client client, Class<T> cls, boolean inheritHeaders, boolean direct) {
         
-        T proxy = create(client.getCurrentURI(), cls, inheritHeaders, direct);
+        T proxy = create(client.getCurrentURI(), cls, inheritHeaders);
         if (inheritHeaders) {
             WebClient.client(proxy).headers(client.getHeaders());
         }
+        WebClient.copyProperties(WebClient.client(proxy), client);
         return proxy;
     }
     
     static <T> T create(Class<T> cls, InvocationHandler handler) {
         
-        return cls.cast(ProxyHelper.getProxy(cls.getClassLoader(),
-                        new Class[]{cls, Client.class}, handler));
+        return cls.cast(ProxyHelper.getProxy(cls.getClassLoader(), new Class[]{cls, Client.class}, handler));
+    }
+    
+    private static JAXRSClientFactoryBean getBean(String baseAddress, Class<?> cls, String configLocation) {
+        JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation);
+        bean.setServiceClass(cls);
+        return bean;
     }
+    
+    
 }

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -21,10 +21,12 @@
 import java.net.URI;
 import java.util.Map;
 
+import javax.ws.rs.Path;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MultivaluedMap;
 
 import org.apache.cxf.common.util.ProxyHelper;
+import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.UpfrontConduitSelector;
@@ -34,10 +36,13 @@
 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;
 
 public class JAXRSClientFactoryBean extends AbstractJAXRSFactoryBean {
     
+    private String username;
+    private String password;
     private boolean inheritHeaders; 
     private MultivaluedMap<String, String> headers;
     
@@ -51,6 +56,22 @@
         
     }
     
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+    
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+    
     public void setInheritHeaders(boolean ih) {
         inheritHeaders = ih;
     }
@@ -102,12 +123,13 @@
             Endpoint ep = createEndpoint();
             URI baseURI = URI.create(getAddress());
             ClassResourceInfo cri = serviceFactory.getClassResourceInfo().get(0);
-            
-            ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, inheritHeaders);
+            boolean isRoot = AnnotationUtils.getClassAnnotation(cri.getServiceClass(), Path.class) != null;
+            ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, isRoot, inheritHeaders);
             initClient(proxyImpl, ep);    
             
             return (Client)ProxyHelper.getProxy(cri.getServiceClass().getClassLoader(),
-                                        new Class[]{cri.getServiceClass(), Client.class}, 
+                                        new Class[]{cri.getServiceClass(), Client.class, 
+                                                    InvocationHandlerAware.class}, 
                                         proxyImpl);
         } catch (Exception ex) {
             throw new WebApplicationException();
@@ -124,6 +146,15 @@
     }
     
     protected void initClient(AbstractClient client, Endpoint ep) {
+        
+        if (username != null) {
+            AuthorizationPolicy authPolicy = new AuthorizationPolicy();
+            authPolicy.setUserName(username);
+            authPolicy.setPassword(password);
+            ep.getEndpointInfo().addExtensor(authPolicy);
+        }
+        
+        
         client.setConduitSelector(getConduitSelector(ep));
         client.setBus(getBus());
         client.setOutInterceptors(getOutInterceptors());

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -18,7 +18,6 @@
  */
 package org.apache.cxf.jaxrs.client;
 
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.lang.annotation.Annotation;
@@ -54,22 +53,116 @@
 
 public class WebClient extends AbstractClient {
     
-    public WebClient(String baseAddress) {
+    protected WebClient(String baseAddress) {
         this(URI.create(baseAddress));
     }
     
-    public WebClient(URI baseURI) {
-        super(baseURI, baseURI);
+    protected WebClient(URI baseAddress) {
+        super(baseAddress, baseAddress);
     }
     
-    public WebClient(Client client) {
-        this(client, false);
+    /**
+     * Creates WebClient
+     * @param baseAddress baseAddress
+     */
+    public static WebClient create(String baseAddress) {
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        bean.setAddress(baseAddress);
+        return bean.createWebClient();
     }
     
-    public WebClient(Client client, boolean inheritHeaders) {
-        super(client, inheritHeaders);
+    public static WebClient create(URI baseURI) {
+        return create(baseURI.toString());
     }
     
+    /**
+     * Creates WebClient
+     * @param baseURI baseURI
+     * @param providers list of providers
+     */
+    public static WebClient create(String baseAddress, List<?> providers) {
+        return create(baseAddress, providers, null);        
+    }
+    
+    /**
+     * Creates a Spring-configuration aware WebClient
+     * @param baseAddress baseAddress
+     * @param providers list of providers
+     * @param configLocation classpath location of Spring configuration resource, can be null  
+     * @return WebClient instance
+     */
+    public static WebClient create(String baseAddress, List<?> providers, String configLocation) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, configLocation);
+        bean.setProviders(providers);
+        return bean.createWebClient();
+    }
+    
+    /**
+     * Creates a Spring-configuration aware WebClient
+     * @param baseAddress baseAddress
+     * @param configLocation classpath location of Spring configuration resource, can be null  
+     * @return WebClient instance
+     */
+    public static WebClient create(String baseAddress, String configLocation) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, configLocation);
+        
+        return bean.createWebClient();
+    }
+    
+    /**
+     * Creates a Spring-configuration aware WebClient which will do basic authentication
+     * @param baseAddress baseAddress
+     * @param username username
+     * @param password password
+     * @param configLocation classpath location of Spring configuration resource, can be null  
+     * @return WebClient instance
+     */
+    public static WebClient create(String baseAddress, String username, String password, 
+                                         String configLocation) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, configLocation);
+        
+        bean.setUsername(username);
+        bean.setPassword(password);
+        
+        return bean.createWebClient();
+    }
+    
+    /**
+     * Creates WebClient, baseURI will be set to Client currentURI
+     * @param client existing client
+     */
+    public static WebClient fromClient(Client client) {
+        return fromClient(client, false);
+    }
+    
+    public static WebClient fromClient(Client client, boolean inheritHeaders) {
+        WebClient webClient = create(client.getCurrentURI());
+        if (inheritHeaders) {
+            webClient.headers(client.getHeaders());
+        }
+        copyProperties(webClient, client);
+        return webClient;
+    }
+    
+    /**
+     * Converts proxy to Client
+     * @param proxy the proxy
+     * @return proxy as a Client 
+     */
+    public static Client client(Object proxy) {
+        if (proxy instanceof Client) {
+            return (Client)proxy;
+        }
+        return null;
+    }
+    
+    /**
+     * Does HTTP invocation
+     * @param httpMethod HTTP method
+     * @param body request body, can be null
+     * @return JAXRS Response, entity may hold a string representaion of 
+     *         error message if client or server error occured
+     */
     public Response invoke(String httpMethod, Object body) {
         return doInvoke(httpMethod, body, InputStream.class);
     }
@@ -175,34 +268,6 @@
         return this;
     }
     
-    /**
-     * Converts proxy to Client
-     * @param proxy the proxy
-     * @return proxy as a Client 
-     */
-    public static Client client(Object proxy) {
-        if (proxy instanceof Client) {
-            return (Client)proxy;
-        }
-        return null;
-    }
-    
-    
-    public static WebClient createClient(String baseAddress, String configLocation) {
-        SpringBusFactory bf = new SpringBusFactory();
-        Bus bus = bf.createBus(configLocation);
-        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
-        bean.setBus(bus);
-        bean.setAddress(baseAddress);
-        return bean.createWebClient();
-    }
-    
-    public static WebClient createClient(String baseAddress) {
-        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
-        bean.setAddress(baseAddress);
-        return bean.createWebClient();
-    }
-    
     @Override
     public WebClient type(MediaType ct) {
         return (WebClient)super.type(ct);
@@ -273,7 +338,7 @@
         return (WebClient)super.reset();
     }
     
-    private Response doInvoke(String httpMethod, Object body, Class<?> responseClass) {
+    protected Response doInvoke(String httpMethod, Object body, Class<?> responseClass) {
         
         MultivaluedMap<String, String> headers = getHeaders();
         if (body != null && headers.getFirst(HttpHeaders.CONTENT_TYPE) == null) {
@@ -282,34 +347,14 @@
         if (responseClass != null && headers.getFirst(HttpHeaders.ACCEPT) == null) {
             headers.putSingle(HttpHeaders.ACCEPT, MediaType.APPLICATION_XML_TYPE.toString());
         }
-        if (conduitSelector == null) {
-            return doDirectInvocation(httpMethod, headers, body, responseClass);
-        } else {
-            return doChainedInvocation(httpMethod, headers, body, responseClass);
-        }
-    }
-
-    protected Response doDirectInvocation(String httpMethod, 
-        MultivaluedMap<String, String> headers, Object body, Class<?> responseClass) {
+        resetResponse();
+        return doChainedInvocation(httpMethod, headers, body, responseClass);
         
-        HttpURLConnection conn = getConnection(httpMethod);
-        
-        setAllHeaders(headers, conn);
-        Message message = createSimpleMessage();
-        if (body != null) {
-            try {
-                writeBody(body, message, body.getClass(), body.getClass(), 
-                      new Annotation[]{}, headers, conn.getOutputStream());
-            } catch (IOException ex) {
-                throw new WebApplicationException(ex);
-            }
-        }
-        return handleResponse(conn, message, responseClass);
     }
-    
+
     protected Response doChainedInvocation(String httpMethod, 
         MultivaluedMap<String, String> headers, Object body, Class<?> responseClass) {
-
+        
         Message m = createMessage(httpMethod, headers, getCurrentURI());
         
         if (body != null) {
@@ -372,10 +417,35 @@
             } catch (Exception ex) {
                 throw new Fault(ex);
             }
-            
         }
-        
     }
 
+    static void copyProperties(Client toClient, Client fromClient) {
+        AbstractClient newClient = toAbstractClient(toClient);
+        AbstractClient oldClient = toAbstractClient(fromClient);
+        newClient.bus = oldClient.bus;
+        newClient.conduitSelector = oldClient.conduitSelector;
+        newClient.inInterceptors = oldClient.inInterceptors;
+        newClient.outInterceptors = oldClient.outInterceptors;
+    }
+    
+    private static AbstractClient toAbstractClient(Client client) {
+        if (client instanceof AbstractClient) {
+            return (AbstractClient)client;
+        } else {
+            return (AbstractClient)((InvocationHandlerAware)client).getInvocationHandler();
+        }
+    }
     
+    static JAXRSClientFactoryBean getBean(String baseAddress, String configLocation) {
+        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
+        
+        if (configLocation != null) {
+            SpringBusFactory bf = new SpringBusFactory();
+            Bus bus = bf.createBus(configLocation);
+            bean.setBus(bus);
+        }
+        bean.setAddress(baseAddress);
+        return bean;
+    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContext.java Fri Mar 20 10:46:33 2009
@@ -36,7 +36,7 @@
 public interface MessageContext {
     
     Object get(Object key);
-    void put(Object key, Object value, boolean outbound);
+    void put(Object key, Object value);
     
     UriInfo getUriInfo();
     Request getRequest();

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java Fri Mar 20 10:46:33 2009
@@ -49,7 +49,6 @@
 public class MessageContextImpl implements MessageContext {
 
     private Message m;
-    
     public MessageContextImpl(Message m) {
         this.m = m;
     }
@@ -112,11 +111,7 @@
         return JAXRSUtils.createServletResourceValue(m, ServletContext.class);
     }
 
-    public void put(Object key, Object value, boolean outbound) {
-        if (outbound) {
-            throw new UnsupportedOperationException(
-                      "MessageContext.put() is not supported for outbound properties");
-        }
+    public void put(Object key, Object value) {
         m.put(key.toString(), value);
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/Messages.properties?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/Messages.properties (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/Messages.properties Fri Mar 20 10:46:33 2009
@@ -18,6 +18,6 @@
 #    under the License.
 #
 #
-WEB_APP_EXCEPTION=WebApplicationExceptionMapper has caught an exception {0}
+WEB_APP_EXCEPTION=WebApplicationException has been caught : {0}
 DEFAULT_EXCEPTION_MESSAGE=Internal server exception occurred. Please consult logs for more information.
 

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WebApplicationExceptionMapper.java Fri Mar 20 10:46:33 2009
@@ -38,14 +38,20 @@
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(WebApplicationExceptionMapper.class);
     
     public Response toResponse(WebApplicationException ex) {
-        if (LOG.isLoggable(Level.FINE)) {
+        if (LOG.isLoggable(Level.WARNING)) {
+            String message = ex.getCause() == null ? ex.getMessage() : ex.getCause().getMessage();
+            if (message == null) {
+                if (ex.getCause() != null) {
+                    message = "cause is " + ex.getCause().getClass().getName();
+                } else {
+                    message = "no cause is available";
+                }
+            }
             org.apache.cxf.common.i18n.Message errorMsg = 
-                new org.apache.cxf.common.i18n.Message("WEB_APP_EXCEPTION", 
-                    BUNDLE, ex.getCause() == null ? ex.getMessage() : ex.getCause().getMessage());
-            LOG.fine(errorMsg.toString());
+                new org.apache.cxf.common.i18n.Message("WEB_APP_EXCEPTION", BUNDLE, message);
+            LOG.warning(errorMsg.toString());
         }
-         
-        Response r = ex.getResponse();
+        Response r = ex.getResponse(); 
         if (r == null) {
             String message = null;
             if (ex.getCause() == null) {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/tl/ThreadLocalMessageContext.java Fri Mar 20 10:46:33 2009
@@ -37,7 +37,7 @@
     public Object get(Object key) {
         return get() != null ? get().get(key) : null;
     }
-
+    
     public <T> T getContext(Class<T> contextClass) {
         return get() != null ? get().getContext(contextClass) : null;
     }
@@ -78,12 +78,11 @@
         return get() != null ? get().getRequest() : null;
     }
 
-    public void put(Object key, Object value, boolean outbound) {
+    public void put(Object key, Object value) {
         if (get() != null) {
-            get().put(key, value, outbound);
+            get().put(key, value);
         }
         throw new IllegalStateException("MessageContext is not set");
-        
     }
 
     public <T, E> T getResolver(Class<T> resolverClass, Class<E> resolveClazz) {

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -119,7 +119,7 @@
                 new org.apache.cxf.common.i18n.Message("NO_ROOT_EXC", 
                                                    BUNDLE, 
                                                    rawPath);
-            LOG.severe(errorMsg.toString());
+            LOG.warning(errorMsg.toString());
 
             throw new WebApplicationException(Response.Status.NOT_FOUND);
         }

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -25,6 +25,7 @@
 import java.lang.reflect.Method;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
@@ -32,21 +33,27 @@
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.ext.MessageBodyWriter;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.stream.events.XMLEvent;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor;
+import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.jaxrs.ext.ResponseHandler;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 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;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageContentsList;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.CachingXmlEventWriter;
+import org.apache.cxf.staxutils.StaxUtils;
 
 public class JAXRSOutInterceptor extends AbstractOutDatabindingInterceptor {
     private static final Logger LOG = LogUtils.getL7dLogger(JAXRSOutInterceptor.class);
@@ -116,18 +123,27 @@
                                   String baseAddress,
                                   boolean firstTry) {
         message.put(Message.RESPONSE_CODE, response.getStatus());
-        message.put(Message.PROTOCOL_HEADERS, response.getMetadata());
-                        
+        Map<String, List<String>> theHeaders = 
+            (Map<String, List<String>>)message.get(Message.PROTOCOL_HEADERS);
+        if (firstTry && theHeaders != null) {
+            // some headers might've been setup by custom cxf interceptors
+            theHeaders.putAll((Map)response.getMetadata());
+        } else {
+            message.put(Message.PROTOCOL_HEADERS, response.getMetadata());
+        }
+        
         Object responseObj = response.getEntity();
         if (responseObj == null) {
             return;
         }
         
         Class targetType = responseObj.getClass();
-        List<MediaType> availableContentTypes = 
-            computeAvailableContentTypes(message, response);  
+        List<MediaType> availableContentTypes = computeAvailableContentTypes(message, response);  
         
-        Method invoked = ori == null ? null : ori.getMethodToInvoke();
+        Method invoked = null;
+        if (firstTry) {
+            invoked = ori == null ? null : ori.getMethodToInvoke();
+        }
         
         MessageBodyWriter writer = null;
         MediaType responseType = null;
@@ -137,7 +153,7 @@
                       invoked != null ? invoked.getGenericReturnType() : null, 
                       invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
                       type,
-                      message.getExchange().getInMessage());
+                      message);
             
             if (writer != null) {
                 responseType = type;
@@ -145,15 +161,13 @@
             }
         }
     
-        OutputStream out = message.getContent(OutputStream.class);
+        OutputStream outOriginal = message.getContent(OutputStream.class);
         if (writer == null) {
             message.put(Message.RESPONSE_CODE, 500);
-            writeResponseErrorMessage(out, 
-                  "NO_MSG_WRITER",
-                  invoked != null ? invoked.getReturnType().getSimpleName() : "");
+            writeResponseErrorMessage(outOriginal, "NO_MSG_WRITER", targetType.getSimpleName());
             return;
         }
-        
+        boolean enabled = checkBufferingMode(message, writer, firstTry);
         try {
             
             responseType = checkFinalContentType(responseType);
@@ -161,24 +175,80 @@
             message.put(Message.CONTENT_TYPE, responseType.toString());
             
             LOG.fine("Response EntityProvider is: " + writer.getClass().getName());
-            writer.writeTo(responseObj, targetType, invoked.getGenericReturnType(), 
-                           invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
-                           responseType, 
-                           response.getMetadata(), 
-                           out);
+            try {
+                writer.writeTo(responseObj, targetType, 
+                               invoked != null ? invoked.getGenericReturnType() : null, 
+                               invoked != null ? invoked.getAnnotations() : new Annotation[]{}, 
+                               responseType, 
+                               response.getMetadata(), 
+                               message.getContent(OutputStream.class));
+                checkCachedStream(message, outOriginal, enabled);
+            } finally {
+                if (enabled) {
+                    message.setContent(OutputStream.class, outOriginal);
+                    message.put(XMLStreamWriter.class.getName(), null);
+                }
+            }
             
         } catch (IOException ex) {
             handleWriteException(message, response, ori, baseAddress, ex, responseObj, firstTry);
-        } catch (Exception ex) {
+        } catch (Throwable ex) {
             handleWriteException(message, response, ori, baseAddress, ex, responseObj, firstTry);
         }
     }
     
+    private boolean checkBufferingMode(Message m, MessageBodyWriter w, boolean firstTry) {
+        if (!firstTry) {
+            return false;
+        }
+        Object outBuf = m.getContextualProperty(OUT_BUFFERING);
+        boolean enabled = Boolean.TRUE.equals(outBuf) || "true".equals(outBuf);
+        if (!enabled && outBuf == null) {
+            enabled = InjectionUtils.invokeBooleanGetter(w, "getEnableBuffering");
+        }
+        if (enabled) {
+            boolean streamingOn = 
+                "org.apache.cxf.jaxrs.provider.JAXBElementProvider".equals(w.getClass().getName())
+                && InjectionUtils.invokeBooleanGetter(w, "getEnableStreaming");
+            if (streamingOn) {
+                m.put(XMLStreamWriter.class.getName(), new CachingXmlEventWriter());
+            } else {
+                m.setContent(OutputStream.class, new CachedOutputStream());
+            }
+        }
+        return enabled;
+    }
+    
+    private void checkCachedStream(Message m, OutputStream osOriginal, boolean enabled) throws Exception {
+        if (!enabled) {
+            return;
+        }
+        XMLStreamWriter writer = (XMLStreamWriter)m.get(XMLStreamWriter.class.getName());
+        if (writer instanceof CachingXmlEventWriter) {
+            CachingXmlEventWriter cache = (CachingXmlEventWriter)writer;
+            if (cache.getEvents().size() != 0) {
+                XMLStreamWriter origWriter = StaxUtils.createXMLStreamWriter(osOriginal);
+                for (XMLEvent event : cache.getEvents()) {
+                    StaxUtils.writeEvent(event, origWriter);
+                }
+            }
+            m.put(XMLStreamWriter.class.getName(), null);
+            return;
+        }
+        OutputStream os = m.getContent(OutputStream.class);
+        if (os != osOriginal && os instanceof CachedOutputStream) {
+            CachedOutputStream cos = (CachedOutputStream)os;
+            if (cos.size() != 0) {
+                cos.writeCacheTo(osOriginal);
+            }
+        }
+    }
+    
     private void handleWriteException(Message message, 
                                          Response response, 
                                          OperationResourceInfo ori,
                                          String baseAddress,
-                                         Exception ex,
+                                         Throwable ex,
                                          Object responseObj,
                                          boolean firstTry) {
         OutputStream out = message.getContent(OutputStream.class);
@@ -218,7 +288,7 @@
         List<MediaType> produceTypes = null;
         OperationResourceInfo operation = exchange.get(OperationResourceInfo.class);
         if (contentType != null) {
-            produceTypes = Collections.singletonList(MediaType.valueOf(contentType.toString()));
+            return Collections.singletonList(MediaType.valueOf(contentType.toString()));
         } else if (operation != null) {
             produceTypes = operation.getProduceTypes();
         } else {

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractConfigurableProvider.java Fri Mar 20 10:46:33 2009
@@ -25,8 +25,9 @@
 
     private List<String> consumeMediaTypes;
     private List<String> produceMediaTypes;
+    private boolean enableBuffering;
     
-    protected void setConsumeMediaTypes(List<String> types) {
+    public void setConsumeMediaTypes(List<String> types) {
         consumeMediaTypes = types;
     }
     
@@ -34,11 +35,19 @@
         return consumeMediaTypes;    
     }
     
-    protected void setProduceMediaTypes(List<String> types) {
+    public void setProduceMediaTypes(List<String> types) {
         produceMediaTypes = types;
     }
     
     public List<String> getProduceMediaTypes() {
         return produceMediaTypes;    
     }
+    
+    public void setEnableBuffering(boolean enableBuf) {
+        enableBuffering = enableBuf;
+    }
+    
+    public boolean getEnableBuffering() {
+        return enableBuffering;
+    }
 }

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=756410&r1=756409&r2=756410&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 Fri Mar 20 10:46:33 2009
@@ -161,7 +161,6 @@
         // TODO: still not checked : 
         // - XmlJavaTypeAdapter at package level
         // - anything else ?
-        
         return type.getAnnotation(XmlRootElement.class) != null
             || JAXBElement.class.isAssignableFrom(type)
             || objectFactoryForClass(type)
@@ -277,6 +276,7 @@
             ? e.getLinkedException() : e.getCause() != null ? e.getCause() : e;
         String message = new org.apache.cxf.common.i18n.Message("JAXB_EXCEPTION", 
                              BUNDLE, t.getMessage()).toString();
+        LOG.warning(message);
         Response r = Response.status(Response.Status.INTERNAL_SERVER_ERROR)
             .type(MediaType.TEXT_PLAIN).entity(message).build();
         throw new WebApplicationException(t, r);

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/BinaryDataProvider.java Fri Mar 20 10:46:33 2009
@@ -40,7 +40,7 @@
 
 import org.apache.cxf.helpers.IOUtils;
 
-public class BinaryDataProvider 
+public class BinaryDataProvider extends AbstractConfigurableProvider 
     implements MessageBodyReader<Object>, MessageBodyWriter<Object> {
     
     private static final int BUFFER_SIZE = 4096;

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=756410&r1=756409&r2=756410&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 Fri Mar 20 10:46:33 2009
@@ -39,10 +39,12 @@
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.utils.schemas.SchemaHandler;
+import org.apache.cxf.staxutils.StaxUtils;
 
 @ProduceMime({"application/xml", "text/xml" })
 @ConsumeMime({"application/xml", "text/xml" })
@@ -50,12 +52,25 @@
 public class JAXBElementProvider extends AbstractJAXBProvider  {
     
     private Map<String, Object> mProperties = new HashMap<String, Object>();
+    private boolean enableStreaming;
     
     @Context
     public void setMessageContext(MessageContext mc) {
         super.setContext(mc);
     }
     
+    public void setEnableStreaming(boolean enableStream) {
+        enableStreaming = enableStream; 
+    }
+    
+    public boolean getEnableStreaming() {
+        return enableStreaming;
+    }
+    
+    public void setEnableBuffering(boolean enableBuf) {
+        super.setEnableBuffering(enableBuf);
+    }
+    
     public void setConsumeMediaTypes(List<String> types) {
         super.setConsumeMediaTypes(types);
     }
@@ -121,10 +136,19 @@
             for (Map.Entry<String, Object> entry : mProperties.entrySet()) {
                 ms.setProperty(entry.getKey(), entry.getValue());
             }
-            ms.marshal(actualObject, os);
+            if (enableStreaming) {
+                XMLStreamWriter writer = 
+                    (XMLStreamWriter)getContext().get(XMLStreamWriter.class.getName());
+                if (writer == null) {
+                    writer = StaxUtils.createXMLStreamWriter(os);
+                }
+                ms.marshal(actualObject, writer);
+            } else {
+                ms.marshal(actualObject, os);
+            }
             
         } catch (JAXBException e) {
-            throw new WebApplicationException(e);
+            handleJAXBException(e);
         }  catch (WebApplicationException e) {
             throw e;
         } catch (Exception e) {

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=756410&r1=756409&r2=756410&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 Fri Mar 20 10:46:33 2009
@@ -70,6 +70,10 @@
         super.setContext(mc);
     }
     
+    public void setEnableBuffering(boolean enableBuf) {
+        super.setEnableBuffering(enableBuf);
+    }
+    
     public void setConsumeMediaTypes(List<String> types) {
         super.setConsumeMediaTypes(types);
     }
@@ -163,7 +167,7 @@
             xsw.close();
             
         } catch (JAXBException e) {
-            throw new WebApplicationException(e);
+            handleJAXBException(e);
         } catch (XMLStreamException e) {
             throw new WebApplicationException(e);
         } catch (Exception e) {

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -25,6 +25,8 @@
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.ProduceMime;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedMap;
@@ -44,6 +46,8 @@
 import org.w3c.dom.Document;
 
 @Provider
+@ProduceMime({"application/xml", "text/xml" })
+@ConsumeMime({"application/xml", "text/xml" })
 public class SourceProvider implements 
     MessageBodyReader<Object>, MessageBodyWriter<Source> {
 

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -87,6 +87,16 @@
         
     }
 
+    public static boolean invokeBooleanGetter(Object o, String name) {
+        try {
+            Method method = o.getClass().getMethod(name, new Class[]{});
+            return (Boolean)method.invoke(o, new Object[]{});
+        } catch (Exception ex) {
+            LOG.finest("Can not invoke method " + name + " on object of class " + o.getClass().getName());
+        }
+        return false;
+    }
+    
     public static Method checkProxy(Method methodToInvoke, Object resourceObject) {
         if (Proxy.class.isInstance(resourceObject)) {
             for (Class<?> c : resourceObject.getClass().getInterfaces()) {

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=756410&r1=756409&r2=756410&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 10:46:33 2009
@@ -300,7 +300,7 @@
                                                    path,
                                                    requestType.toString(),
                                                    convertTypesToString(acceptContentTypes));
-        LOG.severe(errorMsg.toString());
+        LOG.warning(errorMsg.toString());
         
         throw new WebApplicationException(status);
         
@@ -582,24 +582,28 @@
     
     public static <T> T createContextValue(Message m, Type genericType, Class<T> clazz) {
  
+        Message contextMessage = m.getExchange() != null ? m.getExchange().getInMessage() : m;
+        if (contextMessage == null && Boolean.FALSE.equals(m.get(Message.INBOUND_MESSAGE))) { 
+            contextMessage = m;
+        }
         Object o = null;
         if (UriInfo.class.isAssignableFrom(clazz)) {
-            o = createUriInfo(m);
+            o = createUriInfo(contextMessage);
         } else if (HttpHeaders.class.isAssignableFrom(clazz)) {
-            o = new HttpHeadersImpl(m);
+            o = new HttpHeadersImpl(contextMessage);
         } else if (Request.class.isAssignableFrom(clazz)) {
-            o = new RequestImpl(m);
+            o = new RequestImpl(contextMessage);
         } else if (SecurityContext.class.isAssignableFrom(clazz)) {
-            o = new SecurityContextImpl(m);
+            o = new SecurityContextImpl(contextMessage);
         } else if (MessageBodyWorkers.class.isAssignableFrom(clazz)) {
-            o = new ProvidersImpl(m);
+            o = new ProvidersImpl(contextMessage);
         } else if (ContextResolver.class.isAssignableFrom(clazz)) {
-            o = createContextResolver(genericType, m);
+            o = createContextResolver(genericType, contextMessage);
         } else if (MessageContext.class.isAssignableFrom(clazz)) {
             o = new MessageContextImpl(m);
         }
         
-        o = o == null ? createServletResourceValue(m, clazz) : o;
+        o = o == null ? createServletResourceValue(contextMessage, clazz) : o;
         return clazz.cast(o);
     }
     
@@ -761,14 +765,18 @@
                                           + targetTypeClass.getSimpleName() 
                                            + ", content type : " + contentType;
                     LOG.severe(errorMessage);
-                    throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
-                }    
+                    throw new WebApplicationException(e);
+                } catch (WebApplicationException ex) {
+                    throw ex;
+                } catch (Exception ex) {
+                    throw new WebApplicationException(ex);
+                }
             } else {
                 String errorMessage = new org.apache.cxf.common.i18n.Message("NO_MSG_READER",
                                                        BUNDLE,
                                                        targetTypeClass.getSimpleName(),
                                                        contentType).toString();
-                LOG.severe(errorMessage);
+                LOG.warning(errorMessage);
                 throw new WebApplicationException(Response.Status.UNSUPPORTED_MEDIA_TYPE);
             }
         }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java Fri Mar 20 10:46:33 2009
@@ -72,8 +72,10 @@
                     if (enableStatic) {
                         ClassResourceInfo subCri = cri.findResource(subClass, subClass);
                         if (subCri == null) {
-                            subCri = createClassResourceInfo(subClass, subClass, false, enableStatic);
+                            subCri = subClass == cri.getServiceClass() ? cri
+                                     : createClassResourceInfo(subClass, subClass, false, enableStatic);
                         }
+                        
                         if (subCri != null) {
                             cri.addSubClassResourceInfo(subCri);
                         }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/multipart/AttachmentUtils.java Fri Mar 20 10:46:33 2009
@@ -73,10 +73,10 @@
     public static MultipartBody getMultipartBody(MessageContext mc,
         String attachmentDir, String attachmentThreshold) {
         if (attachmentDir != null) {
-            mc.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY, attachmentDir, false);
+            mc.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY, attachmentDir);
         }
         if (attachmentThreshold != null) {
-            mc.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD, attachmentThreshold, false);
+            mc.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD, attachmentThreshold);
         }
         return (MultipartBody)mc.get(MultipartBody.INBOUND_MESSAGE_ATTACHMENTS);
     }

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=756410&r1=756409&r2=756410&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Fri Mar 20 10:46:33 2009
@@ -87,6 +87,8 @@
           <xsd:attribute name="serviceClass" type="xsd:string"/>
           <xsd:attribute name="inheritHeaders" type="xsd:boolean"/>
           <xsd:attribute name="bus" type="xsd:string" />
+          <xsd:attribute name="username" type="xsd:string"/>
+          <xsd:attribute name="password" type="xsd:string"/>
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>



Mime
View raw message