com.sun.jersey.api.client
Class TerminatingClientHandler

java.lang.Object
  extended by com.sun.jersey.api.client.TerminatingClientHandler
All Implemented Interfaces:
ClientHandler
Direct Known Subclasses:
URLConnectionClientHandler

public abstract class TerminatingClientHandler
extends java.lang.Object
implements ClientHandler

A terminating client handler that is invoked to produce an HTTP request to send to a resource and process the HTTP response received from the resource.

This class can be extended to integrate HTTP protocol functionality with the Client API. Utilitly methods are provided for converting header values and writing a request entity.

Author:
[email protected]

Nested Class Summary
protected static interface TerminatingClientHandler.RequestEntityWriter
          A writer for writing a request entity.
protected static interface TerminatingClientHandler.RequestEntityWriterListener
          A lister for listensing to events when writing a request entity.
 
Field Summary
protected static java.lang.annotation.Annotation[] EMPTY_ANNOTATIONS
           
 
Constructor Summary
TerminatingClientHandler()
           
 
Method Summary
protected  MessageBodyWorkers getMessageBodyWorkers()
           
protected  TerminatingClientHandler.RequestEntityWriter getRequestEntityWriter(ClientRequest ro)
          Get a request entity writer capable of writing the request entity.
protected  java.lang.String headerValueToString(java.lang.Object headerValue)
          Convert a header value to a String instance.
protected  void writeRequestEntity(ClientRequest ro, TerminatingClientHandler.RequestEntityWriterListener listener)
          Write a request entity using an appropriate message body writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.jersey.api.client.ClientHandler
handle
 

Field Detail

EMPTY_ANNOTATIONS

protected static final java.lang.annotation.Annotation[] EMPTY_ANNOTATIONS
Constructor Detail

TerminatingClientHandler

public TerminatingClientHandler()
Method Detail

getMessageBodyWorkers

protected MessageBodyWorkers getMessageBodyWorkers()

headerValueToString

protected java.lang.String headerValueToString(java.lang.Object headerValue)
Convert a header value to a String instance.

This method defers to ClientRequest.getHeaderValue(java.lang.Object).

Parameters:
headerValue - the header value.
Returns:
the string instance.

getRequestEntityWriter

protected TerminatingClientHandler.RequestEntityWriter getRequestEntityWriter(ClientRequest ro)
Get a request entity writer capable of writing the request entity.

Parameters:
ro - the client request.
Returns:
the request entity writer.

writeRequestEntity

protected void writeRequestEntity(ClientRequest ro,
                                  TerminatingClientHandler.RequestEntityWriterListener listener)
                           throws java.io.IOException
Write a request entity using an appropriate message body writer.

The method TerminatingClientHandler.RequestEntityWriterListener.onRequestEntitySize(long) will be invoked with the size of the request entity to be serialized. The method TerminatingClientHandler.RequestEntityWriterListener.onGetOutputStream() will be invoked when the output stream is required to write the request entity.

Parameters:
ro - the client request containing the request entity. If the request entity is null then the method will not write any entity.
listener - the request entity listener.
Throws:
java.io.IOException


Copyright © 2010 Oracle Corporation. All Rights Reserved.