Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CAB53C997 for ; Tue, 29 May 2012 07:01:37 +0000 (UTC) Received: (qmail 46323 invoked by uid 500); 29 May 2012 07:01:37 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 46205 invoked by uid 500); 29 May 2012 07:01:36 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 46051 invoked by uid 99); 29 May 2012 07:01:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2012 07:01:35 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2012 07:01:30 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DD7962388860; Tue, 29 May 2012 07:01:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1343558 - in /cxf/branches/2.4.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java Date: Tue, 29 May 2012 07:01:08 -0000 To: commits@cxf.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120529070108.DD7962388860@eris.apache.org> Author: ningjiang Date: Tue May 29 07:01:08 2012 New Revision: 1343558 URL: http://svn.apache.org/viewvc?rev=1343558&view=rev Log: Merged revisions 1343449 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.5.x-fixes ................ r1343449 | ningjiang | 2012-05-29 09:47:59 +0800 (Tue, 29 May 2012) | 9 lines Merged revisions 1343446 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1343446 | ningjiang | 2012-05-29 09:39:02 +0800 (Tue, 29 May 2012) | 1 line CXF-4345 Allow user-secified feautres for JAXRSClientFactory ........ ................ Modified: cxf/branches/2.4.x-fixes/ (props changed) cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Tue May 29 07:01:08 2012 @@ -0,0 +1,2 @@ +/cxf/branches/2.5.x-fixes:1343449 +/cxf/trunk:1343446 Propchange: cxf/branches/2.4.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java URL: http://svn.apache.org/viewvc/cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java?rev=1343558&r1=1343557&r2=1343558&view=diff ============================================================================== --- cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java (original) +++ cxf/branches/2.4.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java Tue May 29 07:01:08 2012 @@ -26,6 +26,7 @@ import java.util.List; import javax.ws.rs.core.MultivaluedMap; import org.apache.cxf.common.util.ProxyHelper; +import org.apache.cxf.feature.AbstractFeature; import org.apache.cxf.jaxrs.model.UserResource; /** @@ -67,18 +68,30 @@ public final class JAXRSClientFactory { * @return typed proxy */ public static T create(URI baseURI, Class cls, boolean inheritHeaders) { - + return create(baseURI, cls, inheritHeaders, null); + } + + /** + * Creates a proxy + * @param baseURI baseURI + * @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 + * @param features, the features which will be applied to the client + * @return typed proxy + */ + public static T create(URI baseURI, Class cls, boolean inheritHeaders, List features) { JAXRSClientFactoryBean bean = getBean(baseURI.toString(), cls, null); bean.setInheritHeaders(inheritHeaders); + bean.setFeatures(features); return bean.create(cls); - } /** * Creates a proxy * @param baseAddress baseAddress * @param cls resource class, if not interface then a CGLIB proxy will be created - * @param config classpath location of Spring configuration resource + * @param configLocation classpath location of Spring configuration resource * @return typed proxy */ public static T create(String baseAddress, Class cls, String configLocation) { @@ -90,9 +103,42 @@ public final class JAXRSClientFactory { * Creates a proxy * @param baseAddress baseAddress * @param cls resource class, if not interface then a CGLIB proxy will be created + * @param configLocation classpath location of Spring configuration resource + * @param features, the features which will be applied to the client + * @return typed proxy + */ + public static T create(String baseAddress, Class cls, String configLocation, + List features) { + JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); + bean.setFeatures(features); + 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 configLocation classpath location of Spring configuration resource + * @param features, the features which will be applied to the client + * @param varValues values to replace root Path template variables + * @return typed proxy + */ + public static T create(String baseAddress, Class cls, String configLocation, + List features, Object... varValues) { + JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); + bean.setFeatures(features); + return bean.create(cls, varValues); + } + + /** + * 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 configLocation classpath location of Spring configuration resource * @param varValues values to replace root Path template variables * @return typed proxy */ @@ -123,11 +169,26 @@ public final class JAXRSClientFactory { * @return typed proxy */ public static T create(String baseAddress, Class cls, List providers, boolean threadSafe) { + return create(baseAddress, cls, providers, threadSafe, null); + } + + /** + * Creates a thread safe proxy + * @param baseAddress baseAddress + * @param cls proxy class, if not interface then a CGLIB proxy will be created + * @param providers list of providers + * @param threadSafe if true then a thread-safe proxy will be created + * @param features, the features which will be applied to the client + * @return typed proxy + */ + public static T create(String baseAddress, Class cls, List providers, boolean threadSafe, + List features) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); bean.setProviders(providers); if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } + bean.setFeatures(features); return bean.create(cls); } @@ -136,12 +197,27 @@ public final class JAXRSClientFactory { * @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 + * @param configLocation classpath location of Spring configuration resource * @return typed proxy */ public static T create(String baseAddress, Class cls, List providers, String configLocation) { + return create(baseAddress, cls, providers, configLocation); + } + + /** + * 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 configLocation classpath location of Spring configuration resource + * @param features, the features which will be applied to the client + * @return typed proxy + */ + public static T create(String baseAddress, Class cls, List providers, String configLocation, + List features) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); bean.setProviders(providers); + bean.setFeatures(features); return bean.create(cls); } @@ -151,14 +227,30 @@ public final class JAXRSClientFactory { * @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 + * @param configLocation classpath location of Spring configuration resource * @return typed proxy */ public static T create(String baseAddress, Class cls, String username, String password, String configLocation) { + return create(baseAddress, cls, username, password, configLocation); + } + + /** + * 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 configLocation classpath location of Spring configuration resource + * @param features, the features which will be applied to the client + * @return typed proxy + */ + public static T create(String baseAddress, Class cls, String username, + String password, String configLocation, List features) { JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation); bean.setUsername(username); bean.setPassword(password); + bean.setFeatures(features); return bean.create(cls); } @@ -180,14 +272,31 @@ public final class JAXRSClientFactory { * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param modelRef model location * @param providers list of providers + * @param configLocation classpath location of Spring configuration resource * @return typed proxy */ public static T createFromModel(String baseAddress, Class cls, String modelRef, List providers, String configLocation) { + return createFromModel(baseAddress, cls, modelRef, providers, configLocation, null); + } + + /** + * Creates a proxy using user resource model + * @param baseAddress baseAddress + * @param cls proxy class, if not interface then a CGLIB proxy will be created + * @param modelRef model location + * @param providers list of providers + * @param configLocation classpath location of Spring configuration resource + * @param features, the features which will be applied to the client + * @return typed proxy + */ + public static T createFromModel(String baseAddress, Class cls, String modelRef, + List providers, String configLocation, List features) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation); bean.setProviders(providers); bean.setModelRef(modelRef); bean.setServiceClass(cls); + bean.setFeatures(features); return bean.create(cls); } @@ -202,6 +311,20 @@ public final class JAXRSClientFactory { */ public static T createFromModel(String baseAddress, Class cls, String modelRef, List providers, boolean threadSafe) { + return createFromModel(baseAddress, cls, modelRef, providers, threadSafe, null); + } + + /** + * Creates a thread safe proxy using user resource model + * @param baseAddress baseAddress + * @param cls proxy class, if not interface then a CGLIB proxy will be created + * @param modelRef model location + * @param providers list of providers + * @param threadSafe if true then thread-safe proxy will be created + * @return typed proxy + */ + public static T createFromModel(String baseAddress, Class cls, String modelRef, + List providers, boolean threadSafe, List features) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, null); bean.setProviders(providers); bean.setModelRef(modelRef); @@ -209,6 +332,7 @@ public final class JAXRSClientFactory { if (threadSafe) { bean.setInitialState(new ThreadLocalClientState(baseAddress)); } + bean.setFeatures(features); return bean.create(cls); } @@ -217,6 +341,7 @@ public final class JAXRSClientFactory { * @param baseAddress baseAddress * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param modelBeans model beans + * @param configLocation classpath location of Spring configuration resource * @return typed proxy */ public static T createFromModel(String baseAddress, Class cls, List modelBeans, @@ -230,15 +355,32 @@ public final class JAXRSClientFactory { * @param cls proxy class, if not interface then a CGLIB proxy will be created * @param modelBeans model beans * @param providers list of providers + * @param configLocation classpath location of Spring configuration resource * @return typed proxy */ public static T createFromModel(String baseAddress, Class cls, List modelBeans, List providers, String configLocation) { + return createFromModel(baseAddress, cls, modelBeans, providers, configLocation); + } + + /** + * Creates a proxy using user resource model + * @param baseAddress baseAddress + * @param cls proxy class, if not interface then a CGLIB proxy will be created + * @param modelBeans model beans + * @param providers list of providers + * @param configLocation classpath location of Spring configuration resource + * @param features, the features which will be applied to the client + * @return typed proxy + */ + public static T createFromModel(String baseAddress, Class cls, List modelBeans, + List providers, String configLocation, List features) { JAXRSClientFactoryBean bean = WebClient.getBean(baseAddress, configLocation); bean.setProviders(providers); bean.setModelBeans(modelBeans); bean.setServiceClass(cls); + bean.setFeatures(features); return bean.create(cls); } @@ -262,8 +404,23 @@ public final class JAXRSClientFactory { * @return typed proxy */ public static T fromClient(Client client, Class cls, boolean inheritHeaders) { + return fromClient(client, cls, inheritHeaders, null); + } + + /** + * 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 features, the features which will be applied to the client + * @return typed proxy + */ + public static T fromClient(Client client, Class cls, boolean inheritHeaders, + List features) { JAXRSClientFactoryBean bean = getBean(client.getCurrentURI().toString(), cls, null); bean.setInheritHeaders(inheritHeaders); + bean.setFeatures(features); ClientState clientState = WebClient.getClientState(client);