public abstract class AbstractGenericContextLoader extends AbstractContextLoader
GenericApplicationContext
をロードする AbstractContextLoader
の抽象、汎用拡張。ContextLoader
SPI を介して呼び出される場合、コンテキストは loadContext(String...)
に提供された場所からロードされます。SmartContextLoader
SPI を介して呼び出される場合、コンテキストは loadContext(MergedContextConfiguration)
に提供された MergedContextConfiguration
からロードされます。そのような場合、SmartContextLoader
は、場所またはアノテーション付きクラスからコンテキストをロードするかどうかを決定します。 具象サブクラスは createBeanDefinitionReader()
の適切な実装を提供する必要があり、loadBeanDefinitions()
もオーバーライドする可能性があります。
loadContext(MergedContextConfiguration)
, loadContext(String...)
コンストラクターと説明 |
---|
AbstractGenericContextLoader() |
修飾子と型 | メソッドと説明 |
---|---|
protected abstract BeanDefinitionReader | createBeanDefinitionReader(GenericApplicationContext context) 提供された context に Bean 定義をロードするための新しい BeanDefinitionReader を作成するためのファクトリメソッド。 |
protected GenericApplicationContext | createContext() この ContextLoader で使用される GenericApplicationContext を作成するためのファクトリメソッド。 |
protected void | customizeBeanFactory(DefaultListableBeanFactory beanFactory) この ContextLoader によって作成された ApplicationContext の内部 Bean ファクトリをカスタマイズします。 |
protected void | customizeContext(GenericApplicationContext context) Bean 定義がコンテキストにロードされた後でコンテキストがリフレッシュされる前に、この ContextLoader によって作成された GenericApplicationContext をカスタマイズします。 |
protected void | loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) 提供された MergedContextConfiguration の場所またはクラスから、提供された context に Bean 定義をロードします。 |
ConfigurableApplicationContext | loadContext(MergedContextConfiguration mergedConfig) 提供されている MergedContextConfiguration から Spring ApplicationContext をロードします。 |
ConfigurableApplicationContext | loadContext(StringSE... locations) 提供されている locations から Spring ApplicationContext をロードします。 |
protected void | prepareContext(GenericApplicationContext context) この ContextLoader によって作成された GenericApplicationContext を準備します。 |
protected void | validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) このコンテキストローダーがサポートするものに関して、提供された MergedContextConfiguration を検証します。 |
customizeContext, generateDefaultLocations, getResourceSuffix, getResourceSuffixes, isGenerateDefaultLocations, modifyLocations, prepareContext, processContextConfiguration, processLocations
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
protected static final Log logger
public final ConfigurableApplicationContext loadContext(MergedContextConfiguration mergedConfig) throws ExceptionSE
MergedContextConfiguration
から Spring ApplicationContext をロードします。実装の詳細:
validateMergedContextConfiguration(MergedContextConfiguration)
を呼び出して、サブクラスが続行する前に指定された構成を検証できるようにします。createContext()
を呼び出して、GenericApplicationContext
インスタンスを作成します。MergedContextConfiguration
が親構成を参照する場合、対応する ApplicationContext
が取得され、このメソッドによって作成されたコンテキストの親として設定されます。ContextLoader
SPI との下位互換性のために prepareContext(GenericApplicationContext)
を呼び出します。AbstractContextLoader.prepareContext(ConfigurableApplicationContext, MergedContextConfiguration)
を呼び出して、Bean 定義がロードされる前にコンテキストをカスタマイズできるようにします。customizeBeanFactory(DefaultListableBeanFactory)
を呼び出して、コンテキストの DefaultListableBeanFactory
をカスタマイズできるようにします。loadBeanDefinitions(GenericApplicationContext, MergedContextConfiguration)
にデリゲートして、提供された MergedContextConfiguration
内の場所またはクラスからコンテキストを設定します。registering
アノテーション構成プロセッサーの AnnotationConfigUtils
へのデリゲート。customizeContext(GenericApplicationContext)
を呼び出して、リフレッシュされる前にコンテキストをカスタマイズできるようにします。AbstractContextLoader.customizeContext(ConfigurableApplicationContext, MergedContextConfiguration)
を呼び出して、リフレッシュされる前にコンテキストをカスタマイズできるようにします。Refreshes
コンテキストとそのための JVM シャットダウンフックを登録します。mergedConfig
- アプリケーションコンテキストをロードするために使用するマージされたコンテキスト構成 ExceptionSE
- コンテキストの読み込みに失敗した場合 SmartContextLoader.loadContext(MergedContextConfiguration)
, GenericApplicationContext
protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig)
MergedContextConfiguration
を検証します。デフォルトの実装はノーオペレーションですが、必要に応じてサブクラスによってオーバーライドできます。
mergedConfig
- 検証するマージされた構成 IllegalStateExceptionSE
- 指定された構成がこのコンテキストローダーに対して有効でない場合 public final ConfigurableApplicationContext loadContext(StringSE... locations) throws ExceptionSE
locations
から Spring ApplicationContext をロードします。実装の詳細:
createContext()
を呼び出して、GenericApplicationContext
インスタンスを作成します。prepareContext(GenericApplicationContext)
を呼び出して、Bean 定義がロードされる前にコンテキストをカスタマイズできるようにします。customizeBeanFactory(DefaultListableBeanFactory)
を呼び出して、コンテキストの DefaultListableBeanFactory
をカスタマイズできるようにします。createBeanDefinitionReader(GenericApplicationContext)
にデリゲートして BeanDefinitionReader
を作成し、それを使用して、指定された場所からコンテキストを設定します。registering
アノテーション構成プロセッサーの AnnotationConfigUtils
へのデリゲート。customizeContext(GenericApplicationContext)
を呼び出して、リフレッシュされる前にコンテキストをカスタマイズできるようにします。Refreshes
コンテキストとそのための JVM シャットダウンフックを登録します。 注意 : このメソッドは、ロードされたコンテキストに対してアクティブな Bean 定義プロファイルを設定する手段を提供しません。代替方法については、loadContext(MergedContextConfiguration)
および AbstractContextLoader.prepareContext(ConfigurableApplicationContext, MergedContextConfiguration)
を参照してください。
locations
- アプリケーションコンテキストをロードするために使用するリソースの場所 ExceptionSE
- コンテキストの読み込みに失敗した場合 ContextLoader.loadContext(java.lang.String...)
, GenericApplicationContext
, loadContext(MergedContextConfiguration)
protected GenericApplicationContext createContext()
ContextLoader
で使用される GenericApplicationContext
を作成するためのファクトリメソッド。 デフォルトの実装では、デフォルトのコンストラクターを使用して GenericApplicationContext
が作成されます。このメソッドはオーバーライドされる可能性があります。カスタムコンテキストサブクラスを使用するか、カスタム DefaultListableBeanFactory
実装で GenericApplicationContext
を作成します。
GenericApplicationContext
protected void prepareContext(GenericApplicationContext context)
ContextLoader
によって作成された GenericApplicationContext
を準備します。Bean 定義が読み取られる前に呼び出されます。 デフォルトの実装は空です。GenericApplicationContext
の標準設定をカスタマイズするためにサブクラスでオーバーライドできます。
context
- 準備すべきコンテキスト loadContext(MergedContextConfiguration)
, loadContext(String...)
, GenericApplicationContext.setAllowBeanDefinitionOverriding(boolean)
, GenericApplicationContext.setResourceLoader(org.springframework.core.io.ResourceLoader)
, AbstractApplicationContext.setId(java.lang.String)
, AbstractContextLoader.prepareContext(ConfigurableApplicationContext, MergedContextConfiguration)
protected void customizeBeanFactory(DefaultListableBeanFactory beanFactory)
ContextLoader
によって作成された ApplicationContext の内部 Bean ファクトリをカスタマイズします。 デフォルトの実装は空ですが、サブクラスでオーバーライドして、DefaultListableBeanFactory
の標準設定をカスタマイズできます。
beanFactory
- この ContextLoader
によって作成された Bean ファクトリ loadContext(MergedContextConfiguration)
, loadContext(String...)
, DefaultListableBeanFactory.setAllowBeanDefinitionOverriding(boolean)
, DefaultListableBeanFactory.setAllowEagerClassLoading(boolean)
, AbstractAutowireCapableBeanFactory.setAllowCircularReferences(boolean)
, AbstractAutowireCapableBeanFactory.setAllowRawInjectionDespiteWrapping(boolean)
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig)
MergedContextConfiguration
の場所またはクラスから、提供された context
に Bean 定義をロードします。 デフォルトの実装は、createBeanDefinitionReader(GenericApplicationContext)
から返された BeanDefinitionReader
を Bean 定義の load
に委譲します。
サブクラスは createBeanDefinitionReader(GenericApplicationContext)
の適切な実装を提供する必要があります。あるいは、サブクラスは createBeanDefinitionReader()
の no-op 実装を提供し、このメソッドをオーバーライドして、Bean 定義をロードまたは登録するためのカスタム戦略を提供できます。
context
- Bean 定義をロードする必要があるコンテキスト mergedConfig
- マージされたコンテキスト構成 loadContext(MergedContextConfiguration)
protected abstract BeanDefinitionReader createBeanDefinitionReader(GenericApplicationContext context)
context
に Bean 定義をロードするための新しい BeanDefinitionReader
を作成するためのファクトリメソッド。context
- BeanDefinitionReader
を作成する必要があるコンテキスト BeanDefinitionReader
loadContext(String...)
, loadBeanDefinitions(org.springframework.context.support.GenericApplicationContext, org.springframework.test.context.MergedContextConfiguration)
, BeanDefinitionReader
protected void customizeContext(GenericApplicationContext context)
ContextLoader
によって作成された GenericApplicationContext
をカスタマイズします。デフォルトの実装は空ですが、サブクラスでオーバーライドして、アプリケーションコンテキストをカスタマイズできます。
context
- 新しく作成されたアプリケーションコンテキスト loadContext(MergedContextConfiguration)
, loadContext(String...)
, AbstractContextLoader.customizeContext(ConfigurableApplicationContext, MergedContextConfiguration)