Package io.microsphere.spring.context
Class ConfigurableApplicationContextInitializer
java.lang.Object
io.microsphere.spring.context.ConfigurableApplicationContextInitializer
- All Implemented Interfaces:
EnvironmentEnabled,org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
- Direct Known Subclasses:
AutoRegistrationBeanInitializer,EventPublishingBeanInitializer,ListenableAutowireCandidateResolverInitializer,ListenableConfigurableEnvironmentInitializer
public abstract class ConfigurableApplicationContextInitializer
extends Object
implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>, EnvironmentEnabled
An abstract base class for
ApplicationContextInitializer implementations targeting ConfigurableApplicationContext.
It provides built-in support for enabling or disabling the initializer via configuration properties,
as well as automatic self-registration into the Spring context.
Example Usage
public class MyCustomInitializer extends ConfigurableApplicationContextInitializer {
@Override
protected void initialize(ConfigurableApplicationContext context, ConfigurableEnvironment environment) {
// Perform custom initialization logic here
}
}
By default, this initializer is enabled. To disable it, set the corresponding property to false:
microsphere.spring.context-initializer.myCustomInitializer.enabled=false
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
-
ApplicationContextInitializerConfigurableApplicationContextConfigurableEnvironment
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringGet the bean name of thisConfigurableApplicationContextInitializerbooleanGet the default value of enabledGet the property name of the enabledfinal voidinitialize(org.springframework.context.ConfigurableApplicationContext context) protected abstract voidinitialize(org.springframework.context.ConfigurableApplicationContext context, org.springframework.core.env.ConfigurableEnvironment environment) Initialize theConfigurableApplicationContext.protected booleanisEnabled(org.springframework.context.ConfigurableApplicationContext context, org.springframework.core.env.ConfigurableEnvironment environment) Is enabled or notprotected booleanisRegistered(org.springframework.context.ConfigurableApplicationContext context) Is registered or notprotected voidregisterSelf(org.springframework.context.ConfigurableApplicationContext context) Register self to theConfigurableApplicationContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.microsphere.spring.config.env.EnvironmentEnabled
isEnabled
-
Field Details
-
logger
protected final io.microsphere.logging.Logger logger
-
-
Constructor Details
-
ConfigurableApplicationContextInitializer
public ConfigurableApplicationContextInitializer()
-
-
Method Details
-
initialize
public final void initialize(org.springframework.context.ConfigurableApplicationContext context) - Specified by:
initializein interfaceorg.springframework.context.ApplicationContextInitializer<org.springframework.context.ConfigurableApplicationContext>
-
initialize
protected abstract void initialize(org.springframework.context.ConfigurableApplicationContext context, org.springframework.core.env.ConfigurableEnvironment environment) Initialize theConfigurableApplicationContext.- Parameters:
context- theConfigurableApplicationContextenvironment- theConfigurableEnvironment
-
isEnabled
protected boolean isEnabled(org.springframework.context.ConfigurableApplicationContext context, org.springframework.core.env.ConfigurableEnvironment environment) Is enabled or not- Parameters:
context- theConfigurableApplicationContextenvironment- theConfigurableEnvironment- Returns:
- if enabled, return
true, orfalse - See Also:
-
getEnabledPropertyName
Get the property name of the enabled- Specified by:
getEnabledPropertyNamein interfaceEnvironmentEnabled- Returns:
- the property name of the enabled
- See Also:
-
getDefaultEnabled
public boolean getDefaultEnabled()Get the default value of enabled- Specified by:
getDefaultEnabledin interfaceEnvironmentEnabled- Returns:
- the default value of enabled
- See Also:
-
getBeanName
Get the bean name of thisConfigurableApplicationContextInitializer- Returns:
- the bean name of this
ConfigurableApplicationContextInitializer - See Also:
-
isRegistered
protected boolean isRegistered(org.springframework.context.ConfigurableApplicationContext context) Is registered or not- Parameters:
context- theConfigurableApplicationContext- Returns:
- if registered, return
true, orfalse
-
registerSelf
protected void registerSelf(org.springframework.context.ConfigurableApplicationContext context) Register self to theConfigurableApplicationContext- Parameters:
context- theConfigurableApplicationContext
-