xsmeral.pipe
Class LocalObjectSink<I>

java.lang.Object
  extended by xsmeral.pipe.AbstractObjectProcessor
      extended by xsmeral.pipe.LocalObjectSink<I>
Type Parameters:
I - Input object type
All Implemented Interfaces:
Runnable, ContextAware, ObjectProcessor, ObjectSink<I>

@ObjectProcessorInterface(in=java.lang.Object.class)
public class LocalObjectSink<I>
extends AbstractObjectProcessor
implements ObjectSink<I>

An object processor in the role of an object sink, usually persists objects. Can only be placed as the last processor in a processor chain. Provides default ObjectProcessorInterface set to Objects.


Nested Class Summary
 
Nested classes/interfaces inherited from interface xsmeral.pipe.interfaces.ObjectProcessor
ObjectProcessor.Status
 
Field Summary
protected  ObjectSource<I> prev
          Reference to the previous processor in chain.
 
Fields inherited from class xsmeral.pipe.AbstractObjectProcessor
canStart, context, status
 
Constructor Summary
LocalObjectSink()
           
 
Method Summary
 ObjectSource<I> getPrev()
          Returns the previous processor in chain.
protected  void handleStoppedSource()
          Called in case the previous processor is stopped during a read operation.
 void prev(ObjectSource<I> src)
          Sets this processor as the next in the chain, after the given processor.
protected  void process()
          Called by the processor itself from run().
protected  I read()
          Reads one object from the top of the buffer of the previous processor.
 void requestStop()
          Requests the processor to stop and sets its status to STOPPING.
 
Methods inherited from class xsmeral.pipe.AbstractObjectProcessor
canStart, failStart, failStart, failStart, getContext, getInType, getOutType, getParams, getStatus, initContext, initContextSet, initialize, initializeInternal, initPostContext, initWithContext, postRun, preRun, run, setContext, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface xsmeral.pipe.interfaces.ObjectSink
getInType
 

Field Detail

prev

protected ObjectSource<I> prev
Reference to the previous processor in chain. Used to access its buffer and status.

Constructor Detail

LocalObjectSink

public LocalObjectSink()
Method Detail

read

protected final I read()
                throws ProcessorStoppedException
Reads one object from the top of the buffer of the previous processor.

Returns:
The read object
Throws:
SourceStoppedException - If the previous processor is in STOPPED state. Calls handleStoppedSource() immediately before throwing.
ProcessorStoppedException

prev

public final void prev(ObjectSource<I> src)
Description copied from interface: ObjectSink
Sets this processor as the next in the chain, after the given processor.

Specified by:
prev in interface ObjectSink<I>
Parameters:
src - The previous processor

getPrev

public final ObjectSource<I> getPrev()
Description copied from interface: ObjectSink
Returns the previous processor in chain.

Specified by:
getPrev in interface ObjectSink<I>

requestStop

public final void requestStop()
Description copied from interface: ObjectProcessor
Requests the processor to stop and sets its status to STOPPING. There is no limit to the time it takes the processor to stop, it should however stop as soon as possible.
Only the first processor in chain should be requested to stop.

Specified by:
requestStop in interface ObjectProcessor
Overrides:
requestStop in class AbstractObjectProcessor

handleStoppedSource

protected void handleStoppedSource()
Called in case the previous processor is stopped during a read operation.


process

protected void process()
                throws ProcessorStoppedException
Called by the processor itself from run(). Should process one object and return. More information in description of AbstractObjectProcessor class, section "Running". This implementation is empty and should be overridden.

Specified by:
process in class AbstractObjectProcessor
Throws:
ProcessorStoppedException - If a neighboring processor has stopped.