Orphan classes in java-support

Brent Putman putmanb at georgetown.edu
Thu Jan 16 23:44:36 EST 2014


On 1/16/14 7:27 AM, Ian Young wrote:
>
> That's interesting. I know Chad looked at a more fluent-style API, or at least the method chaining part of it, for some of our stuff (e.g., see https://issues.shibboleth.net/jira/browse/MDA-72). I'm not a  big fan of the style myself, 

Me either really.  Or at least, I'd prefer the option to do both fluent
style as well as Java bean style property setting for Spring IoC, etc. 
Some of the Apache stuff doesn't support the latter currently  (below).

>
> For HttpClient, I found this:
>
> 	http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fluent.html
>
> That seems to imply it's an optional facade layer for the simplest use cases, though, not a general replacement. Is there some more information available?

Ah, forgot about that.  That's actually something else entirely, not
what I was referring to.  That's their whole new Fluent API for the
entire request execution, etc.  I believe that's even in a separate
project and Maven artifact from the main HttpClient stuff (fluent-hc). 
Haven't looked at it much other than what is in that section of the
tutorial.  I definitely didn't see us making use of that...

What I was referring to is that the "fluent mindset" seems to have
influenced (infected?) their main library in terms of how many of these
new mandatory builders work.  For example, with their main HttpClient
builder you might do something like the following. Most/all the methods
there do a "return this" so you can chain in fluent style:

HttpClient httpClient =
HttpClientBuilder.create().addInterceptorLast(ri1).addInterceptorLast(ri2).disableContentCompression().disableRedirectHandling().build();


Works the same for the regular setter methods on the builder, but I
picked those specific method examples because for those, there is *not*
a setter style for them.  It does not for example support something like
the Java bean style that you'd need for it to work with Spring XML directly:

HttpClientBuilder builder = HttpClientBuilder.create()

// These don't exist
builder.setRequestInterceptors(listOfInterceptors);
builder.setUseContentCompression(false)
builder.setRedirectHandling(false)

HttpClient httpClient = builder.build()


So if you actually wanted to be able to wire those sorts of things via
Spring using their native builder, you'd have to write a Spring factory
bean that took those properties and invoked the builder methods
accordingly.  Kind of annoying IMHO, since the 2 approaches could exist
side-by-side.  But solvable easily enough with a little code.

Anyway, that implies to me that they seem to be skewing to the fluent
style (at least so far), and that's what I meant.

--Brent



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://shibboleth.net/pipermail/dev/attachments/20140116/3445dd86/attachment.html 


More information about the dev mailing list