hudson.model
Class AsyncPeriodicWork

java.lang.Object
  extended by java.util.TimerTask
      extended by hudson.triggers.SafeTimerTask
          extended by hudson.model.PeriodicWork
              extended by hudson.model.AsyncPeriodicWork
All Implemented Interfaces:
ExtensionPoint, Runnable
Direct Known Subclasses:
ConnectionActivityMonitor, FingerprintCleanupThread, WorkspaceCleanupThread

public abstract class AsyncPeriodicWork
extends PeriodicWork

PeriodicWork that takes a long time to run.

Subclasses will implement the execute(TaskListener) method and can carry out a long-running task. This runs in a separate thread so as not to block the timer thread, and this class handles all those details.

Author:
Kohsuke Kawaguchi

Nested Class Summary
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
 String name
          Name of the work.
 
Fields inherited from class hudson.model.PeriodicWork
DAY, HOUR, logger, MIN
 
Constructor Summary
protected AsyncPeriodicWork(String name)
           
 
Method Summary
protected  StreamTaskListener createListener()
           
 void doRun()
          Schedules this periodic work now in a new thread, if one isn't already running.
protected abstract  void execute(TaskListener listener)
          Executes the task.
protected  File getLogFile()
          Determines the log file that records the result of this task.
 
Methods inherited from class hudson.model.PeriodicWork
all, getInitialDelay, getRecurrencePeriod
 
Methods inherited from class hudson.triggers.SafeTimerTask
run
 
Methods inherited from class java.util.TimerTask
cancel, scheduledExecutionTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public final String name
Name of the work.

Constructor Detail

AsyncPeriodicWork

protected AsyncPeriodicWork(String name)
Method Detail

doRun

public final void doRun()
Schedules this periodic work now in a new thread, if one isn't already running.

Specified by:
doRun in class SafeTimerTask

createListener

protected StreamTaskListener createListener()

getLogFile

protected File getLogFile()
Determines the log file that records the result of this task.


execute

protected abstract void execute(TaskListener listener)
                         throws IOException,
                                InterruptedException
Executes the task.

Parameters:
listener - Output sent will be reported to the users. (this work is TBD.)
Throws:
InterruptedException - The caller will record the exception and moves on.
IOException - The caller will record the exception and moves on.


Copyright © 2004-2013. All Rights Reserved.