org.glassfish.jersey.client
Class JerseyInvocation.Builder

java.lang.Object
  extended by org.glassfish.jersey.client.JerseyInvocation.Builder
All Implemented Interfaces:
Invocation.Builder, SyncInvoker
Enclosing class:
JerseyInvocation

public static class JerseyInvocation.Builder
extends java.lang.Object
implements Invocation.Builder

Jersey-specific client invocation builder.


Constructor Summary
protected JerseyInvocation.Builder(java.net.URI uri, ClientConfig configuration)
          Create new Jersey-specific client invocation builder.
 
Method Summary
 JerseyInvocation.Builder acceptLanguage(java.util.Locale... locales)
          Add acceptable languages.
 JerseyInvocation.Builder acceptLanguage(java.lang.String... locales)
          Add acceptable languages.
 AsyncInvoker async()
          Access the asynchronous uniform request invocation interface to asynchronously invoke the built request.
 JerseyInvocation build(java.lang.String method)
          Build a request invocation using an arbitrary request method name.
 JerseyInvocation build(java.lang.String method, Entity<?> entity)
          Build a request invocation using an arbitrary request method name and request entity.
 JerseyInvocation buildDelete()
          Build a DELETE request invocation.
 JerseyInvocation buildGet()
          Build a GET request invocation.
 JerseyInvocation buildPost(Entity<?> entity)
          Build a POST request invocation.
 JerseyInvocation buildPut(Entity<?> entity)
          Build a PUT request invocation.
 JerseyInvocation.Builder cacheControl(CacheControl cacheControl)
          Set the cache control data of the message.
 ClientConfig configuration()
          Get access to the underlying configuration.
 JerseyInvocation.Builder cookie(Cookie cookie)
          Add a cookie to be set.
 Invocation.Builder cookie(java.lang.String name, java.lang.String value)
          Add a cookie to be set.
 Response delete()
          Invoke HTTP DELETE method for the current request synchronously.
<T> T
delete(java.lang.Class<T> responseType)
          Invoke HTTP DELETE method for the current request synchronously.
<T> T
delete(GenericType<T> responseType)
          Invoke HTTP DELETE method for the current request synchronously.
 Response get()
          Invoke HTTP GET method for the current request synchronously.
<T> T
get(java.lang.Class<T> responseType)
          Invoke HTTP GET method for the current request synchronously.
<T> T
get(GenericType<T> responseType)
          Invoke HTTP GET method for the current request synchronously.
 Response head()
          Invoke HTTP HEAD method for the current request synchronously.
 JerseyInvocation.Builder header(java.lang.String name, java.lang.Object value)
          Add an arbitrary header.
 Invocation.Builder headers(MultivaluedMap<java.lang.String,java.lang.Object> headers)
          Replaces all existing headers with the newly supplied headers.
 Response method(java.lang.String name)
          Invoke an arbitrary method for the current request synchronously.
<T> T
method(java.lang.String name, java.lang.Class<T> responseType)
          Invoke an arbitrary method for the current request synchronously.
 Response method(java.lang.String name, Entity<?> entity)
          Invoke an arbitrary method for the current request synchronously.
<T> T
method(java.lang.String name, Entity<?> entity, java.lang.Class<T> responseType)
          Invoke an arbitrary method for the current request synchronously.
<T> T
method(java.lang.String name, Entity<?> entity, GenericType<T> responseType)
          Invoke an arbitrary method for the current request synchronously.
<T> T
method(java.lang.String name, GenericType<T> responseType)
          Invoke an arbitrary method for the current request synchronously.
 Response options()
          Invoke HTTP OPTIONS method for the current request synchronously.
<T> T
options(java.lang.Class<T> responseType)
          Invoke HTTP OPTIONS method for the current request synchronously.
<T> T
options(GenericType<T> responseType)
          Invoke HTTP OPTIONS method for the current request synchronously.
 Response post(Entity<?> entity)
          Invoke HTTP POST method for the current request synchronously.
