View Javadoc

1   package com.atlassian.httpclient.api.factory;
2   
3   import com.atlassian.httpclient.api.HttpClient;
4   import com.atlassian.sal.api.executor.ThreadLocalContextManager;
5   
6   import javax.annotation.Nonnull;
7   
8   /**
9    * Creates configured instances of {@link com.atlassian.httpclient.api.HttpClient}
10   */
11  public interface HttpClientFactory {
12      /**
13       * Creates a new instance of {@link com.atlassian.httpclient.api.HttpClient}
14       *
15       * @param options The http client options.  Cannot be null.
16       * @return The new instance.  Will never be null
17       * @see #create(HttpClientOptions, ThreadLocalContextManager)
18       */
19      @Nonnull
20      HttpClient create(@Nonnull HttpClientOptions options);
21  
22      /**
23       * Creates a new instance of {@link com.atlassian.httpclient.api.HttpClient}
24       *
25       * @param options                   The http client options.  Cannot be null.
26       * @param threadLocalContextManager the manager for thread local variables. Cannot be null.
27       * @param <C>                       the context type
28       * @return The new instance.  Will never be null
29       * @see #create(HttpClientOptions)
30       */
31      @Nonnull
32      <C> HttpClient create(@Nonnull HttpClientOptions options, @Nonnull ThreadLocalContextManager<C> threadLocalContextManager);
33  
34      /**
35       * Disposes the given instance of {@link com.atlassian.httpclient.api.HttpClient}
36       *
37       * @param httpClient The httpClient to dispose. Cannot be null.
38       * @throws Exception in case of shutdown errors.
39       */
40      void dispose(@Nonnull HttpClient httpClient) throws Exception;
41  }