uk.org.ogsadai.activity
Class CallThroughExternalPipe
java.lang.Object
|
+--uk.org.ogsadai.activity.CallThroughExternalPipe
- All Implemented Interfaces:
- BlockReader, BlockWriter, Pipe
- class CallThroughExternalPipe
- extends java.lang.Object
- implements Pipe
This is a simple unsynchronized Pipe with a variable
length internal buffer. It contains an Activity
and
when the consumer reads data from the pipe, this activity is
processed incrementally to generate the data that will be
returned. In other words, reading data from the pipe effectively
drives the processing of the activity.
- Author:
- The OGSA-DAI Project Team
Field Summary |
private static java.lang.String |
COPYRIGHT_NOTICE
Copyright statement. |
private Activity |
mActivity
The activity that outputs data into this pipe when processed. |
private java.util.List |
mBuffer
Stores the blocks of data put into the pipe by the activity. |
private boolean |
mClosed
Indicates whether or not the pipe has been closed. |
private ProcessingStatus |
mStatus
The status of the request containing the activity the has the pipe. |
Method Summary |
void |
close()
Closes the block writer to indicate that there are no more
blocks are to be written. |
boolean |
hasNext()
Indicates whether or not there are any more blocks of data to be read
from the block reader. |
boolean |
isOpen()
Indicates whether or not the block writer is open for writing via the
put method. |
java.lang.Object |
next()
Gets the next block of data contained in the block reader. |
private void |
process()
Processes the handler until its activity has generated some
output. |
void |
put(java.lang.Object block)
Writes the specified block of output data. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
COPYRIGHT_NOTICE
private static final java.lang.String COPYRIGHT_NOTICE
- Copyright statement.
- See Also:
- Constant Field Values
mActivity
private final Activity mActivity
- The activity that outputs data into this pipe when processed.
mBuffer
private final java.util.List mBuffer
- Stores the blocks of data put into the pipe by the activity.
mClosed
private boolean mClosed
- Indicates whether or not the pipe has been closed.
mStatus
private ProcessingStatus mStatus
- The status of the request containing the activity the has the pipe.
CallThroughExternalPipe
public CallThroughExternalPipe(Activity activity,
ProcessingStatus status)
- Constructs a
CallThroughPipe
that will pull data
from the specified source Activity
. When another
activity attempts to read data from the pipe, the source
activity is processed enough to generate the data.
- Parameters:
activity
- Source Activity
status
- Status of the request containing the activity
hasNext
public boolean hasNext()
- Description copied from interface:
BlockReader
- Indicates whether or not there are any more blocks of data to be read
from the block reader.
- Specified by:
hasNext
in interface BlockReader
- Returns:
- true if there are more blocks to be read or false otherwise
next
public java.lang.Object next()
- Description copied from interface:
BlockReader
- Gets the next block of data contained in the block reader.
- Specified by:
next
in interface BlockReader
- Returns:
- an
Object
put
public void put(java.lang.Object block)
- Description copied from interface:
BlockWriter
- Writes the specified block of output data.
- Specified by:
put
in interface BlockWriter
- Parameters:
block
- the Object
block to write
process
private void process()
- Processes the handler until its activity has generated some
output. Note that this may be more than one block. If the
activity finishes and there is no more data, then the internal
mHasNext
flag is set to false
.
If a Throwable
should inadvertently occur during
the activity's process
method, catch it, wrap it
in an ActivityExecutionException
and instruct
the activity to save a reference using its
setError
method.
close
public void close()
- Description copied from interface:
BlockWriter
- Closes the block writer to indicate that there are no more
blocks are to be written. After close has been called, the
put
method should no longer be used.
- Specified by:
close
in interface BlockWriter
isOpen
public boolean isOpen()
- Description copied from interface:
BlockWriter
- Indicates whether or not the block writer is open for writing via the
put
method. After the close
method has been
invoked this method should return false
.
- Specified by:
isOpen
in interface BlockWriter
- Returns:
- A boolean value indicating whether this block writer is open for
writing