<T> T
post(Entity<?> entity, java.lang.Class<T> responseType)
          Invoke HTTP POST method for the current request synchronously.
<T> T
post(Entity<?> entity, GenericType<T> responseType)
          Invoke HTTP POST method for the current request synchronously.
 Response put(Entity<?> entity)
          Invoke HTTP PUT method for the current request synchronously.
<T> T
put(Entity<?> entity, java.lang.Class<T> responseType)
          Invoke HTTP PUT method for the current request synchronously.
<T> T
put(Entity<?> entity, GenericType<T> responseType)
          Invoke HTTP PUT method for the current request synchronously.
 Response trace()
          Invoke HTTP TRACE method for the current request synchronously.
<T> T
trace(java.lang.Class<T> responseType)
          Invoke HTTP TRACE method for the current request synchronously.
<T> T
trace(GenericType<T> responseType)
          Invoke HTTP TRACE method for the current request synchronously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JerseyInvocation.Builder

protected JerseyInvocation.Builder(java.net.URI uri,
                                   ClientConfig configuration)
Create new Jersey-specific client invocation builder.

Parameters:
uri - invoked request URI.
configuration - Jersey client configuration.
Method Detail

build

public JerseyInvocation build(java.lang.String method)
Description copied from interface: Invocation.Builder
Build a request invocation using an arbitrary request method name.

Specified by:
build in interface Invocation.Builder
Parameters:
method - request method name.
Returns:
invocation encapsulating the built request.

build

public JerseyInvocation build(java.lang.String method,
                              Entity<?> entity)
Description copied from interface: Invocation.Builder
Build a request invocation using an arbitrary request method name and request entity.

Specified by:
build in interface Invocation.Builder
Parameters:
method - request method name.
entity - request entity.
Returns:
invocation encapsulating the built request.

buildGet

public JerseyInvocation buildGet()
Description copied from interface: Invocation.Builder
Build a GET request invocation.

Specified by:
buildGet in interface Invocation.Builder
Returns:
invocation encapsulating the built GET request.

buildDelete

public JerseyInvocation buildDelete()
Description copied from interface: Invocation.Builder
Build a DELETE request invocation.

Specified by:
buildDelete in interface Invocation.Builder
Returns:
invocation encapsulating the built DELETE request.

buildPost

public JerseyInvocation buildPost(Entity<?> entity)
Description copied from interface: Invocation.Builder
Build a POST request invocation.

Specified by:
buildPost in interface Invocation.Builder
Parameters:
entity - request entity
Returns:
invocation encapsulating the built POST request.

buildPut

public JerseyInvocation buildPut(Entity<?> entity)
Description copied from interface: Invocation.Builder
Build a PUT request invocation.

Specified by:
buildPut in interface Invocation.Builder
Parameters:
entity - request entity
Returns:
invocation encapsulating the built PUT request.

async

public AsyncInvoker async()
Description copied from interface: Invocation.Builder
Access the asynchronous uniform request invocation interface to asynchronously invoke the built request.

Specified by:
async in interface Invocation.Builder
Returns:
asynchronous uniform request invocation interface.

acceptLanguage

public JerseyInvocation.Builder acceptLanguage(java.util.Locale... locales)
Description copied from interface: Invocation.Builder
Add acceptable languages.

Specified by:
acceptLanguage in interface Invocation.Builder
Parameters:
locales - an array of the acceptable languages
Returns:
the updated builder.

acceptLanguage

public JerseyInvocation.Builder acceptLanguage(java.lang.String... locales)
Description copied from interface: Invocation.Builder
Add acceptable languages.

Specified by:
acceptLanguage in interface Invocation.Builder
Parameters:
locales - an array of the acceptable languages
Returns:
the updated builder.

cookie

