de.phleisch.app.itsucks.processing.impl
Class DataProcessorChainImpl

java.lang.Object
  extended by de.phleisch.app.itsucks.processing.impl.DataProcessorChainImpl
All Implemented Interfaces:
DataProcessorChain

public class DataProcessorChainImpl
extends java.lang.Object
implements DataProcessorChain

This is an implementation of an processor chain.

Author:
olli

Nested Class Summary
protected  class DataProcessorChainImpl.ContainerRuntimeException
           
protected  class DataProcessorChainImpl.DataConsumerImpl
           
 
Field Summary
protected  java.util.List<DataProcessor> mDataProcessors
           
protected  DataRetriever mDataRetriever
           
protected  boolean mInitialized
           
protected  Job mJob
           
protected  JobManager mJobManager
           
 
Constructor Summary
DataProcessorChainImpl()
           
DataProcessorChainImpl(java.util.List<DataProcessor> pProcessorsForJob)
           
 
Method Summary
protected  void abort()
           
 void addDataProcessor(DataProcessor pDataProcessor)
          Adds an data processor at the end of the chain.
 void addDataProcessor(java.util.List<DataProcessor> pProcessorsForJob)
          Adds an list of data processors at the end of the chain.
 boolean canResume()
          Checks if all processors in the chain are supporting resuming.
 boolean containsConsumer()
          Returns if the chain contains at least one consumer.
protected  void dispatchChunk(DataChunk pDataChunk)
           
 void finish()
          Finalizes the chain and all processors in it.
 java.util.List<DataProcessor> getDataProcessors()
          Returns a list with all data processors in the chain.
 DataRetriever getDataRetriever()
          Gets the data retriever.
 Job getJob()
          Gets the job which the chain is assigned to.
 JobManager getJobManager()
          Gets the job manager.
 long getProcessedBytes()
          Gets the already processed bytes in the chain.
 void init()
          Initializes all the chain and all processors in it.
protected  void internalRun()
           
 void replaceDataProcessor(DataProcessor pOldDataProcessor, DataProcessor pNewDataProcessor)
          Replaces an data processor in the chain.
 void resumeAt(long pResumeOffset)
          Advises all processors to resume at the given position.
protected  void rollback()
           
 void run()
          Starts the data retriever and processes the data in the processor chain.
 void setDataRetriever(DataRetriever pDataRetriever)
          Sets the data retriever.
 void setJob(Job pJob)
          Sets the job which the chain is assigned to.
 void setJobManager(JobManager pJobManager)
          Sets the job manager.
 int size()
          Returns the count of registerd processors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDataProcessors

protected java.util.List<DataProcessor> mDataProcessors

mDataRetriever

protected DataRetriever mDataRetriever

mJob

protected Job mJob

mJobManager

protected JobManager mJobManager

mInitialized

protected boolean mInitialized
Constructor Detail

DataProcessorChainImpl

public DataProcessorChainImpl()

DataProcessorChainImpl

public DataProcessorChainImpl(java.util.List<DataProcessor> pProcessorsForJob)
Method Detail

addDataProcessor

public void addDataProcessor(java.util.List<DataProcessor> pProcessorsForJob)
Description copied from interface: DataProcessorChain
Adds an list of data processors at the end of the chain.

Specified by:
addDataProcessor in interface DataProcessorChain

addDataProcessor

public void addDataProcessor(DataProcessor pDataProcessor)
Description copied from interface: DataProcessorChain
Adds an data processor at the end of the chain.

Specified by:
addDataProcessor in interface DataProcessorChain

replaceDataProcessor

public void replaceDataProcessor(DataProcessor pOldDataProcessor,
                                 DataProcessor pNewDataProcessor)
Description copied from interface: DataProcessorChain
Replaces an data processor in the chain.

Specified by:
replaceDataProcessor in interface DataProcessorChain

getDataProcessors

public java.util.List<DataProcessor> getDataProcessors()
Description copied from interface: DataProcessorChain
Returns a list with all data processors in the chain.

Specified by:
getDataProcessors in interface DataProcessorChain
Returns:

init

public void init()
          throws ProcessingException,
                 AbortProcessingException
Description copied from interface: DataProcessorChain
Initializes all the chain and all processors in it.

Specified by:
init in interface DataProcessorChain
Throws:
ProcessingException
AbortProcessingException

run

public void run()
         throws java.io.IOException,
                ProcessingException,
                AbortProcessingException
Description copied from interface: DataProcessorChain
Starts the data retriever and processes the data in the processor chain.

Specified by:
run in interface DataProcessorChain
Throws:
java.io.IOException
ProcessingException
AbortProcessingException

internalRun

protected void internalRun()
                    throws java.io.IOException,
                           ProcessingException
Throws:
java.io.IOException
ProcessingException

finish

public void finish()
Description copied from interface: DataProcessorChain
Finalizes the chain and all processors in it.

Specified by:
finish in interface DataProcessorChain

rollback

protected void rollback()

abort

protected void abort()

dispatchChunk

protected void dispatchChunk(DataChunk pDataChunk)
                      throws ProcessingException
Throws:
ProcessingException

canResume

public boolean canResume()
Description copied from interface: DataProcessorChain
Checks if all processors in the chain are supporting resuming.

Specified by:
canResume in interface DataProcessorChain
Returns:

resumeAt

public void resumeAt(long pResumeOffset)
Description copied from interface: DataProcessorChain
Advises all processors to resume at the given position.

Specified by:
resumeAt in interface DataProcessorChain

setDataRetriever

public void setDataRetriever(DataRetriever pDataRetriever)
Description copied from interface: DataProcessorChain
Sets the data retriever.

Specified by:
setDataRetriever in interface DataProcessorChain

getDataRetriever

public DataRetriever getDataRetriever()
Description copied from interface: DataProcessorChain
Gets the data retriever.

Specified by:
getDataRetriever in interface DataProcessorChain
Returns:

setJobManager

public void setJobManager(JobManager pJobManager)
Description copied from interface: DataProcessorChain
Sets the job manager.

Specified by:
setJobManager in interface DataProcessorChain

getJobManager

public JobManager getJobManager()
Description copied from interface: DataProcessorChain
Gets the job manager.

Specified by:
getJobManager in interface DataProcessorChain
Returns:

setJob

public void setJob(Job pJob)
Description copied from interface: DataProcessorChain
Sets the job which the chain is assigned to.

Specified by:
setJob in interface DataProcessorChain

getJob

public Job getJob()
Description copied from interface: DataProcessorChain
Gets the job which the chain is assigned to.

Specified by:
getJob in interface DataProcessorChain
Returns:

size

public int size()
Description copied from interface: DataProcessorChain
Returns the count of registerd processors.

Specified by:
size in interface DataProcessorChain
Returns:

getProcessedBytes

public long getProcessedBytes()
Description copied from interface: DataProcessorChain
Gets the already processed bytes in the chain.

Specified by:
getProcessedBytes in interface DataProcessorChain
Returns:

containsConsumer

public boolean containsConsumer()
Description copied from interface: DataProcessorChain
Returns if the chain contains at least one consumer.

Specified by:
containsConsumer in interface DataProcessorChain
Returns:


Copyright © 2008. All Rights Reserved.