Package play.jobs
Class Job<V>
- java.lang.Object
-
- play.Invocation
-
- play.jobs.Job<V>
-
- Type Parameters:
V- The job result type (if any)
- All Implemented Interfaces:
java.lang.Runnable,java.util.concurrent.Callable<V>
- Direct Known Subclasses:
SimpleJob
public abstract class Job<V> extends Invocation implements java.util.concurrent.Callable<V>
A job is an asynchronously executed unit of work
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.concurrent.ExecutorServiceexecutorstatic java.lang.StringinvocationTypeprotected java.lang.ThrowablelastExceptionprotected longlastRunprotected booleanwasError
-
Constructor Summary
Constructors Constructor Description Job()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void_finally()Vcall()abstract VdoJobWithResult()Here you do the job and return a resultvoidevery(int seconds)Run this job every n secondsvoidevery(java.lang.String delay)Run this job every n secondsvoidexecute()Override this methodInvocationContextgetInvocationContext()Promise<V>in(int seconds)Start this job in several secondsPromise<V>in(java.lang.String delay)Start this job in several secondsPromise<V>now()Start this job now (well ASAP)voidrun()java.lang.StringtoString()-
Methods inherited from class play.Invocation
after, before, init, onActionInvocationException, onQueued, onStarted, onSuccess, preInit
-
-
-
-
Field Detail
-
invocationType
public static final java.lang.String invocationType
- See Also:
- Constant Field Values
-
executor
protected java.util.concurrent.ExecutorService executor
-
lastRun
protected long lastRun
-
wasError
protected boolean wasError
-
lastException
protected java.lang.Throwable lastException
-
-
Method Detail
-
getInvocationContext
public InvocationContext getInvocationContext()
- Specified by:
getInvocationContextin classInvocation
-
doJobWithResult
public abstract V doJobWithResult() throws java.lang.Exception
Here you do the job and return a result- Returns:
- The job result
- Throws:
java.lang.Exception
-
execute
public void execute()
Description copied from class:InvocationOverride this method- Specified by:
executein classInvocation
-
in
public Promise<V> in(java.lang.String delay)
Start this job in several seconds- Parameters:
delay- time in seconds- Returns:
- the job completion
-
in
public Promise<V> in(int seconds)
Start this job in several seconds- Parameters:
seconds- time in seconds- Returns:
- the job completion
-
every
public void every(java.lang.String delay)
Run this job every n seconds- Parameters:
delay- time in seconds
-
every
public void every(int seconds)
Run this job every n seconds- Parameters:
seconds- time in seconds
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
_finally
protected void _finally()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-