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 classSPRunner.Status
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringActivityText_Propstatic java.lang.StringProgress_Propstatic java.lang.StringStatus_Prop
-
Constructor Summary
Constructors Constructor Description SPRunner()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcancel()Cancels the runner.voidcancelled(java.lang.Exception e)The method to run when cancelled.voidfailure(java.lang.Exception e)The method to run on failure.voidfinished()The method to run when finished (after success()/failure() call).java.lang.StringgetActivityText()Returns a description of the current activity beging performed.longgetElapsedTime()Returns the elapsed time.longgetEndTime()Returns the end time.java.lang.ThrowablegetExeption()Returns the exception.java.lang.StringgetName()Returns the name of runner (and thread).doublegetProgress()Returns the progress value.TgetResult()Returns the result.longgetStartTime()Returns the start time.SPRunner.StatusgetStatus()Returns the status.protected longgetSystemTime()Returns the system time.java.lang.ThreadgetThread()Returns the thread.protected voidinvokeFinished()Runs the success method.protected voidinvokeRun()Runs the run method.booleanisActive()Returns whether thread is still active.booleanisCancelled()Whether runner has been cancelled.SPRunner<T>join()Joins the runner.SPRunner<T>join(int aTimeout)Joins the runner.abstract Trun()The method to run.voidsetActivityText(java.lang.String aString)Sets a description of the current activity beging performed.voidsetName(java.lang.String aName)Sets the name of runner (and thread).voidsetProgress(double aValue)Sets the progress value.protected voidsetStatus(SPRunner.Status aStatus)Sets the status.SPRunner<T>start()Starts the runner.voidsuccess(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.
-
-