javax.ws.rs.client
Interface Client


public interface Client

Client is the main entry point to the fluent API used to build and execute client requests in order to consume responses returned.

Clients are heavy-weight objects that manage the client-side communication infrastructure. Initialization as well as disposal of a Client instance may be a rather expensive operation. It is therefore advised to construct only a small number of Client instances in the application. Client instances must be properly closed before being disposed to avoid leaking resources.

Since:
2.0
Author:
Marek Potociar
See Also:
Configuration

Method Summary
 void close()
          Close client instance and all it's associated resources.
 Configuration configuration()
          Get access to the underlying configuration of the client instance.
 Invocation invocation(Link link)
          Build an invocation from a link.
 Invocation invocation(Link link, Entity<?> entity)
          Build an invocation from a link.
 Target target(Link link)
          Build a new web resource target.
 Target target(String uri)
          Build a new web resource target.
 Target target(URI uri)
          Build a new web resource target.
 Target target(UriBuilder uriBuilder)
          Build a new web resource target.
 

Method Detail

close

void close()
Close client instance and all it's associated resources. Subsequent calls have no effect and are ignored. Once the client is closed, invoking any other method on the client instance would result in an IllegalStateException being thrown.

Calling this method effectively invalidates all resource targets produced by the client instance. Invoking any method on such targets once the client is closed would result in an IllegalStateException being thrown.


configuration

Configuration configuration()
Get access to the underlying configuration of the client instance.

Returns:
a mutable client configuration.

target

Target target(String uri)
              throws IllegalArgumentException,
                     NullPointerException
Build a new web resource target.

Parameters:
uri - web resource URI.
Returns:
web resource target bound to the provided URI.
Throws:
IllegalArgumentException - in case the supplied string is not a valid URI.
NullPointerException - in case the supplied argument is null.

target

Target target(URI uri)
              throws NullPointerException
Build a new web resource target.

Parameters:
uri - web resource URI.
Returns:
web resource target bound to the provided URI.
Throws:
NullPointerException - in case the supplied argument is null.

target

Target target(UriBuilder uriBuilder)
              throws NullPointerException
Build a new web resource target.

Parameters:
uriBuilder - web resource URI represented as URI builder.
Returns:
web resource target bound to the provided URI.
Throws:
NullPointerException - in case the supplied argument is null.

target

Target target(Link link)
              throws NullPointerException
Build a new web resource target.

Parameters:
link - link to a web resource.
Returns:
web resource target bound to the linked web resource.
Throws:
NullPointerException - in case the supplied argument is null.

invocation

Invocation invocation(Link link)
                      throws NullPointerException,
                             IllegalArgumentException

Build an invocation from a link. The method and URI are obtained from the link. The HTTP Accept header is initialized to the value of the "produces" parameter in the link. If the operation requires an entity, use the overloaded form of this method.

This method will throw an IllegalArgumentException if there is not enough information to build an invocation (e.g. no HTTP method or entity when required).

Parameters:
link - link to build invocation from.
Returns:
newly created invocation.
Throws:
NullPointerException - in case argument is null.
IllegalArgumentException - in case link is incomplete to build invocation.

invocation

Invocation invocation(Link link,
                      Entity<?> entity)
                      throws NullPointerException,
                             IllegalArgumentException

Build an invocation from a link. The method and URI are obtained from the link. The HTTP Accept header is initialized to the value of the "produces" parameter in the link.If the operation does not require an entity, use the overloaded form of this method.

This method will throw an IllegalArgumentException if there is not enough information to build and invocation (e.g. no HTTP method).

Parameters:
link - link to build invocation from.
entity - request entity to be send when the invocation is invoked.
Returns:
newly created invocation.
Throws:
NullPointerException - in case argument is null.
IllegalArgumentException - in case link is incomplete to build invocation.


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.