cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r756446 - 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/client/ rt/frontend/jaxrs/src/main...
Date Fri, 20 Mar 2009 13:25:27 GMT
Author: sergeyb
Date: Fri Mar 20 13:25:25 2009
New Revision: 756446

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

........
  r753274 | sergeyb | 2009-03-13 14:05:49 +0000 (Fri, 13 Mar 2009) | 1 line
  
  JAXRS : support for proxies with root classes containing template variables
........
  r753333 | sergeyb | 2009-03-13 18:02:21 +0000 (Fri, 13 Mar 2009) | 1 line
  
  JAXRS : enhancing XMLSource, adding omitted JAXRSClientFactoryBeanTest
........

Added:
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
      - copied, changed from r753274, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/XMLSource.java
      - copied unchanged from r753333, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/XMLSource.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
      - copied unchanged from r753333, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBeanTest.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreSubresourcesOnly.java
      - copied unchanged from r753274, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/resources/BookStoreSubresourcesOnly.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/XMLSourceTest.java
      - copied unchanged from r753333, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/utils/XMLSourceTest.java
Removed:
    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/provider/ActivationProvider.java
    cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/XMLSourceTest.java
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/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/provider/AbstractJAXBProvider.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/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
    cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/Chapter.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 13:25:25 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,752520,752558,752613,752680,752728,752753,752849,752880-752881,752883,752961,752970,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,753274,753293,753333,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 13:25:25 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,752520,752970,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,753274,753333,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 13:25:25 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,752520,752970,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,753274,753333,755514,755806

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=756446&r1=756445&r2=756446&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 13:25:25 2009
@@ -24,9 +24,12 @@
 import java.lang.reflect.Method;
 import java.net.HttpURLConnection;
 import java.net.URI;
-import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.logging.Logger;
 
@@ -67,15 +70,42 @@
     private ClassResourceInfo cri;
     private boolean inheritHeaders;
     private boolean isRoot;
+    private Map<String, Object> valuesMap;
     
     public ClientProxyImpl(URI baseURI, URI currentURI, ClassResourceInfo cri, boolean isRoot,

-                           boolean inheritHeaders) {
+                           boolean inheritHeaders, Object... varValues) {
         super(baseURI, currentURI);
         this.cri = cri;
         this.isRoot = isRoot;
         this.inheritHeaders = inheritHeaders;
+        initValuesMap(varValues);
     }
     
+    private void initValuesMap(Object... varValues) {
+        if (isRoot && varValues.length != 0) {
+            valuesMap = new LinkedHashMap<String, Object>();
+            List<String> vars = cri.getURITemplate().getVariables();
+            for (int i = 0; i < vars.size(); i++) {
+                if (i < varValues.length) {
+                    valuesMap.put(vars.get(i), varValues[i]);
+                } else {
+                    org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(
+                         "ROOT_VARS_MISMATCH", BUNDLE, vars.size(), varValues.length);
+                    LOG.info(msg.toString());
+                    break;
+                }
+            }
+        } else {
+            valuesMap = Collections.emptyMap();
+        }
+    }
+    
+    /**
+     * Updates the current state if Client method is invoked, otherwise 
+     * does the remote invocation or returns a new proxy if subresource 
+     * method is invoked. Can throw an expected exception if ResponseExceptionMapper
+     * is registered     
+     */
     public Object invoke(Object o, Method m, Object[] params) throws Throwable {
         
         Class<?> declaringClass = m.getDeclaringClass();
@@ -91,7 +121,7 @@
         
         MultivaluedMap<ParameterType, Parameter> types = 
             getParametersInfo(ori, m, params);
-        List<Object> pathParams = getParamValues(types, params, ParameterType.PATH);
+        List<Object> pathParams = getPathParamValues(types, params, ori);
         
         int bodyIndex = getBodyIndex(types, ori);
         
@@ -232,12 +262,32 @@
         return headers;
     }
     
