org.apache.wink.client
Class ClientConfig

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

public class ClientConfig
extends Object
implements Cloneable, org.apache.wink.common.internal.WinkConfiguration

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 acceptHeaderAutoSet(boolean isAcceptHeaderAutoSet)
          Set whether client will automatically set an appropriate Accept header
 ClientConfig applications(javax.ws.rs.core.Application... applications)
          Add applications
protected  ClientConfig clone()
           
 ClientConfig connectTimeout(int connectTimeout)
          Convenience method to set the wink.client.connectTimeout property
 ClientConfig followRedirects(boolean followRedirects)
          Set whether to client will automatically follow redirects
 List<javax.ws.rs.core.Application> getApplications()
          Get an unmodifiable list of the applications
 boolean getBypassHostnameVerification()
          Get whether or not hostname verification will be bypassed for SSL certificates.
protected  ConnectionHandler getConnectionHandler()
          Returns the client handler that acts as the connection handler.
 int getConnectTimeout()
          Convenience method to get the int value of the wink.client.connectTimeout property
 List<ClientHandler> getHandlers()
          Get an unmodifiable list of the client handlers
 Properties getProperties()
          Convenience method for getting all properties registered on this instance.
 String getProxyHost()
          Get the proxy host
 int getProxyPort()
          Get the proxy port
 int getReadTimeout()
          Convenience method to get the int value of the wink.client.readTimeout property
 ClientConfig handlers(ClientHandler... handlers)
          Add client handlers
 boolean isAcceptHeaderAutoSet()
          Returns whether client will automatically set an appropriate Accept header
 boolean isFollowRedirects()
          Returns whether to client will automatically follow redirects
 boolean isLoadWinkApplications()
           
 boolean isSupportDTDExpansion()
          Convenience method to get the boolean value of the wink.supportDTDExpansion property
 ClientConfig proxyHost(String proxyHost)
          Set the proxy host
 ClientConfig proxyPort(int proxyPort)
          Set the proxy port
 ClientConfig readTimeout(int readTimeout)
          Convenience method to set the wink.client.readTimeout property
 void setBypassHostnameVerification(boolean bypassHostnameVerification)
          Set whether or not hostname verification to bypass hostname verification for SSL certificates.
 void setLoadWinkApplications(boolean loadWinkApplications)
           
 void setProperties(Properties properties)
          Convenience method to set the client configuration properties.
 ClientConfig supportDTDExpansion(boolean supportDTDExpansion)
          Convenience method to set the wink.supportDTDExpansion property
 
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 String getProxyHost()
Get the proxy host

Returns:
the proxy host

proxyHost

public final ClientConfig proxyHost(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()
Convenience method to get the int value of the wink.client.connectTimeout property

Returns:
the connect timeout in milliseconds

connectTimeout

public final ClientConfig connectTimeout(int connectTimeout)
Convenience method to set the wink.client.connectTimeout property

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

getReadTimeout

public final int getReadTimeout()
Convenience method to get the int value of the wink.client.readTimeout property

Returns:
the read timeout in milliseconds

readTimeout

public final ClientConfig readTimeout(int readTimeout)
Convenience method to set the wink.client.readTimeout property

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

isSupportDTDExpansion

public final boolean isSupportDTDExpansion()
Convenience method to get the boolean value of the wink.supportDTDExpansion property

Returns:
boolean

supportDTDExpansion

public final ClientConfig supportDTDExpansion(boolean supportDTDExpansion)
Convenience method to set the wink.supportDTDExpansion property

Parameters:
supportDTDExpansion - boolean
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

isAcceptHeaderAutoSet

public final boolean isAcceptHeaderAutoSet()
Returns whether client will automatically set an appropriate Accept header

Returns:
true if client will automatically set an appropriate Accept header; false otherwise

acceptHeaderAutoSet

public final ClientConfig acceptHeaderAutoSet(boolean isAcceptHeaderAutoSet)
Set whether client will automatically set an appropriate Accept header

Parameters:
isAcceptHeaderAutoSet - whether client will automatically set an appropriate Accept header
Returns:
this client configuration
Throws:
ClientConfigException

getHandlers

public final 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 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 Object

setLoadWinkApplications

public void setLoadWinkApplications(boolean loadWinkApplications)

isLoadWinkApplications

public boolean isLoadWinkApplications()

getProperties

public Properties getProperties()
Convenience method for getting all properties registered on this instance. System properties may be changed between creation of new instances. The following properties are meaningful to a ClientConfig instance: wink.client.connectTimeout - value is in milliseconds, default is 60000 wink.client.readTimeout - value is in milliseconds, default is 60000 wink.supportDTDExpansion - value is "true" or "false" to allow DOCTYPE entity expansion when built-in providers parse XML, default is "false"

Specified by:
getProperties in interface org.apache.wink.common.internal.WinkConfiguration
Returns:
properties on this ClientConfig instance

setProperties

public void setProperties(Properties properties)
Convenience method to set the client configuration properties. The following properties are meaningful to a ClientConfig instance: wink.client.connectTimeout - value is in milliseconds, default is 60000 wink.client.readTimeout - value is in milliseconds, default is 60000 wink.supportDTDExpansion - value is "true" or "false" to allow DOCTYPE entity expansion when built-in providers parse XML, default is "false"

Specified by:
setProperties in interface org.apache.wink.common.internal.WinkConfiguration
Parameters:
properties - the properties object to use. If properties parameter is null, the properties on this ClientConfig will be cleared with Properties.clear()

getBypassHostnameVerification

public boolean getBypassHostnameVerification()
Get whether or not hostname verification will be bypassed for SSL certificates.

Returns:
Whether or not hostname verification will be bypassed for SSL certificates

setBypassHostnameVerification

public void setBypassHostnameVerification(boolean bypassHostnameVerification)
Set whether or not hostname verification to bypass hostname verification for SSL certificates. Default value is false.

Parameters:
bypassHostnameVerification - true to bypass hostname verification


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