hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Lazy init of cookie specs
Date Tue, 09 Sep 2014 13:00:09 GMT
On Tue, 2014-09-09 at 13:39 +0100, sebb wrote:
> Would it not be simpler to use the IODH idiom for the lazy init?
> 
> For example:
> 
> public class IgnoreSpecProvider implements CookieSpecProvider {
> 
>     public IgnoreSpecProvider() {
>         super();
>     }
> 
>     @Override
>     public CookieSpec create(final HttpContext context) {
>         return IgnoreSpec.getInstance();
>     }
> 
> }
> 
> public class IgnoreSpec extends CookieSpecBase {
> 
>     private static class SpecHolder {
>         private static final IgnoreSpec INSTANCE = new IgnoreSpec();
>     }
> 
>     public static IgnoreSpec getInstance() {
>         return SpecHolder.INSTANCE;
>     }
> 
>     private IgnoreSpec() { // prevent external init (not strictly necessary)
>         super();
>     }
> 
> .... rest of class
> }
> 
> Just a thought.
> 

IODH would be clearly preferred but it works well with default
constructors. IODH would suit IgnoreSpecProvider but not
DefaultCookieSpecProvider due to rather complex construction logic in
the latter.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message