lookfirst / sardine

an easy to use webdav client for java
Other
579 stars 185 forks source link

Refactor the code responsible for configuring SardineImpl.builder to a separate class #262

Open adammichalik opened 8 years ago

adammichalik commented 8 years ago

In SardineImpl a substantial part of the class is responsible for configuring the default HttpClientBuilder. Refactoring it outside of SardineImpl and allowing a SardineImpl constructor to be parameterized with an instance of that "HttpClientBuilderFactory" would allow the developers to selectively modify the default Sardine's setup instead of providing the whole new HttpClientBuilder themselves.

My motivation: I'm using Sardine as a Spring singleton bean. That should work fine if I adjust the maxTotal and defaultMaxPerRoute of the underlying PoolingHttpClientConnectionManager. However, SardineImpl does not give access to the connection manager, so I have to subclass it and override createDefaultConnectionManager(). But that method is called during construction of SardineImpl (superclass), so I don't have a way to pass the maxTotal and defaultMaxPerRoute, because my subclass instance which would have these fields is not constructed yet.

adammichalik commented 8 years ago

That would also allow to easily solve issues like #254