public abstract class AsyncExecutionAspectSupport extends ObjectSE implements BeanFactoryAware
org.springframework.scheduling.annotation.AnnotationAsyncExecutionInterceptor
や org.springframework.scheduling.aspectj.AnnotationAsyncExecutionAspect
などの非同期メソッド実行アスペクトの基本クラス。 メソッドごとにエグゼキューター修飾をサポートします。AsyncExecutionAspectSupport
オブジェクトはデフォルトの Executor
で構築する必要がありますが、個々のメソッドは、アノテーション属性などを使用して、特定の Executor
Bean を実行時に使用するようにさらに修飾できます。
修飾子と型 | フィールドと説明 |
---|---|
static StringSE | DEFAULT_TASK_EXECUTOR_BEAN_NAME 取得する TaskExecutor Bean のデフォルト名: "taskExecutor"。 |
protected Log | logger |
コンストラクターと説明 |
---|
AsyncExecutionAspectSupport(ExecutorSE defaultExecutor) デフォルトの AsyncUncaughtExceptionHandler で新しいインスタンスを作成します。 |
AsyncExecutionAspectSupport(ExecutorSE defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler) 指定された例外ハンドラーで新しい AsyncExecutionAspectSupport を作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
void | configure(SupplierSE<ExecutorSE> defaultExecutor, SupplierSE<AsyncUncaughtExceptionHandler> exceptionHandler) 指定されたエグゼキューターと例外ハンドラーのサプライヤーでこのアスペクトを設定し、サプライヤーが解決できない場合は対応するデフォルトを適用します。 |
protected AsyncTaskExecutor | determineAsyncExecutor(MethodSE method) 特定のメソッドを実行するときに使用する特定のエグゼキューターを決定します。 |
protected ObjectSE | doSubmit(CallableSE<ObjectSE> task, AsyncTaskExecutor executor, ClassSE<?> returnType) 選択したエグゼキューターで特定のタスクを実際に実行するためのデリゲート。 |
protected ExecutorSE | findQualifiedExecutor(BeanFactory beanFactory, StringSE qualifier) 指定された修飾子のターゲットエグゼキューターを取得します。 |
protected ExecutorSE | getDefaultExecutor(BeanFactory beanFactory) このアドバイスインスタンスのデフォルトのエグゼキューターを取得またはビルドします。 |
protected abstract StringSE | getExecutorQualifier(MethodSE method) 指定された非同期メソッドを実行するときに使用されるエグゼキューターの修飾子または Bean 名を返します。これは通常、アノテーション属性の形式で指定されます。 |
protected void | handleError(ThrowableSE ex, MethodSE method, ObjectSE... params) 指定された Method SE を非同期で呼び出しているときにスローされた致命的なエラーを処理します。 |
void | setBeanFactory(BeanFactory beanFactory) 修飾子でエグゼキューターを検索するとき、またはデフォルトのエグゼキュータールックアップアルゴリズムに依存するときに使用する BeanFactory を設定します。 |
void | setExceptionHandler(AsyncUncaughtExceptionHandler exceptionHandler) void 戻り値型で非同期メソッドを呼び出すことによってスローされた例外を処理するために使用する AsyncUncaughtExceptionHandler を提供します。 |
void | setExecutor(ExecutorSE defaultExecutor) 非同期メソッドの実行時に使用するエグゼキューターを指定します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public static final StringSE DEFAULT_TASK_EXECUTOR_BEAN_NAME
TaskExecutor
Bean のデフォルト名: "taskExecutor"。最初の検索は型ごとに行われることに注意してください。これは、コンテキストで複数のエグゼキューター Bean が見つかった場合の単なるフォールバックです。
protected final Log logger
public AsyncExecutionAspectSupport(@Nullable ExecutorSE defaultExecutor)
AsyncUncaughtExceptionHandler
で新しいインスタンスを作成します。defaultExecutor
- 委譲先の Executor
(通常は Spring AsyncTaskExecutor
または ExecutorService
SE)。ただし、非同期メソッドの修飾子を介してより具体的なエグゼキューターがリクエストされていない場合、そのエグゼキューターは呼び出し時に囲まれた Bean ファクトリに対して呼び出されます。public AsyncExecutionAspectSupport(@Nullable ExecutorSE defaultExecutor, AsyncUncaughtExceptionHandler exceptionHandler)
AsyncExecutionAspectSupport
を作成します。defaultExecutor
- 委譲先の Executor
(通常は Spring AsyncTaskExecutor
または ExecutorService
SE)。ただし、非同期メソッドの修飾子を介してより具体的なエグゼキューターがリクエストされていない場合、そのエグゼキューターは呼び出し時に囲まれた Bean ファクトリに対して呼び出されます。exceptionHandler
- 使用する AsyncUncaughtExceptionHandler
public void configure(@Nullable SupplierSE<ExecutorSE> defaultExecutor, @Nullable SupplierSE<AsyncUncaughtExceptionHandler> exceptionHandler)
public void setExecutor(ExecutorSE defaultExecutor)
defaultExecutor
- 委譲先の Executor
(通常は Spring AsyncTaskExecutor
または ExecutorService
SE)。ただし、非同期メソッドの修飾子を介してより具体的なエグゼキューターがリクエストされていない場合、そのエグゼキューターは呼び出し時に囲まれた Bean ファクトリに対して呼び出されます。getExecutorQualifier(Method)
, setBeanFactory(BeanFactory)
, getDefaultExecutor(BeanFactory)
public void setExceptionHandler(AsyncUncaughtExceptionHandler exceptionHandler)
void
戻り値型で非同期メソッドを呼び出すことによってスローされた例外を処理するために使用する AsyncUncaughtExceptionHandler
を提供します。public void setBeanFactory(BeanFactory beanFactory)
BeanFactory
を設定します。BeanFactoryAware
の setBeanFactory
beanFactory
- 所有 BeanFactory(非 null
)。Bean は、ファクトリのメソッドをすぐに呼び出すことができます。findQualifiedExecutor(BeanFactory, String)
, getDefaultExecutor(BeanFactory)
@Nullable protected AsyncTaskExecutor determineAsyncExecutor(MethodSE method)
AsyncListenableTaskExecutor
実装を返す必要があります。null
、ただしデフォルトのエグゼキュータが利用できない場合)@Nullable protected abstract StringSE getExecutorQualifier(MethodSE method)
null
を返すことは、特定の実行プログラムが指定されておらず、デフォルトの実行プログラムを使用する必要があることを示しています。method
- エグゼキューター修飾子メタデータをインスペクションするメソッド null
determineAsyncExecutor(Method)
, findQualifiedExecutor(BeanFactory, String)
@Nullable protected ExecutorSE findQualifiedExecutor(@Nullable BeanFactory beanFactory, StringSE qualifier)
qualifier
- 解決する修飾子 null
がない場合 getExecutorQualifier(Method)
@Nullable protected ExecutorSE getDefaultExecutor(@Nullable BeanFactory beanFactory)
デフォルトの実装では、コンテキスト内で一意の TaskExecutor
Bean を検索するか、それ以外の場合は "taskExecutor" という名前の Executor
SE Bean を検索します。どちらも解決できない場合、この実装は null
を返します。
beanFactory
- デフォルトのエグゼキューター検索に使用する BeanFactorynull
findQualifiedExecutor(BeanFactory, String)
, DEFAULT_TASK_EXECUTOR_BEAN_NAME
@Nullable protected ObjectSE doSubmit(CallableSE<ObjectSE> task, AsyncTaskExecutor executor, ClassSE<?> returnType)
protected void handleError(ThrowableSE ex, MethodSE method, ObjectSE... params) throws ExceptionSE
Method
SE を非同期で呼び出しているときにスローされた致命的なエラーを処理します。 メソッドの戻り型が Future
SE オブジェクトの場合、元の例外は、より高いレベルでスローするだけで伝播できます。ただし、他のすべてのケースでは、例外はクライアントに送信されません。後者の場合、現在の AsyncUncaughtExceptionHandler
がそのような例外の管理に使用されます。
ex
- 処理する例外 method
- 呼び出されたメソッド params
- メソッドの呼び出しに使用されるパラメーター ExceptionSE