org.alfresco.http
Class SharedHttpClientProvider

java.lang.Object
  extended by org.alfresco.http.SharedHttpClientProvider
All Implemented Interfaces:
HttpClientProvider

public final class SharedHttpClientProvider
extends Object
implements HttpClientProvider

A class responsible for managing shared HTTP connections. This uses a thread-safe connection-manager instead of creating a new istance on every call. This is done for the folowing reasons:

Author:
Frederik Heremans, Derek Hulley, Michael Suzuki

Field Summary
static int DEFAULT_CONNECTION_TIMEOUT_MILLISEC
           
static int DEFAULT_SOCKET_TIMEOUT_MILLISEC
           
 
Constructor Summary
SharedHttpClientProvider(int maxNumberOfConnections)
          Constructs with DEFAULT_CONNECTION_TIMEOUT_MILLISEC and DEFAULT_SOCKET_TIMEOUT_MILLISEC.
SharedHttpClientProvider(int maxNumberOfConnections, int connectionTimeoutMs, int socketTimeoutMs)
          See Connection management.
 
Method Summary
 org.apache.http.client.HttpClient getHttpClient()
           
 org.apache.http.client.HttpClient getHttpClient(String username, String password)
          Get a new client using basic authentication
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONNECTION_TIMEOUT_MILLISEC

public static final int DEFAULT_CONNECTION_TIMEOUT_MILLISEC
See Also:
Constant Field Values

DEFAULT_SOCKET_TIMEOUT_MILLISEC

public static final int DEFAULT_SOCKET_TIMEOUT_MILLISEC
See Also:
Constant Field Values
Constructor Detail

SharedHttpClientProvider

public SharedHttpClientProvider(int maxNumberOfConnections)
Constructs with DEFAULT_CONNECTION_TIMEOUT_MILLISEC and DEFAULT_SOCKET_TIMEOUT_MILLISEC.

See Also:
SharedHttpClientProvider#SharedHttpClientProvider(String, int, int)

SharedHttpClientProvider

public SharedHttpClientProvider(int maxNumberOfConnections,
                                int connectionTimeoutMs,
                                int socketTimeoutMs)
See Connection management.

Parameters:
maxNumberOfConnections - the maximum number of Http connections in the pool
connectionTimeoutMs - the time to wait for a connection from the pool before failure
socketTimeoutMs - the time to wait for data activity on a connection before failure
Method Detail

getHttpClient

public org.apache.http.client.HttpClient getHttpClient()
Specified by:
getHttpClient in interface HttpClientProvider
Returns:
the HttpClient instance to use for the next HTTP call.

getHttpClient

public org.apache.http.client.HttpClient getHttpClient(String username,
                                                       String password)
Description copied from interface: HttpClientProvider
Get a new client using basic authentication

Specified by:
getHttpClient in interface HttpClientProvider
Parameters:
username - the username
password - the password for the user
Returns:
the HttpClient instance to use for the next HTTP call.


Copyright © 2012. All Rights Reserved.