Class SPRunner<T>
- java.lang.Object
-
- com.inductiveautomation.rm.base.RMListenerList
-
- com.inductiveautomation.rm.base.RMObject
-
- com.inductiveautomation.snap.util.SPRunner<T>
-
- All Implemented Interfaces:
RMPropertyChanger
,java.lang.Cloneable
- Direct Known Subclasses:
SwingRunner
public abstract class SPRunner<T> extends RMObject
A class for running operations in the background.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SPRunner.Status
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ActivityText_Prop
static java.lang.String
Progress_Prop
static java.lang.String
Status_Prop
-
Constructor Summary
Constructors Constructor Description SPRunner()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
cancel()
Cancels the runner.void
cancelled(java.lang.Exception e)
The method to run when cancelled.void
failure(java.lang.Exception e)
The method to run on failure.void
finished()
The method to run when finished (after success()/failure() call).java.lang.String
getActivityText()
Returns a description of the current activity beging performed.long
getElapsedTime()
Returns the elapsed time.long
getEndTime()
Returns the end time.java.lang.Throwable
getExeption()
Returns the exception.java.lang.String
getName()
Returns the name of runner (and thread).double
getProgress()
Returns the progress value.T
getResult()
Returns the result.long
getStartTime()
Returns the start time.SPRunner.Status
getStatus()
Returns the status.protected long
getSystemTime()
Returns the system time.java.lang.Thread
getThread()
Returns the thread.protected void
invokeFinished()
Runs the success method.protected void
invokeRun()
Runs the run method.boolean
isActive()
Returns whether thread is still active.boolean
isCancelled()
Whether runner has been cancelled.SPRunner<T>
join()
Joins the runner.SPRunner<T>
join(int aTimeout)
Joins the runner.abstract T
run()
The method to run.void
setActivityText(java.lang.String aString)
Sets a description of the current activity beging performed.void
setName(java.lang.String aName)
Sets the name of runner (and thread).void
setProgress(double aValue)
Sets the progress value.protected void
setStatus(SPRunner.Status aStatus)
Sets the status.SPRunner<T>
start()
Starts the runner.void
success(T aResult)
The method run on success.-
Methods inherited from class com.inductiveautomation.rm.base.RMObject
addPropertyChangeListener, animUpdate, firePropertyChange, firePropertyChange, firePropertyChange, getPCEvent, removePropertyChangeListener, sendPropertyChange, toString
-
Methods inherited from class com.inductiveautomation.rm.base.RMListenerList
addListener, clone, getListener, getListenerCount, getListenerCount, getListenerList, getListeners, hasListeners, removeListener
-
-
-
-
Field Detail
-
Progress_Prop
public static final java.lang.String Progress_Prop
- See Also:
- Constant Field Values
-
ActivityText_Prop
public static final java.lang.String ActivityText_Prop
- See Also:
- Constant Field Values
-
Status_Prop
public static final java.lang.String Status_Prop
- See Also:
- Constant Field Values
-
-
Method Detail
-
getProgress
public double getProgress()
Returns the progress value.
-
setProgress
public void setProgress(double aValue)
Sets the progress value.
-
getName
public java.lang.String getName()
Returns the name of runner (and thread).
-
setName
public void setName(java.lang.String aName)
Sets the name of runner (and thread).
-
getActivityText
public java.lang.String getActivityText()
Returns a description of the current activity beging performed.
-
setActivityText
public void setActivityText(java.lang.String aString)
Sets a description of the current activity beging performed.
-
getStatus
public SPRunner.Status getStatus()
Returns the status.
-
setStatus
protected void setStatus(SPRunner.Status aStatus)
Sets the status.
-
getThread
public java.lang.Thread getThread()
Returns the thread.
-
isActive
public boolean isActive()
Returns whether thread is still active.
-
isCancelled
public boolean isCancelled()
Whether runner has been cancelled.
-
getStartTime
public long getStartTime()
Returns the start time.
-
getEndTime
public long getEndTime()
Returns the end time.
-
getElapsedTime
public long getElapsedTime()
Returns the elapsed time.
-
getSystemTime
protected long getSystemTime()
Returns the system time.
-
cancel
public void cancel()
Cancels the runner.
-
run
public abstract T run() throws java.lang.Exception
The method to run.- Throws:
java.lang.Exception
-
success
public void success(T aResult)
The method run on success.
-
cancelled
public void cancelled(java.lang.Exception e)
The method to run when cancelled.
-
failure
public void failure(java.lang.Exception e)
The method to run on failure.
-
finished
public void finished()
The method to run when finished (after success()/failure() call).
-
getResult
public T getResult()
Returns the result.
-
getExeption
public java.lang.Throwable getExeption()
Returns the exception.
-
invokeRun
protected void invokeRun()
Runs the run method.
-
invokeFinished
protected void invokeFinished()
Runs the success method.
-
-