org.apache.wink.client
Class ClientConfig

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

public class ClientConfig
extends java.lang.Object
implements java.lang.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
 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()
          Convenience method to get the int value of the wink.client.connectTimeout property
 java.util.List<ClientHandler> getHandlers()
          Get an unmodifiable list of the client handlers
 java.util.Properties getProperties()
          Convenience method for getting all properties registered on this instance.
 java.lang.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(java.lang.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 setLoadWinkApplications(boolean loadWinkApplications)
           
 void setProperties(java.util.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 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()
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 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

setLoadWinkApplications

public void setLoadWinkApplications(boolean loadWinkApplications)

isLoadWinkApplications

public boolean isLoadWinkApplications()

getProperties

public java.util.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(java.util.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()


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