org.opensaml.ws.soap.client.http
Class HttpClientBuilder

java.lang.Object
  extended by org.opensaml.ws.soap.client.http.HttpClientBuilder

@NotThreadSafe
public class HttpClientBuilder
extends Object

A builder for HttpClients. This builder will produce clients that employ the MultiThreadedHttpConnectionManager and as such users of the clients MUST be sure to invoke HttpMethod.releaseConnection() after they have finished with the method.


Field Summary
private  int connectionRetryAttempts
          Number of times a failed connection to a host should be retried.
private  int connectionTimeout
          Amount of time, in milliseconds, to wait for a connection to be established, default is 5,000.
private  String contentCharSet
          Character set used for HTTP content, defaults to UTF-8.
private  org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory httpsProtocolSocketFactory
          Socket factory used for the 'https' scheme.
private  int maxConnectionsPerHost
          Total number of connections allowed to a specific host, defaults to 5.
private  int maxTotalConnectons
          Total number of connections allowed to all hosts, defaults to 20.
private  boolean preemptiveAuthentication
          Whether authentication should be performed preemptively, defaults to false.
private  String proxyHost
          Host name of the HTTP proxy server through which connections will be made.
private  String proxyPassword
          Password used to connect to the HTTP proxy server.
private  int proxyPort
          Port number of the HTTP proxy server through which connections will be made.
private  String proxyUsername
          Username used to connect to the HTTP proxy server.
private  int receiveBufferSize
          Size of the buffer, in bytes, used to hold inbound information, defaults to 16,384.
private  int sendBufferSize
          Size of the buffer, in bytes, used to hold outbound information, defaults to 4,096.
private  boolean tcpNoDelay
          Whether to use TCP No Delay algorithm, defaults to true.
 
Constructor Summary
HttpClientBuilder()
          Constructor.
 
Method Summary
 org.apache.commons.httpclient.HttpClient buildClient()
          Builds an HTTP client with the given settings.
 int getConnectionRetryAttempts()
          Gets the number of times a connection will be tried if a host is unreachable.
 int getConnectionTimeout()
          Gets the time, in milliseconds, to wait for connection establishments.
 String getContentCharSet()
          Gets the character set used for HTTP content.
 org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory getHttpsProtocolSocketFactory()
          Gets the protocol socket factory used for the https scheme.
 int getMaxConnectionsPerHost()
          Gets the maximum number of connections, per host, that the client will create.
 int getMaxTotalConnections()
          Gets the maximum number of total connections the client will create.
 String getProxyHost()
          Gets the host name of the HTTP proxy server through which connections will be made.
 String getProxyPassword()
          Gets the password used to connect to the HTTP proxy server.
 int getProxyPort()
          Gets the port of the HTTP proxy server through which connections will be made.
 String getProxyUsername()
          Gets the username used to connect to the HTTP proxy server.
 int getReceiveBufferSize()
          Gets the size of buffer, in bytes, used when receiving content.
 int getSendBufferSize()
          Gets the size of buffer, in bytes, used when sending content.
 boolean isPreemptiveAuthentication()
          Gets whether authentication is performed preemptively.
 boolean isTcpNoDelay()
          Gets whether to use TCP No Delay when sending data.
 void resetDefaults()
          Resets the builder to its default values.
 void setConnectionRetryAttempts(int attempts)
          Sets the number of times a connection will be tried if a host is unreachable.
 void setConnectionTimeout(int timeout)
          Sets the time, in milliseconds, to wait for connection establishments.
 void setContentCharSet(String charSet)
          Sets the character set used for HTTP content.
 void setHttpsProtocolSocketFactory(org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory factory)
          Sets the protocol socket factory used for the https scheme.
 void setMaxConnectionsPerHost(int max)
          Sets the maximum number of connections, per host, that the client will create.
 void setMaxTotalConnections(int max)
          Sets the maximum number of total connections the client will create.
 void setPreemptiveAuthentication(boolean preemptive)
          Sets whether authentication is performed preemptively.
 void setProxyHost(String host)
          Sets the host name of the HTTP proxy server through which connections will be made.
 void setProxyPassword(String password)
          Sets the password used to connect to the HTTP proxy server.
 void setProxyPort(int port)
          Sets the port of the HTTP proxy server through which connections will be made.
 void setProxyUsername(String username)
          Sets the username used to connect to the HTTP proxy server.
 void setReceiveBufferSize(int size)
          Sets the size of buffer, in bytes, used when sending content.
 void setSendBufferSize(int size)
          Sets the size of buffer, in bytes, used when sending content.
 void setTcpNoDelay(boolean noDelay)
          Sets whether to use TCP No Delay when sending data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

