net.sf.filePiper.model
Class ProcessorThread

java.lang.Object
  extended by java.lang.Thread
      extended by net.sf.filePiper.model.ProcessorThread
All Implemented Interfaces:
Runnable, FileProcessorEnvironment, PipeComponent

public class ProcessorThread
extends Thread
implements FileProcessorEnvironment, PipeComponent


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ProcessorThread(FileProcessor p, Pipeline pipeline, PipeComponent nextPipeComponent, PipelineEnvironment reporting)
           
 
Method Summary
 OutputStream createOutputStream(InputFileInfo info)
           
 void finished()
          Notififaction that the preceding processes (in the processing pipe) have finished the whole batch.
 ExecutionPhase getCurrentPhase()
          Get the current execution phase of the processor environment.
 OutputStream getOutputStream(InputFileInfo info)
          Get an output stream for writing.
 Pipeline getPipeline()
          Get the object representing the whole file processing pipeline.
 void processInputStream(InputStream input, InputFileInfo info)
           
 void run()
           
 boolean shouldContinue()
          Said that the pipeline processing should continue (until all the threads are finished).
 String toString()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProcessorThread

public ProcessorThread(FileProcessor p,
                       Pipeline pipeline,
                       PipeComponent nextPipeComponent,
                       PipelineEnvironment reporting)
Method Detail

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

toString

public String toString()
Overrides:
toString in class Thread

processInputStream

public void processInputStream(InputStream input,
                               InputFileInfo info)
Specified by:
processInputStream in interface PipeComponent

createOutputStream

public OutputStream createOutputStream(InputFileInfo info)
                                throws IOException
Specified by:
createOutputStream in interface PipeComponent
Throws:
IOException

finished

public void finished()
              throws IOException
Description copied from interface: PipeComponent
Notififaction that the preceding processes (in the processing pipe) have finished the whole batch.

Specified by:
finished in interface PipeComponent
Throws:
IOException

getOutputStream

public OutputStream getOutputStream(InputFileInfo info)
                             throws IOException
Description copied from interface: FileProcessorEnvironment
Get an output stream for writing.
The output stream will be created based on the information passed in the info (the proposed name) and the global pipeline output settings.

Specified by:
getOutputStream in interface FileProcessorEnvironment
Parameters:
info - info about the file to create. The proposed name contained in this info can be used to create the final file name if the pipeline is configured to use it.
Returns:
a suitable output stream.
Throws:
IOException

shouldContinue

public boolean shouldContinue()
Said that the pipeline processing should continue (until all the threads are finished).
This will return false if 'abort' was pressed or if an exception occurred in any of the processor.

Specified by:
shouldContinue in interface FileProcessorEnvironment
Returns:
true if the file processing shoud continue, false if it was aborted.

getPipeline

public Pipeline getPipeline()
Description copied from interface: FileProcessorEnvironment
Get the object representing the whole file processing pipeline.
In general, a FileProcessor does not need to access the Pipeline directly.

Specified by:
getPipeline in interface FileProcessorEnvironment
Returns:
the object representing the whole file processing pipeline.

getCurrentPhase

public ExecutionPhase getCurrentPhase()
Description copied from interface: FileProcessorEnvironment
Get the current execution phase of the processor environment.

Specified by:
getCurrentPhase in interface FileProcessorEnvironment
Returns:
the current execution phase of the processor environment.


Copyright © 2010. All Rights Reserved.