R
- the type of the task resultpublic abstract static class SandboxBackgroundTask.Proxy<R>
extends java.lang.Object
SandboxBackgroundTask
object. A proxy object allows a client that provides the actual task to perform
the task without knowing how the task is handled -- specifically how
the context is set up, the exception is handled or the result is processed.Constructor and Description |
---|
Proxy() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.Long |
getTimeout()
Returns the maximum wait time for the background job.
|
protected java.util.concurrent.TimeUnit |
getTimeoutTimeUnit()
Returns the time unit of the maximum wait time.
|
protected abstract SandboxBackgroundTask<R> |
newTask(SandboxBackgroundTask.Job<java.lang.Object> fj,
SandboxBackgroundTask.Job<R> bj)
Creates a new task.
|
void |
performTask(SandboxBackgroundTask.Job<java.lang.Object> fj,
SandboxBackgroundTask.Job<R> bj)
Performs a task.
|
void |
performTask(SandboxBackgroundTask.Job<R> bj)
Performs a task entirely in a background thread.
|
protected void |
timedOut(java.util.concurrent.TimeoutException e)
Invoked when the maximum wait time is up but the background job has not
finished yet.
|
protected void |
waitInterrupted(java.lang.InterruptedException e)
Invoked when the current thread is interrupted while waiting for the
background job to finish.
|
protected abstract SandboxBackgroundTask<R> newTask(SandboxBackgroundTask.Job<java.lang.Object> fj, SandboxBackgroundTask.Job<R> bj)
fj
- the job that runs in the current threadbj
- the job that runs in a background threadpublic void performTask(SandboxBackgroundTask.Job<java.lang.Object> fj, SandboxBackgroundTask.Job<R> bj)
fj
- the job that runs in the current thread; null
if
task is performed entirely in a background threadbj
- the job that runs in a background threadjava.lang.IllegalArgumentException
- if the background job is nullprotected java.lang.Long getTimeout()
null
if no waittimedOut(java.util.concurrent.TimeoutException)
protected java.util.concurrent.TimeUnit getTimeoutTimeUnit()
null
if
the unit is TimeUnit.MILLISECONDS
protected void timedOut(java.util.concurrent.TimeoutException e)
e
- the exception that indicates the timeoutprotected void waitInterrupted(java.lang.InterruptedException e)
e
- the exception that indicates the interruptionpublic final void performTask(SandboxBackgroundTask.Job<R> bj)
performTask(null, bj)
.bj
- the job that runs in a background thread