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 D5F44199A0 for ; Tue, 22 Mar 2016 09:07:57 +0000 (UTC) Received: (qmail 15852 invoked by uid 500); 22 Mar 2016 09:06:44 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 15787 invoked by uid 500); 22 Mar 2016 09:06:44 -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 15535 invoked by uid 99); 22 Mar 2016 09:06:38 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Mar 2016 09:06:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id AD3D5C6AB9 for ; Tue, 22 Mar 2016 09:06:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.802 X-Spam-Level: X-Spam-Status: No, score=-0.802 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id nRqIP1ECJkTI for ; Tue, 22 Mar 2016 09:06:15 +0000 (UTC) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 1F62C5F238 for ; Tue, 22 Mar 2016 09:06:15 +0000 (UTC) Received: by mail-lb0-f175.google.com with SMTP id bc4so152168286lbc.2 for ; Tue, 22 Mar 2016 02:06:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=33wAFdvEB1X6lwLRydqBt4OEqzxRV1UwAcJ513RLlac=; b=mxH13xdw6XFUKJit5ACBKVoaPEeRjrXajjySs/U5KZnDKMJ+s9+ArN1Sd0hllQsMvE g0niMqwvfqXgt6ygovzJUwT1UHLCaCQTqAbScdaaY8jpIZ8DycfMrhmJMz122QKwhdxd B6yMmovVwZtp05AafcDotukeJqRzUz0U/ao/dAzsgjzUIf1x8spzsjqtzGqDk7kc035h 3ReIWc/r0xBtivA++9E4QdLaIFH/Ohj/4zKskfmv7mJwXQfvvmxK5QnwGZMaBA4n2hlC COmD54t/D4UQnrm/KQeXm/4hC0Rvmz9v6fUhUdrySQEeXrXixz1chqltwqFHqo18typ+ Wx6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=33wAFdvEB1X6lwLRydqBt4OEqzxRV1UwAcJ513RLlac=; b=MHPOZbxpez3JDivV74l8tGxeNJMi+ggBzxQpZFSOmO8jgbpfA0SCWb+07j74+KPgpI L0fZRuYS105yOVARureUgkTSQNMAj4MespoOUcdsjmq7IvKe1N9Jj++xZMc8+Crbqx3n WsyoJ6LvD3cBXDMwHClal2442QvIThK/lV5okc6nLexCKNfbcRKx0BYiomE3dXnDQ3CT faAJBv70kGBmfePbaFCHGGheAjhG+7MU+Rk2dWZgQYXsFN5bXsndYaN9tKZIrz8EvZwS PSp/extouKNBSHiqIU65EKCJrO2tVcQxY1vaylBG9YIzleolli8QMTvBWWMDDx/xK53F BBfg== X-Gm-Message-State: AD7BkJIhADUgNTHDphAMt38OvhMThwTpRzAMvfzz2LUmbUUgeebpCbmft//eBI5RzvvmCw== X-Received: by 10.112.13.8 with SMTP id d8mr12615012lbc.110.1458637574548; Tue, 22 Mar 2016 02:06:14 -0700 (PDT) Received: from [10.39.0.31] (nat-141-pool-1-ip-6.cosmostv.by. [87.252.225.96]) by smtp.googlemail.com with ESMTPSA id gp6sm5091090lbc.44.2016.03.22.02.06.13 for (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Mar 2016 02:06:13 -0700 (PDT) Subject: Re: Using Interceptors on JAX-RS 2.0 Client To: dev@cxf.apache.org References: From: Sergey Beryozkin Message-ID: <56F10B05.8090603@gmail.com> Date: Tue, 22 Mar 2016 12:06:13 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hi It is not possible to register CXF specific Feature or Interceptor with JAX-RS 2.0 Client API. When you do "client.register(new MyLoggingFeature())", assuming it is CXF Feature, then it will be currently ignored. I wonder if it might make sense to create some JAX-RS 2.0 FeatureWrapper which can wrap an arbitrary CXF Feature...I'll try to experiment with it... Sergey On 22/03/16 01:56, Eirik Bjørsnøs wrote: > Hello, > > Is the CXF implementation of the JAX-RS 2.0 client API designed to allow > Interceptors to be configured on Clients? If so, how should this be done? > > Say we have a Client built like this: > > Client client = ClientBuilder.newClient(); > > and we want to configure Logging[In/Out]Interceptors of this client. (Just > as an example). > > First I tried in various ways to get an Endpoint out of the client, but > failed at that. > > Then, after looking through the implementation classes of Client/WebTarget, > I discovered that you can register CXF Features on a Client using something > like > > client.register(new MyLoggingFeature()); > > However, with this setup MyLoggingFeature.initialize(InterceptorProvider > ip, Bus bus) is called _once per request_. > > Not exactly what I wanted since it lead to the interceptor chains being > filled up with duplicate LoggingInterceptors. > > I might perhaps have misunderstood the lifecycle of Clients and/or > WebTargets. Should be ok to reuse a JAX-RS 2.0 Client, right? > > Can someone please enlighten me? Did I perhaps miss some relevant > documentation? > > Cheers, > Eirik. >