On Mon, Apr 3, 2017 at 9:15 AM, Oleg Kalnichevski <[email protected]> wrote:
> On Sun, 2017-04-02 at 16:14 -0700, Gary Gregory wrote: > > On Sat, Apr 1, 2017 at 10:19 AM, Oleg Kalnichevski <[email protected]> > > 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<T>) > > > > > > > > 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<T>) 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: [email protected] > > > For additional commands, e-mail: [email protected] > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > -- E-Mail: [email protected] | [email protected] Java Persistence with Hibernate, Second Edition <https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459> JUnit in Action, Second Edition <https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021> Spring Batch in Action <https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory
