xsmeral.pipe
Class LocalObjectSource<O>

java.lang.Object
  extended by xsmeral.pipe.AbstractObjectProcessor
      extended by xsmeral.pipe.LocalObjectSource<O>
Type Parameters:
O - Output object type
All Implemented Interfaces:
Runnable, ContextAware, ObjectProcessor, ObjectSource<O>

@ObjectProcessorInterface(out=java.lang.Object.class)
public class LocalObjectSource<O>
extends AbstractObjectProcessor
implements ObjectSource<O>

An object processor in the role of an object source, produces objects. Can only be placed as the first processor in a processor chain. Provides default ObjectProcessorInterface set to Objects.
Uses ArrayBlockingQueue as the output buffer.


Nested Class Summary
 
Nested classes/interfaces inherited from interface xsmeral.pipe.interfaces.ObjectProcessor
ObjectProcessor.Status
 
Field Summary
protected  ObjectSink<O> next
          Reference to the next processor in chain.
protected  BlockingQueue<O> outBuffer
          A buffer between the current and the next processor.
protected  int outBufferCapacity
          Output buffer capacity, defaults to 10000 objects
 
Fields inherited from class xsmeral.pipe.AbstractObjectProcessor
canStart, context, status
 
Constructor Summary
LocalObjectSource()
          Instantiates the output buffer, set to the default capacity
LocalObjectSource(BlockingQueue<O> outBuffer)
          Sets the output buffer to the one given
 
Method Summary
 ObjectSink<O> getNext()
          Returns the next processor in chain.
 BlockingQueue<O> getOutBuffer()
          Returns the output buffer of this processor.
protected  void handleStoppedSink()
          Called in case the next processor is stopped during a write operation.
 void next(ObjectSink<O> sink)
          Sets the next processor in the chain and sets this as its previous.
protected  void process()
          Called by the processor itself from run().
protected  void setNext(ObjectSink<O> sink)
          Sets the next processor, without calling prev() on the sink.
protected  void setOutBuffer(BlockingQueue<O> buffer)
          Sets the output buffer, used for object flow redirection.
protected  void write(O o)
          Puts one object to the output buffer
 
Methods inherited from class xsmeral.pipe.AbstractObjectProcessor
canStart, failStart, failStart, failStart, getContext, getInType, getOutType, getParams, getStatus, initContext, initContextSet, initialize, initializeInternal, initPostContext, initWithContext, postRun, preRun, requestStop, 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.ObjectSource
getOutType
 

Field Detail

outBuffer

protected BlockingQueue<O> outBuffer
A buffer between the current and the next processor.


next

protected ObjectSink<O> next
Reference to the next processor in chain.


outBufferCapacity

protected int outBufferCapacity
Output buffer capacity, defaults to 10000 objects

Constructor Detail

LocalObjectSource

public LocalObjectSource()
Instantiates the output buffer, set to the default capacity


LocalObjectSource

public LocalObjectSource(BlockingQueue<O> outBuffer)
Sets the output buffer to the one given

Method Detail

write

protected final void write(O o)
                    throws ProcessorStoppedException
Puts one object to the output buffer

Parameters:
o - The object to write
Throws:
SinkStoppedException - If the sink is in STOPPED state and thus no longer reads the buffer
Calls handleStoppedSink() immediately before throwing.
ProcessorStoppedException

getOutBuffer

public final BlockingQueue<O> getOutBuffer()
Description copied from interface: ObjectSource
Returns the output buffer of this processor.

Specified by:
getOutBuffer in interface ObjectSource<O>

setOutBuffer

protected final void setOutBuffer(BlockingQueue<O> buffer)
Sets the output buffer, used for object flow redirection.


setNext

protected final void setNext(ObjectSink<O> sink)
Sets the next processor, without calling prev() on the sink.


next

public final void next(ObjectSink<O> sink)
Description copied from interface: ObjectSource
Sets the next processor in the chain and sets this as its previous.

Specified by:
next in interface ObjectSource<O>
Parameters:
sink - The next processor

getNext

public final ObjectSink<O> getNext()
Description copied from interface: ObjectSource
Returns the next processor in chain.

Specified by:
getNext in interface ObjectSource<O>

handleStoppedSink

protected void handleStoppedSink()
Called in case the next processor is stopped during a write operation. Can be used, for example, to persist objects left in the buffer.


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.