Return-Path: X-Original-To: apmail-cxf-dev-archive@www.apache.org Delivered-To: apmail-cxf-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8CFE5CEC2 for ; Tue, 29 May 2012 13:12:02 +0000 (UTC) Received: (qmail 64758 invoked by uid 500); 29 May 2012 13:12:02 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 64707 invoked by uid 500); 29 May 2012 13:12:02 -0000 Mailing-List: contact dev-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 dev@cxf.apache.org Received: (qmail 64698 invoked by uid 99); 29 May 2012 13:12:02 -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 13:12:02 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of sberyozkin@gmail.com designates 74.125.83.41 as permitted sender) Received: from [74.125.83.41] (HELO mail-ee0-f41.google.com) (74.125.83.41) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 May 2012 13:11:54 +0000 Received: by eekb47 with SMTP id b47so1156741eek.0 for ; Tue, 29 May 2012 06:11:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=6v5aV8rxUTh+GZhJ1lR7kL3QAFmLjqvTndYnbo8l1jw=; b=lXEkLjh52UQv26fb9YZgD9XdadTW0nXDw0FZsJ680q1B7Owksqvtjd2qROqrLqOhGT 8BhNnse+JIDGAP8MDW0zoxSggxGIh6Ih9i/EwECY4yXiCAPMmIDdQw5PX3Fl56rtxOry a4IXOfiAbVarp5y9e2O6Hq+msO1KsZhILEcmeNbUm2VfL64dL1YeilA8FVMa7RrDP+YQ HrYmDQy0HrOEWFP0rmQxSghppfvNdn7Gedk5kvL6ZRtNM+danoe82n3BlhC2H6QNXWxa yUCxU/ZbDcpR5XgJ4cuENWG2/mC1BP1Z1YDO2U3sUBIiRIDbLawzMXkP2P049KLsgv9a JptQ== Received: by 10.14.40.18 with SMTP id e18mr4316288eeb.109.1338297093845; Tue, 29 May 2012 06:11:33 -0700 (PDT) Received: from [10.36.226.5] ([217.173.99.61]) by mx.google.com with ESMTPS id y54sm48711909eef.10.2012.05.29.06.11.33 (version=SSLv3 cipher=OTHER); Tue, 29 May 2012 06:11:33 -0700 (PDT) Message-ID: <4FC4CB04.7000303@gmail.com> Date: Tue, 29 May 2012 14:11:32 +0100 From: Sergey Beryozkin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: dev@cxf.apache.org Subject: Re: svn commit: r1343446 References: <20120529013903.59CE623889BF@eris.apache.org> <4FC49038.5010805@gmail.com> <4FC4C9FF.30106@gmail.com> In-Reply-To: <4FC4C9FF.30106@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 29/05/12 14:07, Willem Jiang wrote: > Hi Sergey, > > JAXRSClientFactory provides the static method to create the proxy or the > client. I didn't find a better way to apply the features to all these > method by just changing a single method. > > If you have a better idea, please share it with me. > > BTW, I just found my commit introduced a stall over follow issue, I will > commit a patch to fix the build right way. > I already fixed it As I said, JAXRSClientFactoryBean can always be used. Having a single utility method should be enough, Sergey > > On 5/29/12 5:00 PM, Sergey Beryozkin wrote: >> Hi Willem >> >> I'd really prefer us discussing updates like this one to the public >> client API that the CXF JAX-RS runtime offers. >> >> I can see you just added 5 or so new JAXRSClientFactory methods. >> I consider most of them redundant. JAXRSClientFactory is a *utility* >> factory and is already a bit overloaded without these new extra 5 >> methods added. >> >> JAXRSClientFactoryBean is always there to offer a more custom approach >> toward creating a proxy and I would like to revert most of the methods >> you added. >> >> I agree it may make sense to offer say a single utility method for >> accepting the features, but I'd not like to have 5+ variations, the API >> will become too 'noisy'. Besides the same would then need to be added to >> WebClient factory methods... >> >> I'll take care of updating the api >> >> Thanks, Sergey >> >> >> On 29/05/12 02:39, ningjiang@apache.org wrote: >>> Author: ningjiang >>> Date: Tue May 29 01:39:02 2012 >>> New Revision: 1343446 >>> >>> URL: http://svn.apache.org/viewvc?rev=1343446&view=rev >>> Log: >>> CXF-4345 Allow user-secified feautres for JAXRSClientFactory >>> >>> Modified: >>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java >>> >>> >>> >>> Modified: >>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java >>> >>> >>> URL: >>> http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java?rev=1343446&r1=1343445&r2=1343446&view=diff >>> >>> >>> ============================================================================== >>> >>> >>> --- >>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java >>> >>> (original) >>> +++ >>> cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactory.java >>> >>> Tue May 29 01:39:02 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; >>> >>> /** >>> @@ -56,7 +57,20 @@ public final class JAXRSClientFactory { >>> * @return typed proxy >>> */ >>> public static T create(String baseAddress, Class cls, >>> ClassLoader loader) { >>> + >>> + return create(baseAddress, cls, loader, null); >>> + } >>> + >>> + /** >>> + * Creates a proxy using a custom class loader >>> + * @param baseAddress baseAddress >>> + * @param loader class loader >>> + * @param cls resource class, if not interface then a CGLIB proxy >>> will be created >>> + * @return typed proxy >>> + */ >>> + public static T create(String baseAddress, Class cls, >>> ClassLoader loader, List features) { >>> JAXRSClientFactoryBean bean = getBean(baseAddress, cls, null); >>> + bean.setFeatures(features); >>> bean.setClassLoader(loader); >>> return bean.create(cls); >>> } >>> @@ -80,18 +94,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) { >>> @@ -103,9 +129,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 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 config classpath location of Spring configuration resource >>> + * @param configLocation classpath location of Spring configuration >>> resource >>> * @param varValues values to replace root Path template variables >>> * @return typed proxy >>> */ >>> @@ -136,11 +195,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); >>> } >>> >>> @@ -149,12 +223,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); >>> } >>> >>> @@ -164,14 +253,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); >>> } >>> >>> @@ -193,14 +298,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); >>> } >>> >>> @@ -215,6 +337,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); >>> @@ -222,6 +358,7 @@ public final class JAXRSClientFactory { >>> if (threadSafe) { >>> bean.setInitialState(new ThreadLocalClientState(baseAddress)); >>> } >>> + bean.setFeatures(features); >>> return bean.create(cls); >>> } >>> >>> @@ -230,6 +367,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, >>> @@ -243,15 +381,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); >>> } >>> >>> @@ -275,8 +430,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); >>> >>> >>> >> >> > > -- Sergey Beryozkin Talend Community Coders http://coders.talend.com/ Blog: http://sberyozkin.blogspot.com