org.alfresco.bm.http
Class SharedHttpClientProvider
java.lang.Object
org.alfresco.bm.http.SharedHttpClientProvider
- All Implemented Interfaces:
- HttpClientProvider
public final class SharedHttpClientProvider
- extends Object
- implements HttpClientProvider
A class responsible for managing one shared HttpClient instance. This uses a
thread-safe connection-manager instead of creating a new istance on every call.
This is done for the folowing reasons:
- Creating new HTTPClient instances for each request has memory-overhead and most
important, opens a new connection for each request. Even though the connection is released
they are kept in 'CLOSE_WAIT' state by the OS. This can, on high usage, empty out available outgoing TCP-ports and
influence the testing on the client, having impact on the results.
- Using a single HTTPClient allows creating a pool of connections that can be kept alive to
a certain route (route = combination of host and port) for a max number of time. This eliminates connection
setup and additional server round-trips, raising the overall throughput of http-calls (Browsers use
this mechanism all the time to lower loading-times).
- Author:
- Frederik Heremans
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SharedHttpClientProvider
public SharedHttpClientProvider(String alfrescoUrl,
int maxNumberOfConnections)
getFullAlfrescoUrlForPath
public String getFullAlfrescoUrlForPath(String path)
- Specified by:
getFullAlfrescoUrlForPath in interface HttpClientProvider
- Parameters:
path - relative path of the URL from alfresco host.
- Returns:
- full URL including hostname and port for the given path.
getHttpClient
public org.apache.commons.httpclient.HttpClient getHttpClient()
- Specified by:
getHttpClient in interface HttpClientProvider
- Returns:
- the
HttpClient instance to use for the next HTTP-call.
Copyright © 2012. All Rights Reserved.