public class TaskExecutorAdapter extends ObjectSE implements AsyncListenableTaskExecutor
java.util.concurrent.Executor
を取得し、Spring TaskExecutor
を公開するアダプター。また、拡張 java.util.concurrent.ExecutorService
を検出し、それに応じて AsyncTaskExecutor
インターフェースを適合させます。Executor
SE, ExecutorService
SE, Executors
SETIMEOUT_IMMEDIATE, TIMEOUT_INDEFINITE
コンストラクターと説明 |
---|
TaskExecutorAdapter(ExecutorSE concurrentExecutor) 指定された JDK コンカレントエグゼキューターを使用して、新しい TaskExecutorAdapter を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
protected void | doExecute(ExecutorSE concurrentExecutor, TaskDecorator taskDecorator, RunnableSE runnable) 実際に、指定されたエグゼキューターを使用して、指定された Runnable (ユーザー指定タスクまたはユーザー指定タスクのラッパー)を実行します。 |
void | execute(RunnableSE task) 指定された JDK コンカレントエグゼキューターへのデリゲート。 |
void | execute(RunnableSE task, long startTimeout) 指定された task を実行します。 |
void | setTaskDecorator(TaskDecorator taskDecorator) 実行しようとしている Runnable SE に適用するカスタム TaskDecorator を指定します。 |
<T> FutureSE<T> | submit(CallableSE<T> task) Callable タスクを送信して実行し、そのタスクを表す Future を受け取ります。 |
FutureSE<?> | submit(RunnableSE task) 実行可能な Runnable タスクを送信し、そのタスクを表す Future を受け取ります。 |
<T> ListenableFuture<T> | submitListenable(CallableSE<T> task) Callable タスクを実行のために送信し、そのタスクを表す ListenableFuture を受け取ります。 |
ListenableFuture<?> | submitListenable(RunnableSE task) Runnable タスクを実行のために送信し、そのタスクを表す ListenableFuture を受け取ります。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public TaskExecutorAdapter(ExecutorSE concurrentExecutor)
concurrentExecutor
- 委譲する JDK コンカレントエグゼキューター public final void setTaskDecorator(TaskDecorator taskDecorator)
Runnable
SE に適用するカスタム TaskDecorator
を指定します。 このようなデコレータは、必ずしもユーザー提供の Runnable
/Callable
に適用されるのではなく、実際の実行コールバック(ユーザー提供のタスクのラッパーである可能性があります)に適用されることに注意してください。
主な使用例は、タスクの呼び出しの周囲に実行コンテキストを設定するか、タスク実行の監視 / 統計を提供することです。
注意 : TaskDecorator
実装での例外処理は、execute
呼び出しによる単純な Runnable
実行に制限されています。#submit
呼び出しの場合、公開された Runnable
は、例外を伝搬しない FutureTask
になります。例外を評価するには、キャストして Future#get
を呼び出す必要がある場合があります。
public void execute(RunnableSE task)
ExecutorSE
の executeSE
TaskExecutor
の execute
task
- 実行する Runnable
(非 null
)Executor.execute(Runnable)
SEpublic void execute(RunnableSE task, long startTimeout)
AsyncTaskExecutor
task
を実行します。AsyncTaskExecutor
の execute
task
- 実行する Runnable
(非 null
)startTimeout
- タスクが開始される予定の期間(ミリ秒)。これはエグゼキューターへのヒントとして意図されており、即時タスクの優先処理を可能にします。一般的な値は AsyncTaskExecutor.TIMEOUT_IMMEDIATE
または AsyncTaskExecutor.TIMEOUT_INDEFINITE
(TaskExecutor.execute(Runnable)
で使用されるデフォルト)です。public FutureSE<?> submit(RunnableSE task)
AsyncTaskExecutor
null
の結果を返します。AsyncTaskExecutor
の submit
task
- 実行する Runnable
(非 null
)public <T> FutureSE<T> submit(CallableSE<T> task)
AsyncTaskExecutor
AsyncTaskExecutor
の submit
task
- 実行する Callable
(非 null
)public ListenableFuture<?> submitListenable(RunnableSE task)
AsyncListenableTaskExecutor
Runnable
タスクを実行のために送信し、そのタスクを表す ListenableFuture
を受け取ります。Future は完了時に null
の結果を返します。AsyncListenableTaskExecutor
の submitListenable
task
- 実行する Runnable
(非 null
)ListenableFuture
public <T> ListenableFuture<T> submitListenable(CallableSE<T> task)
AsyncListenableTaskExecutor
Callable
タスクを実行のために送信し、そのタスクを表す ListenableFuture
を受け取ります。Future は、完了時に Callable の結果を返します。AsyncListenableTaskExecutor
の submitListenable
task
- 実行する Callable
(非 null
)ListenableFuture
protected void doExecute(ExecutorSE concurrentExecutor, @Nullable TaskDecorator taskDecorator, RunnableSE runnable) throws RejectedExecutionExceptionSE
Runnable
(ユーザー指定タスクまたはユーザー指定タスクのラッパー)を実行します。concurrentExecutor
- 委譲先の基礎となる JDK コンカレントエグゼキューター taskDecorator
- 適用される指定されたデコレータ(存在する場合)runnable
- 実行するランナブル RejectedExecutionExceptionSE
- 指定された実行可能ファイルが受け入れられない場合