org.sonatype.spice.jersey.client.ahc
Class AhcHttpClient

java.lang.Object
  extended by com.sun.jersey.api.client.filter.Filterable
      extended by com.sun.jersey.api.client.Client
          extended by org.sonatype.spice.jersey.client.ahc.AhcHttpClient
All Implemented Interfaces:
com.sun.jersey.api.client.ClientHandler

public class AhcHttpClient
extends com.sun.jersey.api.client.Client

A Client that utilizes the AsyncHttpClient to send and receive HTTP request and responses.

If an AhcClientHandler is not explicitly passed as a constructor or method parameter then by default an instance is created with an AsyncHttpClient constructed

If a response entity is obtained that is an instance of Closeable then the instance MUST be closed after processing the entity to release connection-based resources.

If a ClientResponse is obtained and an entity is not read from the response then ClientResponse.close() MUST be called after processing the response to release connection-based resources.

Author:
Jeanfrancois Arcand

Constructor Summary
AhcHttpClient()
          Create a new client instance.
AhcHttpClient(AhcClientHandler root)
          Create a new client instance.
AhcHttpClient(AhcClientHandler root, com.sun.jersey.api.client.config.ClientConfig config, com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory provider)
          Deprecated. the config parameter is no longer utilized and instead the config obtained from the AhcClientHandler.getConfig() is utilized instead.
AhcHttpClient(AhcClientHandler root, com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory provider)
          Create a new instance with a client configuration and a component provider.
 
Method Summary
static AhcHttpClient create()
          Create a default client.
static AhcHttpClient create(com.sun.jersey.api.client.config.ClientConfig cc)
          Create a default client with client configuration.
static AhcHttpClient create(com.sun.jersey.api.client.config.ClientConfig cc, com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory provider)
          Create a default client with client configuration and component provider.
 void destroy()
           
protected  void finalize()
           
 AhcClientHandler getClientHandler()
          Get the AsyncHttpClient client handler.
 void setConnectTimeout(Integer interval)
           
 void setFollowRedirects(Boolean redirect)
           
 void setReadTimeout(Integer interval)
           
 
Methods inherited from class com.sun.jersey.api.client.Client
asyncResource, asyncResource, asyncView, asyncView, asyncView, asyncView, asyncViewResource, asyncViewResource, getExecutorService, getMessageBodyWorkers, getProperties, getProviders, getViewProxy, handle, inject, resource, resource, setChunkedEncodingSize, setExecutorService, view, view, view, view, view, view, viewResource, viewResource
 
Methods inherited from class com.sun.jersey.api.client.filter.Filterable
addFilter, getHeadHandler, isFilterPreset, removeAllFilters, removeFilter
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AhcHttpClient

public AhcHttpClient()
Create a new client instance.


AhcHttpClient

public AhcHttpClient(AhcClientHandler root)
Create a new client instance.

Parameters:
root - the root client handler for dispatching a request and returning a response.

AhcHttpClient

@Deprecated
public AhcHttpClient(AhcClientHandler root,
                                com.sun.jersey.api.client.config.ClientConfig config,
                                com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory provider)
Deprecated. the config parameter is no longer utilized and instead the config obtained from the AhcClientHandler.getConfig() is utilized instead.

Create a new instance with a client configuration and a component provider.

Parameters:
root - the root client handler for dispatching a request and returning a response.
config - the client configuration.
provider - the IoC component provider factory.

AhcHttpClient

public AhcHttpClient(AhcClientHandler root,
                     com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory provider)
Create a new instance with a client configuration and a component provider.

Parameters:
root - the root client handler for dispatching a request and returning a response.
provider - the IoC component provider factory.
Method Detail

getClientHandler

public AhcClientHandler getClientHandler()
Get the AsyncHttpClient client handler.

Returns:
the AsyncHttpClient client handler.

create

public static AhcHttpClient create()
Create a default client.

Returns:
a default client.

create

public static AhcHttpClient create(com.sun.jersey.api.client.config.ClientConfig cc)
Create a default client with client configuration.

Parameters:
cc - the client configuration.
Returns:
a default client.

create

public static AhcHttpClient create(com.sun.jersey.api.client.config.ClientConfig cc,
                                   com.sun.jersey.core.spi.component.ioc.IoCComponentProviderFactory provider)
Create a default client with client configuration and component provider.

Parameters:
cc - the client configuration.
provider - the IoC component provider factory.
Returns:
a default client.

destroy

public void destroy()
Overrides:
destroy in class com.sun.jersey.api.client.Client

finalize

protected void finalize()
Overrides:
finalize in class com.sun.jersey.api.client.Client

setFollowRedirects

public void setFollowRedirects(Boolean redirect)
Overrides:
setFollowRedirects in class com.sun.jersey.api.client.Client

setReadTimeout

public void setReadTimeout(Integer interval)
Overrides:
setReadTimeout in class com.sun.jersey.api.client.Client

setConnectTimeout

public void setConnectTimeout(Integer interval)
Overrides:
setConnectTimeout in class com.sun.jersey.api.client.Client


Copyright © 2012. All Rights Reserved.