public JerseyInvocation.Builder cookie(Cookie cookie)
Description copied from interface: Invocation.Builder
Add a cookie to be set.

Specified by:
cookie in interface Invocation.Builder
Parameters:
cookie - to be set.
Returns:
the updated builder.

cookie

public Invocation.Builder cookie(java.lang.String name,
                                 java.lang.String value)
Description copied from interface: Invocation.Builder
Add a cookie to be set.

Specified by:
cookie in interface Invocation.Builder
Parameters:
name - the name of the cookie.
value - the value of the cookie.
Returns:
the updated builder.

cacheControl

public JerseyInvocation.Builder cacheControl(CacheControl cacheControl)
Description copied from interface: Invocation.Builder
Set the cache control data of the message.

Specified by:
cacheControl in interface Invocation.Builder
Parameters:
cacheControl - the cache control directives, if null any existing cache control directives will be removed.
Returns:
the updated builder.

header

public JerseyInvocation.Builder header(java.lang.String name,
                                       java.lang.Object value)
Description copied from interface: Invocation.Builder
Add an arbitrary header.

Specified by:
header in interface Invocation.Builder
Parameters:
name - the name of the header
value - the value of the header, the header will be serialized using a RuntimeDelegate.HeaderDelegate if one is available via RuntimeDelegate.createHeaderDelegate(java.lang.Class) for the class of value or using its toString method if a header delegate is not available. If value is null then all current headers of the same name will be removed.
Returns:
the updated builder.

headers

public Invocation.Builder headers(MultivaluedMap<java.lang.String,java.lang.Object> headers)
Description copied from interface: Invocation.Builder
Replaces all existing headers with the newly supplied headers.

Specified by:
headers in interface Invocation.Builder
Parameters:
headers - new headers to be set, if null all existing headers will be removed.
Returns:
the updated builder.

configuration

public ClientConfig configuration()
Description copied from interface: Invocation.Builder
Get access to the underlying configuration.

Specified by:
configuration in interface Invocation.Builder
Returns:
a mutable configuration bound to the instance.

get

public Response get()
             throws ClientException
Description copied from interface: SyncInvoker
Invoke HTTP GET method for the current request synchronously.

Specified by:
get in interface SyncInvoker
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

get

public <T> T get(java.lang.Class<T> responseType)
      throws ClientException,
             WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP GET method for the current request synchronously.

Specified by:
get in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

get

public <T> T get(GenericType<T> responseType)
      throws ClientException,
             WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP GET method for the current request synchronously.

Specified by:
get in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response

put

public Response put(Entity<?> entity)
             throws ClientException
Description copied from interface: SyncInvoker
Invoke HTTP PUT method for the current request synchronously.

Specified by:
put in interface SyncInvoker
Parameters:
entity - request entity.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

put

public <T> T put(Entity<?> entity,
                 java.lang.Class<T> responseType)
      throws ClientException,
             WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP PUT method for the current request synchronously.

Specified by:
put in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
entity - request entity.
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

put

public <T> T put(Entity<?> entity,
                 GenericType<T> responseType)
      throws ClientException,
             WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP PUT method for the current request synchronously.

Specified by:
put in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
entity - request entity.
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response.

post

public Response post(Entity<?> entity)
              throws ClientException
Description copied from interface: SyncInvoker
Invoke HTTP POST method for the current request synchronously.

Specified by:
post in interface SyncInvoker
Parameters:
entity - request entity.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

post

public <T> T post(Entity<?> entity,
                  java.lang.Class<T> responseType)
       throws ClientException,
              WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP POST method for the current request synchronously.

Specified by:
post in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
entity - request entity.
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

post

public <T> T post(Entity<?> entity,
                  GenericType<T> responseType)
       throws ClientException,
              WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP POST method for the current request synchronously.

Specified by:
post in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
entity - request entity.
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response.

delete

public Response delete()
                throws ClientException
