V
- The job result type (if any)public class Job<V> extends Invoker.Invocation implements java.util.concurrent.Callable<V>
Modifier and Type | Field and Description |
---|---|
protected java.util.concurrent.ExecutorService |
executor |
static java.lang.String |
invocationType |
protected java.lang.Throwable |
lastException |
protected long |
lastRun |
protected boolean |
wasError |
Constructor and Description |
---|
Job() |
Modifier and Type | Method and Description |
---|---|
void |
_finally()
Things to do in all cases after the invocation.
|
F.Promise<V> |
afterRequest()
If is called in a 'HttpRequest' invocation context, waits until request is served and schedules job then.
|
V |
call() |
void |
doJob()
Here you do the job
|
V |
doJobWithResult()
Here you do the job and return a result
|
void |
every(int seconds)
Run this job every n seconds
|
void |
every(java.lang.String delay)
Run this job every n seconds
|
void |
execute()
Override this method
|
Invoker.InvocationContext |
getInvocationContext() |
F.Promise<V> |
in(int seconds)
Start this job in several seconds
|
F.Promise<V> |
in(java.lang.String delay)
Start this job in several seconds
|
F.Promise<V> |
now()
Start this job now (well ASAP)
|
void |
onException(java.lang.Throwable e)
Things to do if the Invocation code thrown an exception
|
void |
run()
It's time to execute.
|
java.lang.String |
toString() |
public static final java.lang.String invocationType
protected java.util.concurrent.ExecutorService executor
protected long lastRun
protected boolean wasError
protected java.lang.Throwable lastException
public Invoker.InvocationContext getInvocationContext()
getInvocationContext
in class Invoker.Invocation
public void doJob() throws java.lang.Exception
java.lang.Exception
- if problems occurredpublic V doJobWithResult() throws java.lang.Exception
java.lang.Exception
- if problems occurredpublic void execute() throws java.lang.Exception
Invoker.Invocation
execute
in class Invoker.Invocation
java.lang.Exception
- Thrown if Invocation encounters any problemspublic F.Promise<V> afterRequest()
public F.Promise<V> in(java.lang.String delay)
delay
- time in secondspublic F.Promise<V> in(int seconds)
seconds
- time in secondspublic void every(java.lang.String delay)
delay
- time in secondspublic void every(int seconds)
seconds
- time in secondspublic void onException(java.lang.Throwable e)
Invoker.Invocation
onException
in class Invoker.Invocation
e
- The exceptionpublic void run()
Invoker.Invocation
run
in interface java.lang.Runnable
run
in class Invoker.Invocation
public void _finally()
Invoker.Invocation
_finally
in class Invoker.Invocation
public java.lang.String toString()
toString
in class java.lang.Object
Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly