com.sun.jini.jeri.internal.http
Class HttpClientConnection.OutboundRequestImpl

java.lang.Object
  extended by com.sun.jini.jeri.internal.http.Request
      extended by com.sun.jini.jeri.internal.http.HttpClientConnection.OutboundRequestImpl
All Implemented Interfaces:
OutboundRequest
Enclosing class:
HttpClientConnection

private class HttpClientConnection.OutboundRequestImpl
extends Request
implements OutboundRequest

HTTP-based implementation of OutboundRequest abstraction.


Field Summary
private  Header inHeader
           
private  StartLine inLine
           
private  boolean persist
           
private  MessageReader reader
           
private  MessageWriter writer
           
 
Constructor Summary
HttpClientConnection.OutboundRequestImpl()
           
 
Method Summary
(package private)  void addAckListener(AcknowledgmentSource.Listener listener)
          Method called internally to register acknowledgment listener.
(package private)  int available()
          Method called internally to gauge available inbound data.
(package private)  void done(boolean corrupt)
          Method called internally when request is finished.
(package private)  void endInput()
          Method called internally when finished reading inbound data.
(package private)  void endOutput()
          Method called internally to signal the end of outbound data.
 OutputStream getRequestOutputStream()
          Returns an OutputStream to write the request data to.
 InputStream getResponseInputStream()
          Returns an InputStream to read the response data from.
 InvocationConstraints getUnfulfilledConstraints()
          Returns the requirements that must be at least partially implemented by higher layers in order to fully satisfy the requirements for this request.
 void populateContext(Collection context)
          Populates the supplied collection with context information representing this request.
(package private)  int read(byte[] b, int off, int len)
          Method called internally to read inbound request/response data.
(package private)  boolean startInput()
          Method called internally before any inbound data is read.
(package private)  void startOutput()
          Method called internally before any outbound data is written.
(package private)  void write(byte[] b, int off, int len)
          Method called internally to write outbound request/response data.
 
Methods inherited from class com.sun.jini.jeri.internal.http.Request
abort, addAcknowledgmentListener, finish, getDeliveryStatus, getInputStream, getOutputStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.jini.jeri.OutboundRequest
abort, getDeliveryStatus
 

Field Detail

writer

private final MessageWriter writer

reader

private MessageReader reader

inLine

private StartLine inLine

inHeader

private Header inHeader

persist

private boolean persist
Constructor Detail

HttpClientConnection.OutboundRequestImpl

HttpClientConnection.OutboundRequestImpl()
                                   throws IOException
Throws:
IOException
Method Detail

populateContext

public void populateContext(Collection context)
Description copied from interface: OutboundRequest
Populates the supplied collection with context information representing this request.

Specified by:
populateContext in interface OutboundRequest
Parameters:
context - the context collection to populate

getUnfulfilledConstraints

public InvocationConstraints getUnfulfilledConstraints()
Description copied from interface: OutboundRequest
Returns the requirements that must be at least partially implemented by higher layers in order to fully satisfy the requirements for this request. This method may also return preferences that must be at least partially implemented by higher layers in order to fully satisfy some of the preferences for this request.

For any given constraint, there must be a clear delineation of which aspects (if any) must be implemented by the transport layer. This method must not return a constraint (as a requirement or a preference, directly or as an element of another constraint) unless this request implements all of those aspects. Also, this method must not return a constraint for which all aspects must be implemented by the transport layer. Most of the constraints in the net.jini.core.constraint package must be fully implemented by the transport layer and thus must not be returned by this method; the one exception is Integrity, for which the transport layer is responsible for the data integrity aspect and higher layers are responsible for the code integrity aspect.

For any ConstraintAlternatives in the constraints for this request, this method should only return a corresponding constraint if all of the alternatives satisfied by this request need to be at least partially implemented by higher layers in order to be fully satisfied.

Specified by:
getUnfulfilledConstraints in interface OutboundRequest
Returns:
the constraints for this request that must be partially or fully implemented by higher layers

getRequestOutputStream

