org.glassfish.jersey.client
Class JerseyClient

java.lang.Object
  extended by org.glassfish.jersey.client.JerseyClient
All Implemented Interfaces:
Client

public class JerseyClient
extends java.lang.Object
implements Client

Jersey implementation of JAX-RS JerseyClient contract.

Author:
Marek Potociar (marek.potociar at oracle.com)

Constructor Summary
protected JerseyClient()
          Create a new Jersey client instance using a default configuration.
protected JerseyClient(Configurable configuration)
          Create a new Jersey client instance.
 
Method Summary
 void addListener(org.glassfish.jersey.client.JerseyClient.LifecycleListener listener)
          Add a new client lifecycle listener.
 void close()
          Close client instance and all it's associated resources.
 ClientConfig configuration()
          Get access to the underlying configuration of the client instance.
 JerseyInvocation.Builder invocation(Link link)
          Build an invocation builder from a link.
 boolean isClosed()
          Check client state.
 JerseyWebTarget target(Link link)
          Build a new web resource target.
 JerseyWebTarget target(java.lang.String uri)
          Build a new web resource target.
 JerseyWebTarget target(java.net.URI uri)
          Build a new web resource target.
 JerseyWebTarget target(UriBuilder uriBuilder)
          Build a new web resource target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JerseyClient

protected JerseyClient()
Create a new Jersey client instance using a default configuration.


JerseyClient

protected JerseyClient(Configurable configuration)
Create a new Jersey client instance.

Parameters:
configuration - jersey client configuration.
Method Detail

close

public void close()
Description copied from interface: Client
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.

Specified by:
close in interface Client

addListener

public void addListener(org.glassfish.jersey.client.JerseyClient.LifecycleListener listener)
Add a new client lifecycle listener.

Parameters:
listener - client lifecycle listener.

isClosed

public boolean isClosed()
Check client state.

Returns:
true if current JerseyClient instance is closed, otherwise false.
See Also:
close()

configuration

public ClientConfig configuration()
Description copied from interface: Client
Get access to the underlying configuration of the client instance.

Specified by:
configuration in interface Client
Returns:
a mutable client configuration.

target

public JerseyWebTarget target(java.lang.String uri)
                       throws java.lang.IllegalArgumentException,
                              java.lang.NullPointerException
Description copied from interface: Client
Build a new web resource target.

Specified by:
target in interface Client
Parameters:
uri - web resource URI. May contain template parameters. Must not be null.
Returns:
web resource target bound to the provided URI.
Throws:
java.lang.IllegalArgumentException - in case the supplied string is not a valid URI template.
java.lang.NullPointerException - in case the supplied argument is null.

target

public JerseyWebTarget target(java.net.URI uri)
                       throws java.lang.NullPointerException
Description copied from interface: Client
Build a new web resource target.

Specified by:
target in interface Client
Parameters:
uri - web resource URI. Must not be null.
Returns:
web resource target bound to the provided URI.
Throws:
java.lang.NullPointerException - in case the supplied argument is null.

target

public JerseyWebTarget target(UriBuilder uriBuilder)
                       throws java.lang.NullPointerException
Description copied from interface: Client
Build a new web resource target.

Specified by:
target in interface Client
Parameters:
uriBuilder - web resource URI represented as URI builder. Must not be null.
Returns:
web resource target bound to the provided URI.
Throws:
java.lang.NullPointerException - in case the supplied argument is null.

target

public JerseyWebTarget target(Link link)
                       throws java.lang.NullPointerException
Description copied from interface: Client
Build a new web resource target.

Specified by:
target in interface Client
Parameters:
link - link to a web resource. Must not be null.
Returns:
web resource target bound to the linked web resource.
Throws:
java.lang.NullPointerException - in case the supplied argument is null.

invocation

public JerseyInvocation.Builder invocation(Link link)
                                    throws java.lang.NullPointerException,
                                           java.lang.IllegalArgumentException
Description copied from interface: Client

Build an invocation builder from a link. It uses the URI and the type of the link to initialize the invocation builder. The type is used as the initial value for the HTTP Accept header, if present.

Specified by:
invocation in interface Client
Parameters:
link - link to build invocation from. Must not be null.
Returns:
newly created invocation builder.
Throws:
java.lang.NullPointerException - in case link is null.
java.lang.IllegalArgumentException


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