play.jobs
Class Job<V>

java.lang.Object
  extended by play.Invoker.Invocation
      extended by play.jobs.Job<V>
Type Parameters:
V - The job result type (if any)
All Implemented Interfaces:
java.lang.Runnable, java.util.concurrent.Callable<V>

public class Job<V>
extends Invoker.Invocation
implements java.util.concurrent.Callable<V>

A job is an asynchronously executed unit of work


Field Summary
protected  java.util.concurrent.ExecutorService executor
           
static java.lang.String invocationType
           
protected  java.lang.Throwable lastException
           
protected  long lastRun
           
protected  boolean wasError
           
 
Constructor Summary
Job()
           
 
Method Summary
 void _finally()
          Things to do in all cases after the invocation.
 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()
           
 
Methods inherited from class play.Invoker.Invocation
after, before, init, onSuccess, suspend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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
Constructor Detail

Job

public Job()
Method Detail

getInvocationContext

public Invoker.InvocationContext getInvocationContext()
Specified by:
getInvocationContext in class Invoker.Invocation

doJob

public void doJob()
           throws java.lang.Exception
Here you do the job

Throws:
java.lang.Exception

doJobWithResult

public V doJobWithResult()
                  throws java.lang.Exception
Here you do the job and return a result

Throws:
java.lang.Exception

execute

public void execute()
             throws java.lang.Exception
Description copied from class: Invoker.Invocation
Override this method

Specified by:
execute in class Invoker.Invocation
Throws:
java.lang.Exception

now

public F.Promise<V> now()
Start this job now (well ASAP)

Returns:
the job completion

in

public F.Promise<V> in(java.lang.String delay)
Start this job in several seconds

Returns:
the job completion

in

public F.Promise<V> in(int seconds)
Start this job in several seconds

Returns:
the job completion

every

public void every(java.lang.String delay)
Run this job every n seconds


every

public void every(int seconds)
Run this job every n seconds


onException

public void onException(java.lang.Throwable e)
Description copied from class: Invoker.Invocation
Things to do if the Invocation code thrown an exception

Overrides:
onException in class Invoker.Invocation

run

public void run()
Description copied from class: Invoker.Invocation
It's time to execute.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class Invoker.Invocation

call

public V call()
Specified by:
call in interface java.util.concurrent.Callable<V>

_finally

public void _finally()
Description copied from class: Invoker.Invocation
Things to do in all cases after the invocation.

Overrides:
_finally in class Invoker.Invocation

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Guillaume Bort & zenexity - Distributed under Apache 2 licence, without any warrantly