public OutputStream getRequestOutputStream()
Description copied from interface: OutboundRequest
Returns an OutputStream to write the request data to. The sequence of bytes written to the returned stream will be the sequence of bytes sent as the body of this request.

After the entirety of the request has been written to the stream, the stream's close method must be invoked to ensure complete delivery of the request. It is possible that none of the data written to the returned stream will be delivered before close has been invoked (even if the stream's flush method had been invoked at any time). Note, however, that some or all of the data written to the stream may be delivered to (and processed by) the recipient before the stream's close method has been invoked.

After the stream's close method has been invoked, no more data may be written to the stream; writes subsequent to a close invocation will fail with an IOException.

If this method is invoked more than once, it will always return the identical stream object that it returned the first time (although the stream may be in a different state than it was upon return from the first invocation).

Specified by:
getRequestOutputStream in interface OutboundRequest
Returns:
the output stream to write request data to

getResponseInputStream

public InputStream getResponseInputStream()
Description copied from interface: OutboundRequest
Returns an InputStream to read the response data from. The sequence of bytes produced by reading from the returned stream will be the sequence of bytes received as the response data. When the entirety of the response has been successfully read, reading from the stream will indicate an EOF.

Users of an OutboundRequest must not expect any data to be available from the returned stream before the close method has been invoked on the stream returned by getRequestOutputStream; in other words, the user's request/response protocol must not require any part of a request to be a function of any part of its response.

It is possible, however, for data to be available from the returned stream before the close method has been invoked on, or even before the entirety of the request has been written to, the stream returned by getRequestOutputStream. Because such an early response might indicate, depending on the user's request/response protocol, that the recipient will not consider the entirety of the request, perhaps due to an error or other abnormal condition, the user may wish to process it expeditiously, rather than continuing to write the remainder of the request.

Invoking the close method of the returned stream will cause any subsequent read operations on the stream to fail with an IOException, although it will not terminate this request as a whole; in particular, the request may still be subsequently written to the stream returned by the getRequestOutputStream method. After close has been invoked on both the returned stream and the stream returned by getRequestOutputStream, the implementation may free all resources associated with this request.

If this method is invoked more than once, it will always return the identical stream object that it returned the first time (although the stream may be in a different state than it was upon return from the first invocation).

Specified by:
getResponseInputStream in interface OutboundRequest
Returns:
the input stream to read response data from

startOutput

void startOutput()
           throws IOException
Description copied from class: Request
Method called internally before any outbound data is written.

Specified by:
startOutput in class Request
Throws:
IOException

write

void write(byte[] b,
           int off,
           int len)
     throws IOException
Description copied from class: Request
Method called internally to write outbound request/response data.

Specified by:
write in class Request
Throws:
IOException

endOutput

void endOutput()
         throws IOException
Description copied from class: Request
Method called internally to signal the end of outbound data.

Specified by:
endOutput in class Request
Throws:
IOException

startInput

boolean startInput()
             throws IOException
Description copied from class: Request
Method called internally before any inbound data is read. Returns true if inbound data is valid, false otherwise (e.g., error message content).

Specified by:
startInput in class Request
Throws:
IOException

read

int read(byte[] b,
         int off,
         int len)
   throws IOException
Description copied from class: Request
Method called internally to read inbound request/response data.

Specified by:
read in class Request
Throws:
IOException

available

int available()
        throws IOException
Description copied from class: Request
Method called internally to gauge available inbound data.

Specified by:
available in class Request
Throws:
IOException

endInput

void endInput()
        throws IOException
Description copied from class: Request
Method called internally when finished reading inbound data.

Specified by:
endInput in class Request
Throws:
IOException

addAckListener

void addAckListener(AcknowledgmentSource.Listener listener)
Description copied from class: Request
Method called internally to register acknowledgment listener.

Specified by:
addAckListener in class Request

done

void done(boolean corrupt)
Description copied from class: Request
Method called internally when request is finished. If corrupt is true, the underlying transport channel has been left in an unknown state.

Specified by:
done in class Request


Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.