Description copied from interface: SyncInvoker
Invoke HTTP DELETE method for the current request synchronously.

Specified by:
delete in interface SyncInvoker
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

delete

public <T> T delete(java.lang.Class<T> responseType)
         throws ClientException,
                WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP DELETE method for the current request synchronously.

Specified by:
delete in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

delete

public <T> T delete(GenericType<T> responseType)
         throws ClientException,
                WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP DELETE method for the current request synchronously.

Specified by:
delete in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response.

head

public Response head()
              throws ClientException
Description copied from interface: SyncInvoker
Invoke HTTP HEAD method for the current request synchronously.

Specified by:
head in interface SyncInvoker
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

options

public Response options()
                 throws ClientException
Description copied from interface: SyncInvoker
Invoke HTTP OPTIONS method for the current request synchronously.

Specified by:
options in interface SyncInvoker
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

options

public <T> T options(java.lang.Class<T> responseType)
          throws ClientException,
                 WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP OPTIONS method for the current request synchronously.

Specified by:
options in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

options

public <T> T options(GenericType<T> responseType)
          throws ClientException,
                 WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP OPTIONS method for the current request synchronously.

Specified by:
options in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response.

trace

public Response trace()
               throws ClientException
Description copied from interface: SyncInvoker
Invoke HTTP TRACE method for the current request synchronously.

Specified by:
trace in interface SyncInvoker
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

trace

public <T> T trace(java.lang.Class<T> responseType)
        throws ClientException,
               WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP TRACE method for the current request synchronously.

Specified by:
trace in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

trace

public <T> T trace(GenericType<T> responseType)
        throws ClientException,
               WebApplicationException
Description copied from interface: SyncInvoker
Invoke HTTP TRACE method for the current request synchronously.

Specified by:
trace in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response.

method

public Response method(java.lang.String name)
                throws ClientException
Description copied from interface: SyncInvoker
Invoke an arbitrary method for the current request synchronously.

Specified by:
method in interface SyncInvoker
Parameters:
name - method name.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

method

public <T> T method(java.lang.String name,
                    java.lang.Class<T> responseType)
         throws ClientException,
                WebApplicationException
Description copied from interface: SyncInvoker
Invoke an arbitrary method for the current request synchronously.

Specified by:
method in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
name - method name.
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

method

public <T> T method(java.lang.String name,
                    GenericType<T> responseType)
         throws ClientException,
                WebApplicationException
Description copied from interface: SyncInvoker
Invoke an arbitrary method for the current request synchronously.

Specified by:
method in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
name - method name.
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response.

method

public Response method(java.lang.String name,
                       Entity<?> entity)
                throws ClientException
Description copied from interface: SyncInvoker
Invoke an arbitrary method for the current request synchronously.

Specified by:
method in interface SyncInvoker
Parameters:
name - method name.
entity - request entity.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.

method

public <T> T method(java.lang.String name,
                    Entity<?> entity,
                    java.lang.Class<T> responseType)
         throws ClientException,
                WebApplicationException
Description copied from interface: SyncInvoker
Invoke an arbitrary method for the current request synchronously.

Specified by:
method in interface SyncInvoker
Type Parameters:
T - response entity type.
Parameters:
name - method name.
entity - request entity.
responseType - Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified response type is not Response.

method

public <T> T method(java.lang.String name,
                    Entity<?> entity,
                    GenericType<T> responseType)
         throws ClientException,
                WebApplicationException
Description copied from interface: SyncInvoker
Invoke an arbitrary method for the current request synchronously.

Specified by:
method in interface SyncInvoker
Type Parameters:
T - generic response entity type.
Parameters:
name - method name.
entity - request entity.
responseType - representation of a generic Java type the response entity will be converted to.
Returns:
invocation response.
Throws:
ClientException - in case the invocation processing has failed.
WebApplicationException - in case the response status code of the response returned by the server is not successful and the specified generic response type does not represent Response.


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