|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.jersey.api.client.filter.Filterable
com.sun.jersey.api.client.Client
public final class Client
The main class for creating WebResource
instances and configuring
the properties of connections and requests.
ClientFilter
instances may be added to the client for filtering
requests and responses, including those of WebResource
instances
created from the client.
A client may be configured by passing a ClientConfig
instance to
the appropriate construtor.
Methods to create instances of WebResource
are thread-safe. Methods
that modify configuration and or filters are not guaranteed to be
thread-safe.
A client may integrate with an IoC framework by passing a
ComponentProvider
instance to the appropriate constructor.
Constructor Summary | |
---|---|
Client(ClientHandler root)
Create a new client instance. |
|
Client(ClientHandler root,
ClientConfig config)
Create a new client instance with a client configuration. |
|
Client(ClientHandler root,
ClientConfig config,
ComponentProvider provider)
Create a new instance with a client configuration and a component provider. |
Method Summary | |
---|---|
AsyncWebResource |
asyncResource(java.lang.String u)
Create an asynchronous Web resource from the client. |
AsyncWebResource |
asyncResource(java.net.URI u)
Create an asynchronous Web resource from the client. |
static Client |
create()
Create a default client. |
static Client |
create(ClientConfig cc)
Create a default client with client configuration. |
static Client |
create(ClientConfig cc,
ComponentProvider cp)
Create a default client with client configuration and component provider. |
java.util.Map<java.lang.String,java.lang.Object> |
getProperties()
Get the mutable property bag. |
ClientResponse |
handle(ClientRequest cr)
Handle a HTTP request as a ClientRequest and return the HTTP
response as a ClientResponse . |
WebResource |
resource(java.lang.String u)
Create a Web resource from the client. |
WebResource |
resource(java.net.URI u)
Create a Web resource from the client. |
void |
setChunkedEncodingSize(java.lang.Integer chunkSize)
Set the client to send request entities using chunked encoding with a particular chunk size. |
void |
setConnectTimeout(java.lang.Integer interval)
Set the connect timeout interval. |
void |
setFollowRedirects(java.lang.Boolean redirect)
Set if redirection should be performed or not. |
void |
setReadTimeout(java.lang.Integer interval)
Set the read timeout interval. |
Methods inherited from class com.sun.jersey.api.client.filter.Filterable |
---|
addFilter, getHeadHandler, removeAllFilters, removeFilter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Client(ClientHandler root)
root
- the root client handler for dispatching a request and
returning a response.public Client(ClientHandler root, ClientConfig config)
root
- the root client handler for dispatching a request and
returning a response.config
- the client configuration.public Client(ClientHandler root, ClientConfig config, ComponentProvider provider)
root
- the root client handler for dispatching a request and
returning a response.config
- the client configuration.provider
- the component provider.Method Detail |
---|
public WebResource resource(java.lang.String u)
u
- the URI of the resource.
public WebResource resource(java.net.URI u)
u
- the URI of the resource.
public AsyncWebResource asyncResource(java.lang.String u)
u
- the URI of the resource.
public AsyncWebResource asyncResource(java.net.URI u)
u
- the URI of the resource.
public java.util.Map<java.lang.String,java.lang.Object> getProperties()
public void setFollowRedirects(java.lang.Boolean redirect)
ClientConfig.PROPERTY_FOLLOW_REDIRECTS
on the property bag
returned from getProperties()
redirect
- if true then the client will automatically redirect
to the URI declared in 3xx responses.public void setReadTimeout(java.lang.Integer interval)
ClientConfig.PROPERTY_READ_TIMEOUT
on the property bag
returned from getProperties()
interval
- the read timeout interval. If null or 0 then
an interval of infinity is declared.public void setConnectTimeout(java.lang.Integer interval)
ClientConfig.PROPERTY_CONNECT_TIMEOUT
on the property bag
returned from getProperties()
interval
- the connect timeout interval. If null or 0 then
an interval of infinity is declared.public void setChunkedEncodingSize(java.lang.Integer chunkSize)
ClientConfig.PROPERTY_CHUNKED_ENCODING_SIZE
on the property bag
returned from getProperties()
chunkSize
- the chunked encoding size. If <= 0 then the default
size will be used. If null then chunked encoding will not be
utilized.public ClientResponse handle(ClientRequest cr) throws ClientHandlerException
ClientHandler
ClientRequest
and return the HTTP
response as a ClientResponse
.
handle
in interface ClientHandler
cr
- the HTTP request.
ClientHandlerException
- if the client
handler fails to process the request or response.public static Client create()
public static Client create(ClientConfig cc)
cc
- the client configuration.
public static Client create(ClientConfig cc, ComponentProvider cp)
cc
- the client configuration.cp
- the component provider.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |