T - 実行する Bean の型 public abstract class AbstractCommandLineRunner<T>
extends java.lang.Object このランチャーのコンセプトの基本的な考え方は、コンテキスト構成の場所、実行処理の Bean 名、オプション、引数を定義する方法を提供することです。考えられる例は次のとおりです。
contextConfig contextConfig,childContextConfig beanIdentifier contextConfig beanIdentifier <arguments> contextConfig <options> beanIdentifier contextConfig <options> beanIdentifier <arguments> <options> contextConfig <options> beanIdentifier <arguments>
| コンストラクターと説明 |
|---|
AbstractCommandLineRunner() |
| 修飾子と型 | メソッドと説明 |
|---|---|
protected void | doMain(java.lang.String[] args) サブクラスに表示されるメインメソッド。 |
void | exit(int status)SystemExiter を介してメソッドの折り返し処理を終了します。 |
protected org.springframework.context.ConfigurableApplicationContext | getApplicationContext(java.lang.String configLocation) アプリケーションコンテキストを取得します。 |
protected org.springframework.context.ConfigurableApplicationContext | getChildApplicationContext(java.lang.String configLocation, org.springframework.context.ConfigurableApplicationContext parent) アプリケーションコンテキストを取得します。 |
protected java.lang.String | getChildContextConfigPath(java.lang.String path) サブクラスが解析されたコンテキスト構成パスを変更できるようにします。 |
protected java.lang.String | getContextConfigPath(java.lang.String path) サブクラスが解析されたコンテキスト構成パスを変更できるようにします。 |
protected abstract java.lang.String | getDefaultBeanIdentifier() アプリケーションコンテキストからインスタンスを解決するために使用されるデフォルトの Bean ID を取得します。 |
static java.lang.String | getErrorMessage() このクラスに設定された静的エラーメッセージを取得します。 |
protected java.util.List<java.lang.String> | getValidOpts() 有効なオプション引数のリストを取得します。 |
protected abstract ExitStatus | handleBeanRun(T bean, java.lang.String[] parameters, java.util.Set<java.lang.String> opts) アプリケーションコンテキストが初期化された後の Bean の実行を処理します。 |
static void | presetSystemExiter(SystemExiter systemExiter)SystemExiter を設定します。 |
protected int | start(java.lang.String configLocation, java.lang.String masterIdentifier, java.lang.String childConfigLocation, java.lang.String[] parameters, java.util.Set<java.lang.String> opts) アプリケーションコンテキストを構築し、Bean の「実行」を処理します。 |
public static java.lang.String getErrorMessage()
public static void presetSystemExiter(SystemExiter systemExiter)
SystemExiter を設定します。テストに役立ちます。systemExiter - システム終了者 protected abstract ExitStatus handleBeanRun(T bean, java.lang.String[] parameters, java.util.Set<java.lang.String> opts)
このクラスは型指定された Bean インスタンスのみを認識するため、指定された Bean をどのように処理するかを決定するのは実装者の責任です。
bean - Bean インスタンス parameters - パラメーター opts - オプション protected abstract java.lang.String getDefaultBeanIdentifier()
protected java.util.List<java.lang.String> getValidOpts()
有効なオプションを上書きする場合は、オプションがコマンドラインで使用される予定の他のオプションと一致しないことを確認してください。つまり、通常はオプションの前に '-' 文字を付けることをお勧めします。
protected java.lang.String getContextConfigPath(java.lang.String path)
デフォルトの実装では、指定されたものを変更せずに返すだけです。
path - 解析された設定パス protected java.lang.String getChildContextConfigPath(java.lang.String path)
デフォルトの実装では、指定されたものを変更せずに返すだけです。
path - 解析された設定パス protected int start(java.lang.String configLocation,
java.lang.String masterIdentifier,
java.lang.String childConfigLocation,
java.lang.String[] parameters,
java.util.Set<java.lang.String> opts)configLocation - メインコンテキスト設定の場所 masterIdentifier - Bean 識別子 childConfigLocation - 子コンテキストの設定場所 parameters - パラメーター opts - オプション protected org.springframework.context.ConfigurableApplicationContext getApplicationContext(java.lang.String configLocation)
configLocation - コンテキスト設定の場所 protected org.springframework.context.ConfigurableApplicationContext getChildApplicationContext(java.lang.String configLocation,
org.springframework.context.ConfigurableApplicationContext parent)configLocation - コンテキスト設定の場所 parent - 親コンテキスト public void exit(int status)
SystemExiter を介して終了メソッドをラップする処理。このメソッドは主に、ユニットテストで実際の終了を行わないようにするために存在します。status - 終了コード protected void doMain(java.lang.String[] args)
args - 議論