A uniform interface for invoking HTTP requests.
Any Java type for a response entity, that is supported by the client configuration of the client, may be declared using Class<T>
where T
is the Java type, or using {@link GenericType} where the generic parameter is the Java type.
Any Java type instance for a request entity, that is supported by the client configuration of the client, can be passed. If generic information is required then an instance of {@link javax.ws.rs.core.GenericEntity} maybe used.
A type of {@link ClientResponse} declaredfor the response entity may be used to obtain the status, headers and response entity.
If any type, other than {@link ClientResponse}, is declared and the response status is greater than or equal to 300 then a {@link UniformInterfaceException} exceptionwill be thrown, from which the {@link ClientResponse} instance can beaccessed.
In the following cases it is necessary to close the response, when response processing has completed, to ensure that underlying resources are correctly released.
If a response entity is declared of the type {@link ClientResponse}or of a type that is assignable to {@link java.io.Closeable}(such as {@link java.io.InputStream}) then the response must be either: 1) closed by invoking the method {@link ClientResponse#close() } or{@link java.io.Closeable#close}; or 2) all bytes of response entity must be read.
If a {@link UniformInterfaceException} isthrown then by default the response entity is automatically buffered and the underlying resources are correctly released. See the following property for more details: {@link ClientConfig#PROPERTY_BUFFER_RESPONSE_ENTITY_ON_EXCEPTION}.
@author Paul.Sandoz@Sun.Com
@see com.sun.jersey.api.client