-    private static List<Object> getParamValues(MultivaluedMap<ParameterType, Parameter>
map, 
-                                               Object[] params, ParameterType key) {
-        List<Parameter> indexList =  getParameters(map, key);
-        List<Object> list = new ArrayList<Object>(indexList.size());
-        for (Parameter p : indexList) {
-            list.add(params[p.getIndex()].toString());
+    private List<Object> getPathParamValues(MultivaluedMap<ParameterType, Parameter>
map,
+                                            Object[] params,
+                                            OperationResourceInfo ori) {
+        List<Parameter> paramsList =  getParameters(map, ParameterType.PATH);
+        List<Object> list = new LinkedList<Object>();
+        if (isRoot) {
+            list.addAll(valuesMap.values());
+        }
+        List<String> vars = ori.getURITemplate().getVariables();
+        // TODO : unfortunately, UriBuilder will lose a method-scoped parameter 
+        // if a same name variable exists in a class scope which is an api bug.
+        // It's a rare case but we might want just to use UriBuilderImpl() directly 
+        // on the client side and tell it to choose the last variable value
+        for (Parameter p : paramsList) {
+            if (valuesMap.containsKey(p.getValue()) && !vars.contains(p.getValue()))
{
+                int index = 0; 
+                for (Iterator<String> it = valuesMap.keySet().iterator(); it.hasNext();
index++) {
+                    if (it.next().equals(p.getValue())) {
+                        list.remove(index);
+                        list.add(index, params[p.getIndex()]);
+                        break;
+                    }
+                }
+            } else {
+                list.add(params[p.getIndex()]);
+            }
         }
         return list;
     }

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=756446&r1=756445&r2=756446&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 13:25:25 2009
@@ -22,8 +22,6 @@
 import java.net.URI;
 import java.util.List;
 
-import javax.ws.rs.core.MediaType;
-
 import org.apache.cxf.common.util.ProxyHelper;
 
 public final class JAXRSClientFactory {
@@ -32,10 +30,22 @@
         
     }
     
+    /**
+     * Creates a proxy
+     * @param baseAddress baseAddress
+     * @param cls resource class, if not interface then a CGLIB proxy will be created
+     * @return typed proxy
+     */
     public static <T> T create(String baseAddress, Class<T> cls) {
         return create(URI.create(baseAddress), cls);
     }
     
+    /**
+     * Creates a proxy
+     * @param baseURI baseURI
+     * @param cls resource class, if not interface then a CGLIB proxy will be created
+     * @return typed proxy
+     */
     public static <T> T create(URI baseURI, Class<T> cls) {
         return create(baseURI, cls, false);
     }
@@ -43,7 +53,7 @@
     /**
      * Creates a proxy
      * @param baseURI baseURI
-     * @param cls proxy class, if not interface then a CGLIB proxy will be created
+     * @param cls resource 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
      * @return typed proxy
@@ -59,7 +69,7 @@
     /**
      * Creates a proxy
      * @param baseAddress baseAddress
-     * @param cls proxy class, if not interface then a CGLIB proxy will be created
+     * @param cls resource class, if not interface then a CGLIB proxy will be created
      * @param config classpath location of Spring configuration resource
      * @return typed proxy
      */
@@ -68,6 +78,22 @@
         return bean.create(cls);
     }
     
+    /**
+     * Creates a proxy
+     * @param baseAddress baseAddress
+     * @param cls resource class, if not interface then a CGLIB proxy will be created
+     *        This class is expected to have a root JAXRS Path annotation containing
+     *        template variables, for ex, "/path/{id1}/{id2}"  
+     * @param config classpath location of Spring configuration resource
+     * @param varValues values to replace root Path template variables   
+     * @return typed proxy
+     */
+    public static <T> T create(String baseAddress, Class<T> cls, String configLocation,

+                               Object... varValues) {
+        JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation);
+        return bean.create(cls, varValues);
+    }
+    
     
     /**
      * Creates a proxy
@@ -112,21 +138,6 @@
     }
     
     /**
-     * Creates a proxy
-     * @param baseAddress baseAddress
-     * @param cls proxy class, if not interface then a CGLIB proxy will be created
-     * @param contentType JAXRS MediaType representing HTTP Content-Type header, can be null
-     * @param acceptTypes JAXRS MediaTypes representing HTTP Accept header, can be null
-     * @return typed proxy
-     */
-    public static <T> T create(String baseAddress, Class<T> cls, MediaType contentType,

-                               MediaType... acceptTypes) {
-        T proxy = create(baseAddress, cls);
-        WebClient.client(proxy).type(contentType).accept(acceptTypes);
-        return proxy;
-    }
-    
-    /**
      * Creates a proxy, baseURI will be set to Client currentURI
      *   
      * @param client Client instance

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=756446&r1=756445&r2=756446&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 13:25:25 2009
@@ -111,11 +111,15 @@
         }
     }
     
-    public <T> T create(Class<T> cls) {
-        return cls.cast(create());
+    public <T> T create(Class<T> cls, Object... varValues) {
+        return cls.cast(createWithValues(varValues));
     }
     
-    public Client create() {
+    public Client create() { 
+        return createWithValues();
+    }
+    
+    public Client createWithValues(Object... varValues) {
         checkResources();
         
         try {
@@ -123,7 +127,8 @@
             URI baseURI = URI.create(getAddress());
             ClassResourceInfo cri = serviceFactory.getClassResourceInfo().get(0);
             boolean isRoot = AnnotationUtils.getClassAnnotation(cri.getServiceClass(), Path.class)
!= null;
-            ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, isRoot,
inheritHeaders);
+            ClientProxyImpl proxyImpl = new ClientProxyImpl(baseURI, baseURI, cri, isRoot,
inheritHeaders,
+                                                            varValues);
             initClient(proxyImpl, ep);    
             
             return (Client)ProxyHelper.getProxy(cri.getServiceClass().getClassLoader(),

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=756446&r1=756445&r2=756446&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 13:25:25 2009
@@ -122,7 +122,8 @@
         return context != null ? context : getClassContext(type);
     }
     
-    private JAXBContext getClassContext(Class<?> type) throws JAXBException {
+    // TODO : move this method to a dedicated JAXBContextRegistry class
+    public JAXBContext getClassContext(Class<?> type) throws JAXBException {
         synchronized (classContexts) {
             JAXBContext context = classContexts.get(type);
             if (context == null) {
@@ -133,7 +134,8 @@
         }
     }
     
-    protected JAXBContext getPackageContext(Class<?> type) {
+    //  TODO : move this method to a dedicated JAXBContextRegistry class
+    public JAXBContext getPackageContext(Class<?> type) {
         if (type == null) {
             return null;
         }

Copied: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
(from r753274, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java?p2=cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java&r1=753274&r2=756446&rev=756446&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/MultipartProvider.java
Fri Mar 20 13:25:25 2009
@@ -28,7 +28,7 @@
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
-import javax.ws.rs.Consumes;
+import javax.ws.rs.ConsumeMime;
 import javax.ws.rs.WebApplicationException;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.MediaType;
@@ -43,7 +43,7 @@
 import org.apache.cxf.jaxrs.utils.multipart.AttachmentUtils;
 
 @Provider
-@Consumes({"multipart/related", "multipart/mixed", "multipart/alternative" })
+@ConsumeMime({"multipart/related", "multipart/mixed", "multipart/alternative" })
 public class MultipartProvider implements MessageBodyReader<Object> {
 
     @Context
@@ -59,11 +59,10 @@
         attachmentThreshold = threshold;
     }
     
-    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,

-                              MediaType mt) {
+    public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations)
{
         if (DataHandler.class.isAssignableFrom(type) || DataSource.class.isAssignableFrom(type)
             || Attachment.class.isAssignableFrom(type) || MultipartBody.class.isAssignableFrom(type)
-            || mediaTypeSupported(mt)) {
+            || mediaTypeSupported()) {
             return true;
         }
         return false;
@@ -118,7 +117,11 @@
         return null;
     }
     
-    private boolean mediaTypeSupported(MediaType mt) {
+    private boolean mediaTypeSupported() {
+        if (mc == null) {
+            return false;
+        }
+        MediaType mt = mc.getHttpHeaders().getMediaType();
         return mt.getType().equals("multipart") && (mt.getSubtype().equals("related")

             || mt.getSubtype().equals("mixed") || mt.getSubtype().equals("alternative"));
     }

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=756446&r1=756445&r2=756446&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 13:25:25 2009
@@ -28,6 +28,7 @@
 import java.util.Comparator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.logging.Logger;
 
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.ContextResolver;
@@ -35,6 +36,7 @@
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
 import org.apache.cxf.jaxrs.ext.ParameterHandler;
@@ -49,17 +51,26 @@
 import org.apache.cxf.message.Message;
 
 public final class ProviderFactory {
-    
+    private static final Logger LOG = LogUtils.getL7dLogger(ProviderFactory.class);
     private static final ProviderFactory SHARED_FACTORY = new ProviderFactory();
     
     static {
+        // TODO : do dynamic instantiation of JSON and few other default providers
+        JSONProvider jsonProvider = null;
+        try {
+            jsonProvider = new JSONProvider();
+        } catch (Throwable ex) {
+            ex.printStackTrace();
+            LOG.fine("Problem with instantiating the default JSON provider");
+        }
+        
         SHARED_FACTORY.setProviders(new JAXBElementProvider(),
-                                    new JSONProvider(),
+                                    jsonProvider,
                                     new BinaryDataProvider(),
                                     new SourceProvider(),
                                     new FormEncodingProvider(),
                                     new PrimitiveTextProvider(),
-                                    new ActivationProvider(),
+                                    new MultipartProvider(),
                                     new WebApplicationExceptionMapper(),
                                     new SystemQueryHandler());
     }
@@ -271,6 +282,9 @@
     private void setProviders(Object... providers) {
         
         for (Object o : providers) {
+            if (o == null) {
+                continue;
+            }
             if (MessageBodyReader.class.isAssignableFrom(o.getClass())) {
                 messageReaders.add(new ProviderInfo<MessageBodyReader>((MessageBodyReader)o));

             }

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=756446&r1=756445&r2=756446&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 13:25:25 2009
@@ -45,7 +45,7 @@
 
 import org.w3c.dom.Document;
 
-import org.apache.cxf.jaxrs.client.XMLSource;
+import org.apache.cxf.jaxrs.utils.XMLSource;
 
 @Provider
 @ProduceMime({"application/xml", "text/xml" })

Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java?rev=756446&r1=756445&r2=756446&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
(original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBeanTest.java
Fri Mar 20 13:25:25 2009
@@ -28,6 +28,7 @@
 import org.apache.cxf.jaxrs.model.MethodDispatcher;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
 import org.apache.cxf.jaxrs.model.URITemplate;
+
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -69,6 +70,16 @@
     }
 
     @Test
+    public void testSubresourcesOnlyDynamicResolution() throws Exception {
+        JAXRSServiceFactoryBean sf = new JAXRSServiceFactoryBean();
+        sf.setResourceClasses(org.apache.cxf.jaxrs.resources.BookStoreSubresourcesOnly.class);
+        sf.create();
+        
+        List<ClassResourceInfo> resources = ((JAXRSServiceImpl)sf.getService()).getClassResourceInfos();
+        assertEquals(1, resources.size());
+    }
+    
+    @Test
     public void testSubResources() throws Exception {
         JAXRSServiceFactoryBean sf = new JAXRSServiceFactoryBean();
         sf.setEnableStaticResolution(true);

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/Chapter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/Chapter.java?rev=756446&r1=756445&r2=756446&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/Chapter.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/Chapter.java
Fri Mar 20 13:25:25 2009
@@ -61,6 +61,11 @@
         return this;
     }
     
+    @Path("/recurse2")
+    public Chapter getItself2() {
+        return this;
+    }
+    
     @GET
     @ProduceMime("application/xml;charset=ISO-8859-1")
     public Chapter get() {

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java?rev=756446&r1=756445&r2=756446&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
Fri Mar 20 13:25:25 2009
@@ -359,6 +359,9 @@
         getAndCompareAsStrings("http://localhost:9080/bookstore/booksubresource/123/chapters/sub/1/recurse",
                                "resources/expected_get_chapter1_utf.txt",
                                "application/xml", 200);
+        getAndCompareAsStrings("http://localhost:9080/bookstore/booksubresource/123/chapters/sub/1/recurse2",
+                               "resources/expected_get_chapter1.txt",
+                               "application/xml", 200);
     }
     
     @Test

Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=756446&r1=756445&r2=756446&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
(original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
Fri Mar 20 13:25:25 2009
@@ -44,9 +44,9 @@
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.ResponseExceptionMapper;
 import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.client.XMLSource;
 import org.apache.cxf.jaxrs.ext.form.Form;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
+import org.apache.cxf.jaxrs.utils.XMLSource;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;



Mime
View raw message