Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 9F186200C3C for ; Mon, 3 Apr 2017 21:09:41 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9D950160B8F; Mon, 3 Apr 2017 19:09:41 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BBF4E160B8D for ; Mon, 3 Apr 2017 21:09:40 +0200 (CEST) Received: (qmail 84509 invoked by uid 500); 3 Apr 2017 19:09:40 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 84497 invoked by uid 99); 3 Apr 2017 19:09:39 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Apr 2017 19:09:39 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 43747180595 for ; Mon, 3 Apr 2017 19:09:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.379 X-Spam-Level: ** X-Spam-Status: No, score=2.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id sFnkSyFI1OxR for ; Mon, 3 Apr 2017 19:09:36 +0000 (UTC) Received: from mail-oi0-f52.google.com (mail-oi0-f52.google.com [209.85.218.52]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 937095F23A for ; Mon, 3 Apr 2017 19:09:36 +0000 (UTC) Received: by mail-oi0-f52.google.com with SMTP id r203so137845226oib.3 for ; Mon, 03 Apr 2017 12:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=TFKrci2iyKP31FMqn28uIE4BjMaa7QGy4AOkPWkYsGs=; b=ljTSgJpynPes92xC7Jz6JPSlYRbMeFV6RKwr2FIFHB/eaH8q3x1xFKzhg/EkfP7qIO rNK7mAItjPkhh0LJ/IckGrF0ipTgrdeHU1TRcmgxJdlJTLm8tR7NeTgVGXFksdreh99n d+Hn2CqqCtwGQJpii3gW8VbOiOVXaYRTePi2iccFT3pXOkW91BGtQMF3GHjKNt+kmzhL 1wYXGqN8kpD7oVup3uHEysDeYWWfXJoR+lDmr1UMegltobHsGBn+FlxZo1bSaJc7she4 cRu6kxZCv7gX0LRrpsQ+qhTZ3uXFX9PoWNe0Or460VolZzt8o2gz+g7ZWJcZ0G0HGz6C ZlEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=TFKrci2iyKP31FMqn28uIE4BjMaa7QGy4AOkPWkYsGs=; b=HaZ2M1W6u/5T1zPy3tU33ov+PxwuegmTtJd36gkF4HeZB2ohWdZZtKWAFno6H+HJp/ 9FWvaUYUz/zWAFtfHsbwg5Zv7Sf2/EbXwT3cplT6FKEiVfBVvBeP0WpSSz19atA7okYH EN9EVEkehNlCkE/xh/WRSEdjY+lXHVANjoxeXvDhiPzAGLiTJ6AVzmnGdYB4q8h2HZCz iaKh+TFTs/9sYCTpSg9cPuihoXzIp00uDi2ucuMYOpsLhWx8D7VGX9A+WGEqybRqex9u M3JATXflTVSKEvlsAiGFYbBOsYgGylm8uKV41VahtSnaYGhZNyNR0aSaLvmjH+AhfwPU NOFg== X-Gm-Message-State: AFeK/H0yjeDO7w9OwY8GaM440IR0LpvXHqM1gLgS7o2v4fYp/tLo1sQXM+GwaVemV5jC8k25BcF55L4jvYIY6Q== X-Received: by 10.202.195.194 with SMTP id t185mr9454019oif.174.1491246575753; Mon, 03 Apr 2017 12:09:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.157.48.91 with HTTP; Mon, 3 Apr 2017 12:09:35 -0700 (PDT) In-Reply-To: <1491236114.28557.4.camel@apache.org> References: <1491067146.6825.1.camel@apache.org> <1491236114.28557.4.camel@apache.org> From: Gary Gregory Date: Mon, 3 Apr 2017 12:09:35 -0700 Message-ID: Subject: Re: org.apache.http.protocol.HttpCoreContext.getAttribute(String, Class) To: HttpComponents Project Content-Type: multipart/alternative; boundary=001a1137c4406ba0d1054c47e61d archived-at: Mon, 03 Apr 2017 19:09:41 -0000 --001a1137c4406ba0d1054c47e61d Content-Type: text/plain; charset=UTF-8 On Mon, Apr 3, 2017 at 9:15 AM, Oleg Kalnichevski wrote: > On Sun, 2017-04-02 at 16:14 -0700, Gary Gregory wrote: > > On Sat, Apr 1, 2017 at 10:19 AM, Oleg Kalnichevski > > wrote: > > > > > On Fri, 2017-03-31 at 16:34 -0700, Gary Gregory wrote: > > > > I am always casting when I call HttpContext.getAttribute(String) > > > > for > > > > well-known keys defined HttpCoreContext like HTTP_CONNECTION. > > > > > > > > It seems we could make > > > > > > > > org.apache.http.protocol.HttpCoreContext.getAttribute(String, > > > > Class) > > > > > > > > part of the interface HttpContext. > > > > > > > > Thoughts? > > > > > > > > Gayr > > > > > > > > > > Hi Gary > > > > > > Usually one would probably want to use an adapter class such > > > HttpCoreContext or HttpClientContext to get access to context > > > specific > > > attributes but I am fine with moving the method to the generic > > > HttpContext interface. > > > > > > > Let me try to solve this from a different angle. > > > > I have an HttpContext and I want it's HttpConnection. > > > > - If I do an instanceof test for HttpCoreContext and call > > getConnection(), > > am I always going to get a non-null connection object? > > - If I call getAttribute(HttpCoreContext.HTTP_CONNECTION) on any > > HttpContext, will I only get a non-null object when the receiver is a > > HttpCoreContext? > > > > I do not want to make getAttribute(String, Class) part of the > > interface > > if it is going to make things more confusing. > > > > Thank you, > > Gary > > > > Hi Gary > > Of course, casting HttpContext to HttpCoreContext cannot ensure > presence of a HttpConection attribute in the context but it can provide > an easier access to it. > > --- > HttpContext context = ... > HttpCoreContext coreContext = HttpCoreContext.adapt(context); > HttpClientConnection connection = > coreContext.getConnection(HttpClientConnection.class); > if (connection != null) { > // do stuff > } > --- > Ah, very nice, I will use HttpCoreContext.adapt(context) Thank you! Gary > Oleg > > > > > > > > > > > > Oleg > > > > > > ----------------------------------------------------------------- > > > ---- > > > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > > > For additional commands, e-mail: dev-help@hc.apache.org > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org > > -- E-Mail: garydgregory@gmail.com | ggregory@apache.org Java Persistence with Hibernate, Second Edition JUnit in Action, Second Edition Spring Batch in Action Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory --001a1137c4406ba0d1054c47e61d--