org.springframework.context.ApplicationContext interface.
Configuration and lifecycle methods are encapsulated here to avoid making them obvious to ApplicationContext client code. The present methods should only be used by startup and shutdown code.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | APPLICATION_STARTUP_BEAN_NAME
Name of the |
| public static final String | CONFIG_LOCATION_DELIMITERS
Any number of these characters are considered delimiters between multiple context config paths in a single String value. |
| public static final String | CONVERSION_SERVICE_BEAN_NAME
Name of the ConversionService bean in the factory. |
| public static final String | ENVIRONMENT_BEAN_NAME
Name of the |
| public static final String | LOAD_TIME_WEAVER_BEAN_NAME
Name of the LoadTimeWeaver bean in the factory. |
| public static final String | SHUTDOWN_HOOK_THREAD_NAME
|
| public static final String | SYSTEM_ENVIRONMENT_BEAN_NAME
Name of the System environment bean in the factory. |
| public static final String | SYSTEM_PROPERTIES_BEAN_NAME
Name of the System properties bean in the factory. |
| Modifier and Type | Method and Description |
|---|---|
| public void | addApplicationListener(ApplicationListener<?>
the ApplicationListener to register listener)Add a new ApplicationListener that will be notified on context events such as context refresh and context shutdown. |
| public void | addBeanFactoryPostProcessor(BeanFactoryPostProcessor
the factory processor to register postProcessor)Add a new BeanFactoryPostProcessor that will get applied to the internal bean factory of this application context on refresh, before any of the bean definitions get evaluated. |
| public void | addProtocolResolver(ProtocolResolver resolver)
Register the given protocol resolver with this application context, allowing for additional resource protocols to be handled. |
| public void | close()
Redeclares java. Close this application context, releasing all resources and locks that the implementation might hold. |
| public ApplicationStartup | |
| public ConfigurableListableBeanFactory | Returns: the underlying bean factoryReturn the internal bean factory of this application context. |
| public ConfigurableEnvironment | getEnvironment()
Redeclares org. Return the |
| public boolean | Returns: whether the context is still activeDetermine whether this application context is active, that is, whether it has been refreshed at least once and has not been closed yet. |
| public void | refresh()
Load or refresh the persistent representation of the configuration, which might be from Java-based configuration, an XML file, a properties file, a relational database schema, or some other format. |
| public void | registerShutdownHook()
Register a shutdown hook with the JVM runtime, closing this context on JVM shutdown unless it has already been closed at that time. |
| public void | removeApplicationListener(ApplicationListener<?>
the ApplicationListener to deregister listener)Remove the given ApplicationListener from this context's set of listeners,
assuming it got registered via |
| public void | setApplicationStartup(ApplicationStartup
the new context event factory applicationStartup)Set the |
| public void | setClassLoader(ClassLoader classLoader)
Specify the ClassLoader to load class path resources and bean classes with. |
| public void | setEnvironment(ConfigurableEnvironment
the new environment environment)Set the |
| public void | |
| public void |
| APPLICATION_STARTUP_BEAN_NAME | back to summary |
|---|---|
| public static final String APPLICATION_STARTUP_BEAN_NAME Name of the
| |
| CONFIG_LOCATION_DELIMITERS | back to summary |
|---|---|
| public static final String CONFIG_LOCATION_DELIMITERS Any number of these characters are considered delimiters between multiple context config paths in a single String value. | |
| CONVERSION_SERVICE_BEAN_NAME | back to summary |
|---|---|
| public static final String CONVERSION_SERVICE_BEAN_NAME Name of the ConversionService bean in the factory. If none is supplied, default conversion rules apply.
| |
| ENVIRONMENT_BEAN_NAME | back to summary |
|---|---|
| public static final String ENVIRONMENT_BEAN_NAME Name of the
| |
| LOAD_TIME_WEAVER_BEAN_NAME | back to summary |
|---|---|
| public static final String LOAD_TIME_WEAVER_BEAN_NAME Name of the LoadTimeWeaver bean in the factory. If such a bean is supplied, the context will use a temporary ClassLoader for type matching, in order to allow the LoadTimeWeaver to process all actual bean classes.
| |
| SHUTDOWN_HOOK_THREAD_NAME | back to summary |
|---|---|
| public static final String SHUTDOWN_HOOK_THREAD_NAME
| |
| SYSTEM_ENVIRONMENT_BEAN_NAME | back to summary |
|---|---|
| public static final String SYSTEM_ENVIRONMENT_BEAN_NAME Name of the System environment bean in the factory.
| |
| SYSTEM_PROPERTIES_BEAN_NAME | back to summary |
|---|---|
| public static final String SYSTEM_PROPERTIES_BEAN_NAME Name of the System properties bean in the factory.
| |
| addApplicationListener | back to summary |
|---|---|
| public void addApplicationListener(ApplicationListener<?> listener) Add a new ApplicationListener that will be notified on context events such as context refresh and context shutdown. Note that any ApplicationListener registered here will be applied on refresh if the context is not active yet, or on the fly with the current event multicaster in case of a context that is already active.
| |
| addBeanFactoryPostProcessor | back to summary |
|---|---|
| public void addBeanFactoryPostProcessor(BeanFactoryPostProcessor postProcessor) Add a new BeanFactoryPostProcessor that will get applied to the internal bean factory of this application context on refresh, before any of the bean definitions get evaluated. To be invoked during context configuration.
| |
| addProtocolResolver | back to summary |
|---|---|
| public void addProtocolResolver(ProtocolResolver resolver) Register the given protocol resolver with this application context, allowing for additional resource protocols to be handled. Any such resolver will be invoked ahead of this context's standard resolution rules. It may therefore also override any default rules.
| |
| close | back to summary |
|---|---|
| public void close() Redeclares java. Close this application context, releasing all resources and locks that the implementation might hold. This includes destroying all cached singleton beans. Note Does not invoke This method can be called multiple times without side effects: Subsequent
| |
| getApplicationStartup | back to summary |
|---|---|
| public ApplicationStartup getApplicationStartup() Return the
| |
| getBeanFactory | back to summary |
|---|---|
| public ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException Return the internal bean factory of this application context. Can be used to access specific functionality of the underlying factory. Note Do not use this to post-process the bean factory; singletons will already have been instantiated before. Use a BeanFactoryPostProcessor to intercept the BeanFactory setup process before beans get touched. Generally, this internal factory will only be accessible while the context
is active, that is, in-between
| |
| getEnvironment | back to summary |
|---|---|
| public ConfigurableEnvironment getEnvironment() Redeclares org. Return the
| |
| isActive | back to summary |
|---|---|
| public boolean isActive() Determine whether this application context is active, that is, whether it has been refreshed at least once and has not been closed yet.
| |
| refresh | back to summary |
|---|---|
| public void refresh() throws BeansException, IllegalStateException Load or refresh the persistent representation of the configuration, which might be from Java-based configuration, an XML file, a properties file, a relational database schema, or some other format. As this is a startup method, it should destroy already created singletons if it fails, to avoid dangling resources. In other words, after invocation of this method, either all or no singletons at all should be instantiated.
| |
| registerShutdownHook | back to summary |
|---|---|
| public void registerShutdownHook() Register a shutdown hook with the JVM runtime, closing this context on JVM shutdown unless it has already been closed at that time. This method can be called multiple times. Only one shutdown hook (at max) will be registered for each context instance. As of Spring Framework 5.2, the name of
the shutdown hook thread should be
| |
| removeApplicationListener | back to summary |
|---|---|
| public void removeApplicationListener(ApplicationListener<?> listener) Remove the given ApplicationListener from this context's set of listeners,
assuming it got registered via
| |
| setApplicationStartup | back to summary |
|---|---|
| public void setApplicationStartup(ApplicationStartup applicationStartup) Set the This allows the application context to record metrics during startup.
| |
| setClassLoader | back to summary |
|---|---|
| public void setClassLoader(ClassLoader classLoader) Specify the ClassLoader to load class path resources and bean classes with. This context class loader will be passed to the internal bean factory. | |
| setEnvironment | back to summary |
|---|---|
| public void setEnvironment(ConfigurableEnvironment environment) Set the
| |
| setId | back to summary |
|---|---|
| public void setId(String id) Set the unique id of this application context.
| |
| setParent | back to summary |
|---|---|
| public void setParent(ApplicationContext parent) Set the parent of this application context. Note that the parent shouldn't be changed: It should only be set outside a constructor if it isn't available when an object of this class is created, for example in case of WebApplicationContext setup.
| |