net.jini.jeri.connection
Class ConnectionManager.Outbound

java.lang.Object
  extended by net.jini.jeri.connection.ConnectionManager.Outbound
All Implemented Interfaces:
OutboundRequest
Enclosing class:
ConnectionManager

private static final class ConnectionManager.Outbound
extends Object
implements OutboundRequest

Outbound request wrapper around the outbound request created by the mux.


Nested Class Summary
private  class ConnectionManager.Outbound.Input
          Wrapper for the response input stream of an outbound request, used to call readResponseData on the underlying connection before subsequent data is read by higher levels.
 
Field Summary
private  Connection c
          The connection on which the outbound request originates.
private  OutboundRequestHandle handle
          The outbound request handle.
private  InputStream in
          Wrapper around the mux's response input stream.
private  OutboundRequest req
          The outbound request created by the mux.
private  boolean status
          Delivery status override from readResponseData.
 
Constructor Summary
ConnectionManager.Outbound(OutboundRequest req, Connection c, OutboundRequestHandle handle)
           
 
Method Summary
 void abort()
          Terminates this request, freeing all associated resources.
 boolean getDeliveryStatus()
          False if readResponseData returned an exception, otherwise pass-through to the underlying request.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

req

private final OutboundRequest req
The outbound request created by the mux.


c

private final Connection c
The connection on which the outbound request originates.


handle

private final OutboundRequestHandle handle
The outbound request handle.


in

private final InputStream in
Wrapper around the mux's response input stream.


status

private boolean status
Delivery status override from readResponseData.

Constructor Detail

ConnectionManager.Outbound

ConnectionManager.Outbound(OutboundRequest req,
                           Connection c,
                           OutboundRequestHandle handle)
Method Detail

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

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

getDeliveryStatus

public boolean getDeliveryStatus()
False if readResponseData returned an exception, otherwise pass-through to the underlying request.

Specified by:
getDeliveryStatus in interface OutboundRequest
Returns:
false if data written for this request has definitely not been processed by the recipient, and true if data written for this request may have been at least partially processed by the recipient

abort

public void abort()
Description copied from interface: OutboundRequest
Terminates this request, freeing all associated resources.

This method may be invoked at any stage of the processing of the request.

After this method has been invoked, I/O operations on the streams returned by the getRequestOutputStream and getResponseInputStream methods will fail with an IOException, except some operations that may succeed because they only affect data in local I/O buffers.

If this method is invoked before the close method has been invoked on the stream returned by getRequestOutputStream, there is no guarantee that any or none of the data written to the stream so far will be delivered; the implication of such an invocation of this method is that the user is no longer interested in the successful delivery of the request.

Specified by:
abort in interface OutboundRequest


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