hudson.model
Class TaskThread

java.lang.Object
  extended by java.lang.Thread
      extended by hudson.model.TaskThread
All Implemented Interfaces:
Runnable

public abstract class TaskThread
extends Thread

Thread for performing one-off task.

Designed to be used inside TaskAction.

Since:
1.191
Author:
Kohsuke Kawaguchi
See Also:
TaskAction

Nested Class Summary
static class TaskThread.ListenerAndText
          Tuple of TaskListener and AnnotatedLargeText, representing the interface for producing output and how to retrieve it later.
 
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
protected TaskThread(TaskAction owner, TaskThread.ListenerAndText output)
           
 
Method Summary
protected  void associateWith(TaskAction action)
          Registers that this TaskThread is run for the specified TaskAction.
protected  TaskThread.ListenerAndText createListener()
          Determines where the output of this TaskThread goes.
 boolean isRunning()
           
protected abstract  void perform(TaskListener listener)
          Do the actual work.
 Reader readAll()
           
 void run()
           
 void start()
          Starts the task execution asynchronously.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, 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, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaskThread

protected TaskThread(TaskAction owner,
                     TaskThread.ListenerAndText output)
Parameters:
output - Determines where the output from this task thread goes.
Method Detail

readAll

public Reader readAll()
               throws IOException
Throws:
IOException

associateWith

protected final void associateWith(TaskAction action)
Registers that this TaskThread is run for the specified TaskAction. This can be explicitly called from subtypes to associate a single TaskThread across multiple tag actions.


start

public void start()
Starts the task execution asynchronously.

Overrides:
start in class Thread

isRunning

public boolean isRunning()

createListener

protected TaskThread.ListenerAndText createListener()
                                             throws IOException
Determines where the output of this TaskThread goes.

Subclass can override this to send the output to a file, for example.

Throws:
IOException

run

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

perform

protected abstract void perform(TaskListener listener)
                         throws Exception
Do the actual work.

Throws:
Exception - The exception is recorded and reported as a failure.


Copyright © 2004-2013. All Rights Reserved.