Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

edu.emory.mathcs.util.concurrent
Class SecureAsyncTask  view SecureAsyncTask download SecureAsyncTask.java

java.lang.Object
  extended byedu.emory.mathcs.util.concurrent.AsyncTask
      extended byedu.emory.mathcs.util.concurrent.SecureAsyncTask
All Implemented Interfaces:
Cancellable, Future

public class SecureAsyncTask
extends AsyncTask

Variant of AsyncTask that overrides method createPerformer 55 so that it always runs with a fixed access control context and thread context inherited from the caller of createPerformer method. This class is intended primarily for subclassing. Typical usage scenario in subclasses is to create a new instance and call createPerformer. As a result, one obtains a runnable that will perform assigned task with the same access permissions, DelegatableThreadLocals, and the context class loader, regardless of the thread that actually executes the runnable.

Version:
1.0

Field Summary
 
Fields inherited from class edu.emory.mathcs.util.concurrent.AsyncTask
callback, cancellationException, cancellationHandler, completed, result, resultException
 
Constructor Summary
protected SecureAsyncTask()
           
protected SecureAsyncTask(Callback cb)
           
 
Method Summary
protected  java.lang.Runnable createPerformer(Callable call, boolean disableStackTraces)
          Creates a runnable that will execute specified call and then mark this AsyncTask with the result of that call.
static AsyncTask start(Executor executor, Callable call)
          Schedules specified task with given executor, and returns completion handle that can be used to access the result or to cancel the task.
static AsyncTask start(Executor executor, Callable call, Callback cb)
          Schedules specified task with given executor, and returns completion handle that can be used to access the result or to cancel the task.
static AsyncTask start(Executor executor, Callable call, Callback cb, boolean disableStackTraces)
          Schedules specified task with given executor, and returns completion handle that can be used to access the result or to cancel the task.
 
Methods inherited from class edu.emory.mathcs.util.concurrent.AsyncTask
cancel, createCancellationHandler, get, get, isCancelled, isDone, setCompleted, setFailed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureAsyncTask

protected SecureAsyncTask()

SecureAsyncTask

protected SecureAsyncTask(Callback cb)
Method Detail

createPerformer

protected java.lang.Runnable createPerformer(Callable call,
                                             boolean disableStackTraces)
Creates a runnable that will execute specified call and then mark this AsyncTask with the result of that call. The runnable will run with access control context and ThreadContext inherited from this method's invoker, regardless of the thread that will actually execute it. If the call completes successfully, this AsyncTask is marked completed with the result returned by the call. If the call throws an exception, the AsyncTask is marked as failed with cause being that exception. The stack trace of the thread in which the performer is created is appended to the failure cause stack trace unless the disableStackTraces parameter is set to false.

This method is intended to be used by subclasses. Runnable returned from this method should be executed only once -- subsequent execution attempts will fail due to "task already completed" condition.

Overrides:
createPerformer in class AsyncTask

start

public static AsyncTask start(Executor executor,
                              Callable call)
Schedules specified task with given executor, and returns completion handle that can be used to access the result or to cancel the task. The task will run with access control context and ThreadContext inherited from this method's invoker, regardless of the thread that will actually execute it. Later, if task completes successfully, the handle is marked completed with the result that has been returned from the task. If the task ends with an exception, the handle is marked failed with cause being that exception. In such case, as a debugging aid, current stack trace (i.e. that of this method's invoker) is appended to the original stack trace.


start

public static AsyncTask start(Executor executor,
                              Callable call,
                              Callback cb)
Schedules specified task with given executor, and returns completion handle that can be used to access the result or to cancel the task. The task will run with access control context and ThreadContext inherited from this method's invoker, regardless of the thread that will actually execute it. Later, if task completes successfully, the handle is marked completed with the result that has been returned from the task. If the task ends with an exception, the handle is marked failed with cause being that exception. In such case, as a debugging aid, current stack trace (i.e. that of this method's invoker) is appended to the original stack trace.


start

public static AsyncTask start(Executor executor,
                              Callable call,
                              Callback cb,
                              boolean disableStackTraces)
Schedules specified task with given executor, and returns completion handle that can be used to access the result or to cancel the task. The task will run with access control context and ThreadContext inherited from this method's invoker, regardless of the thread that will actually execute it. Later, if task completes successfully, the handle is marked completed with the result that has been returned from the task. If the task ends with an exception, the handle is marked failed with cause being that exception. In such case, as a debugging aid, current stack trace (i.e. that of this method's invoker) is appended to the original stack trace unless the disableStackTraces parameter is set to false