org.apache.wink.client
Class ClientConfig

java.lang.Object
  extended by org.apache.wink.client.ClientConfig
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
ApacheHttpClientConfig

public class ClientConfig
extends java.lang.Object
implements java.lang.Cloneable

Provides client configuration. The ClientConfig is implemented using the builder pattern so method calls can be easily aggregated. Custom Providers are defined by calling the applications(Application...) method. Custom client handlers are defined by calling the handlers(ClientHandler...) method.


Constructor Summary
ClientConfig()
          Construct a new ClientConfig with the following default settings: proxy: none connect timeout: 60 seconds read timeout: 60 seconds follow redirects: true
 
Method Summary
 ClientConfig applications(javax.ws.rs.core.Application... applications)
          Add applications
protected  ClientConfig clone()
           
 ClientConfig connectTimeout(int connectTimeout)
          Set the connect timeout in milliseconds
 ClientConfig followRedirects(boolean followRedirects)
          Set whether to client will automatically follow redirects
 java.util.List<javax.ws.rs.core.Application> getApplications()
          Get an unmodifiable list of the applications
protected  ConnectionHandler getConnectionHandler()
          Returns the client handler that acts as the connection handler.
 int getConnectTimeout()
          Get the connect timeout in milliseconds
 java.util.List<ClientHandler> getHandlers()
          Get an unmodifiable list of the client handlers
 java.lang.String getProxyHost()
          Get the proxy host
 int getProxyPort()
          Get the proxy port
 int getReadTimeout()
          Get the read timeout in milliseconds
 ClientConfig handlers(ClientHandler... handlers)
          Add client handlers
 boolean isFollowRedirects()
          Returns whether to client will automatically follow redirects
 ClientConfig proxyHost(java.lang.String proxyHost)
          Set the proxy host
 ClientConfig proxyPort(int proxyPort)
          Set the proxy port
 ClientConfig readTimeout(int readTimeout)
          Set the read timeout in milliseconds
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientConfig

public ClientConfig()
Construct a new ClientConfig with the following default settings:

Method Detail

getProxyHost

public final java.lang.String getProxyHost()
Get the proxy host

Returns:
the proxy host

proxyHost

public final ClientConfig proxyHost(java.lang.String proxyHost)
Set the proxy host

Parameters:
proxyHost - proxy host
Returns:
this client configuration
Throws:
ClientConfigException

getProxyPort

public final int getProxyPort()
Get the proxy port

Returns:
the proxy port

proxyPort

public final ClientConfig proxyPort(int proxyPort)
Set the proxy port

Parameters:
proxyPort - proxy port
Returns:
this client configuration
Throws:
ClientConfigException

getConnectTimeout

public final int getConnectTimeout()
Get the connect timeout in milliseconds

Returns:
the connect timeout in milliseconds

connectTimeout

public final ClientConfig connectTimeout(int connectTimeout)
Set the connect timeout in milliseconds

Parameters:
connectTimeout - the connect timeout in milliseconds
Returns:
this client configuration
Throws:
ClientConfigException

getReadTimeout

public final int getReadTimeout()
Get the read timeout in milliseconds

Returns:
the read timeout in milliseconds

readTimeout

public final ClientConfig readTimeout(int readTimeout)
Set the read timeout in milliseconds

Parameters:
readTimeout - the read timeout in milliseconds
Returns:
this client configuration
Throws:
ClientConfigException

isFollowRedirects

public final boolean isFollowRedirects()
Returns whether to client will automatically follow redirects

Returns:
true if client will automatically follow redirects; false otherwise

followRedirects

public final ClientConfig followRedirects(boolean followRedirects)
Set whether to client will automatically follow redirects

Parameters:
followRedirects - whether to client will automatically follow redirects
Returns:
this client configuration
Throws:
ClientConfigException

getHandlers

public final java.util.List<ClientHandler> getHandlers()
Get an unmodifiable list of the client handlers

Returns:
an unmodifiable list of the client handlers

handlers

public final ClientConfig handlers(ClientHandler... handlers)
Add client handlers

Parameters:
handlers - the handlers to add
Returns:
this client configuration
Throws:
ClientConfigException

getConnectionHandler

protected ConnectionHandler getConnectionHandler()
Returns the client handler that acts as the connection handler. This handler is always the last handler on the chain and is automatically added to the end of the defined list of handlers.

This method should be overridden in order to provide an alternate connection handler.

Returns:
the connection handler

getApplications

public final java.util.List<javax.ws.rs.core.Application> getApplications()
Get an unmodifiable list of the applications

Returns:

applications

public final ClientConfig applications(javax.ws.rs.core.Application... applications)
Add applications

Parameters:
applications - the applications to add
Returns:
this client configuration
Throws:
ClientConfigException

clone

protected ClientConfig clone()
Overrides:
clone in class java.lang.Object


Copyright © 2009 The Apache Software Foundation. All Rights Reserved.