proxyHost

private String proxyHost
Host name of the HTTP proxy server through which connections will be made.


proxyPort

private int proxyPort
Port number of the HTTP proxy server through which connections will be made.


proxyUsername

private String proxyUsername
Username used to connect to the HTTP proxy server.


proxyPassword

private String proxyPassword
Password used to connect to the HTTP proxy server.


preemptiveAuthentication

private boolean preemptiveAuthentication
Whether authentication should be performed preemptively, defaults to false.


contentCharSet

private String contentCharSet
Character set used for HTTP content, defaults to UTF-8.


connectionTimeout

private int connectionTimeout
Amount of time, in milliseconds, to wait for a connection to be established, default is 5,000.


sendBufferSize

private int sendBufferSize
Size of the buffer, in bytes, used to hold outbound information, defaults to 4,096.


receiveBufferSize

private int receiveBufferSize
Size of the buffer, in bytes, used to hold inbound information, defaults to 16,384.


tcpNoDelay

private boolean tcpNoDelay
Whether to use TCP No Delay algorithm, defaults to true.


maxConnectionsPerHost

private int maxConnectionsPerHost
Total number of connections allowed to a specific host, defaults to 5.


maxTotalConnectons

private int maxTotalConnectons
Total number of connections allowed to all hosts, defaults to 20.


connectionRetryAttempts

private int connectionRetryAttempts
Number of times a failed connection to a host should be retried.


httpsProtocolSocketFactory

private org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory httpsProtocolSocketFactory
Socket factory used for the 'https' scheme.

Constructor Detail

HttpClientBuilder

public HttpClientBuilder()
Constructor.

Method Detail

resetDefaults

public void resetDefaults()
Resets the builder to its default values.


buildClient

public org.apache.commons.httpclient.HttpClient buildClient()
Builds an HTTP client with the given settings. Settings are NOT reset to their default values after a client has been created.

Returns:
the created client.

getProxyHost

public String getProxyHost()
Gets the host name of the HTTP proxy server through which connections will be made.

Returns:
host name of the HTTP proxy server through which connections will be made

setProxyHost

public void setProxyHost(String host)
Sets the host name of the HTTP proxy server through which connections will be made.

Parameters:
host - host name of the HTTP proxy server through which connections will be made

getProxyPort

public int getProxyPort()
Gets the port of the HTTP proxy server through which connections will be made.

Returns:
port of the HTTP proxy server through which connections will be made

setProxyPort

public void setProxyPort(int port)
Sets the port of the HTTP proxy server through which connections will be made.

Parameters:
port - port of the HTTP proxy server through which connections will be made

getProxyUsername

public String getProxyUsername()
Gets the username used to connect to the HTTP proxy server.

Returns:
username used to connect to the HTTP proxy server

setProxyUsername

public void setProxyUsername(String username)
Sets the username used to connect to the HTTP proxy server.

Parameters:
username - username used to connect to the HTTP proxy server

getProxyPassword

public String getProxyPassword()
Gets the password used to connect to the HTTP proxy server.

Returns:
password used to connect to the HTTP proxy server

setProxyPassword

public void setProxyPassword(String password)
Sets the password used to connect to the HTTP proxy server.

Parameters:
password - password used to connect to the HTTP proxy server

isPreemptiveAuthentication

public boolean isPreemptiveAuthentication()
Gets whether authentication is performed preemptively. Default value is false.

Returns:
whether authentication is performed preemptively

setPreemptiveAuthentication

public void setPreemptiveAuthentication(boolean preemptive)
Sets whether authentication is performed preemptively.

Parameters:
preemptive - whether authentication is performed preemptively

getContentCharSet

public String getContentCharSet()
Gets the character set used for HTTP content. Default value is UTF-8.

Returns:
character set used for HTTP content

setContentCharSet

public void setContentCharSet(String charSet)
Sets the character set used for HTTP content.

Parameters:
charSet - character set used for HTTP content

getConnectionTimeout

public int getConnectionTimeout()
Gets the time, in milliseconds, to wait for connection establishments. Default value is 5,000. A value of 0 indicates there is no timeout.

Returns:
time, in milliseconds, to wait for connection establishments

setConnectionTimeout

public void setConnectionTimeout(int timeout)
Sets the time, in milliseconds, to wait for connection establishments. A value of 0 indicates there is no timeout.

Parameters:
timeout - time, in milliseconds, to wait for connection establishments

getSendBufferSize

public int getSendBufferSize()
Gets the size of buffer, in bytes, used when sending content. Default value is 4,096.

Returns:
size of buffer, in bytes, used when sending content

setSendBufferSize

public void setSendBufferSize(int size)
Sets the size of buffer, in bytes, used when sending content.

Parameters:
size - size of buffer, in bytes, used when sending content

getReceiveBufferSize

public int getReceiveBufferSize()
Gets the size of buffer, in bytes, used when receiving content. Default value is 16,384.

Returns:
size of buffer, in bytes, used when sending content

setReceiveBufferSize

public void setReceiveBufferSize(int size)
Sets the size of buffer, in bytes, used when sending content.

Parameters:
size - size of buffer, in bytes, used when sending content

isTcpNoDelay

public boolean isTcpNoDelay()
Gets whether to use TCP No Delay when sending data. Default value is true.

Returns:
whether to use TCP No Delay when sending data

setTcpNoDelay

public void setTcpNoDelay(boolean noDelay)
Sets whether to use TCP No Delay when sending data.

Parameters:
noDelay - whether to use TCP No Delay when sending data

getMaxConnectionsPerHost

public int getMaxConnectionsPerHost()
Gets the maximum number of connections, per host, that the client will create. Default value is 5. A value of 0 indicates there is no maximum.

Returns:
maximum number of connections, per host, that the client will create

setMaxConnectionsPerHost

public void setMaxConnectionsPerHost(int max)
Sets the maximum number of connections, per host, that the client will create. A value of 0 indicates there is no maximum.

Parameters:
max - maximum number of connections, per host, that the client will create

getMaxTotalConnections

public int getMaxTotalConnections()
Gets the maximum number of total connections the client will create. Default value is 20.

Returns:
maximum number of total connections the client will create

setMaxTotalConnections

public void setMaxTotalConnections(int max)
Sets the maximum number of total connections the client will create.

Parameters:
max - maximum number of total connections the client will create, must be greater than zero

getConnectionRetryAttempts

public int getConnectionRetryAttempts()
Gets the number of times a connection will be tried if a host is unreachable.

Returns:
number of times a connection will be tried if a host is unreachable

setConnectionRetryAttempts

public void setConnectionRetryAttempts(int attempts)
Sets the number of times a connection will be tried if a host is unreachable.

Parameters:
attempts - number of times a connection will be tried if a host is unreachable

getHttpsProtocolSocketFactory

public org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory getHttpsProtocolSocketFactory()
Gets the protocol socket factory used for the https scheme.

Returns:
protocol socket factory used for the https scheme

setHttpsProtocolSocketFactory

public void setHttpsProtocolSocketFactory(org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory factory)
Sets the protocol socket factory used for the https scheme.

Parameters:
factory - the httpsProtocolSocketFactory to set


Copyright © 1999-2013. All Rights Reserved.