类 AbstractRefreshableApplicationContext
- 所有已实现的接口:
BeanFactory,HierarchicalBeanFactory,BeanDefinitionRegistry,DependencyInjectorProvider,ApplicationContext,ApplicationEventPublisher,ConfigurableApplicationContext,Lifecycle,MessageSource,cn.taketoday.core.AliasRegistry,cn.taketoday.core.env.EnvironmentCapable,cn.taketoday.core.io.PatternResourceLoader,cn.taketoday.core.io.ResourceLoader,Closeable,AutoCloseable
ApplicationContext
implementations which are supposed to support multiple calls to AbstractApplicationContext.refresh(),
creating a new internal bean factory instance every time.
Typically (but not necessarily), such a context will be driven by
a set of config locations to load bean definitions from.
The only method to be implemented by subclasses is loadBeanDefinitions(cn.taketoday.beans.factory.support.StandardBeanFactory),
which gets invoked on each refresh. A concrete implementation is supposed to load
bean definitions into the given
StandardBeanFactory,
typically delegating to one or more specific bean definition readers.
Note that there is a similar base class for WebApplicationContexts.
cn.taketoday.web.context.support.AbstractRefreshableWebApplicationContext
provides the same subclassing strategy, but additionally pre-implements
all context functionality for web environments. There is also a
pre-defined way to receive config locations for a web context.
- 从以下版本开始:
- 4.0 2022/2/20 17:36
- 作者:
- Juergen Hoeller, Chris Beams, Harry Yang
- 另请参阅:
-
loadBeanDefinitions(cn.taketoday.beans.factory.support.StandardBeanFactory)StandardBeanFactorycn.taketoday.web.context.support.AbstractRefreshableWebApplicationContext
-
嵌套类概要
从类继承的嵌套类/接口 cn.taketoday.core.io.DefaultResourceLoader
cn.taketoday.core.io.DefaultResourceLoader.ClassPathContextResource从接口继承的嵌套类/接口 cn.taketoday.context.ApplicationContext
ApplicationContext.State -
字段概要
从类继承的字段 cn.taketoday.context.support.AbstractApplicationContext
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, log, MESSAGE_SOURCE_BEAN_NAME从接口继承的字段 cn.taketoday.context.ApplicationContext
APPLICATION_NAME从接口继承的字段 cn.taketoday.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX从接口继承的字段 cn.taketoday.context.ConfigurableApplicationContext
CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME从接口继承的字段 cn.taketoday.core.io.PatternResourceLoader
CLASSPATH_ALL_URL_PREFIX从接口继承的字段 cn.taketoday.core.io.ResourceLoader
CLASSPATH_URL_PREFIX -
构造器概要
构造器构造器说明Create a new AbstractRefreshableApplicationContext with no parent.Create a new AbstractRefreshableApplicationContext with the given parent context. -
方法概要
修饰符和类型方法说明protected voidOverridden to turn it into a no-op: With AbstractRefreshableApplicationContext,getBeanFactory()serves a strong assertion for an active context anyway.protected voidCancel this context's refresh attempt, after an exception got thrown.protected final voidSubclasses must implement this method to release their internal bean factory.booleancontainsBeanDefinition(Class<?> type) booleancontainsBeanDefinition(Class<?> type, boolean equals) booleancontainsBeanDefinition(String beanName) booleancontainsBeanDefinition(String beanName, Class<?> type) protected StandardBeanFactoryCreate an internal bean factory for this context.protected BootstrapContextReturn the DefinitionLoadingContext to use for loading this contextprotected voidcustomizeBeanFactory(StandardBeanFactory beanFactory) Customize the internal bean factory used by this context.getAliasList(String name) getBeanDefinition(Class<?> requiredType) getBeanDefinition(String beanName) intString[]final StandardBeanFactorySubclasses must return their internal bean factory here.protected final booleanDetermine whether this context currently holds a bean factory, i.e. has been refreshed at least once and not been closed yet.booleanbooleanbooleanisBeanNameInUse(String beanName) protected abstract voidloadBeanDefinitions(StandardBeanFactory beanFactory) Load bean definitions into the given bean factory, typically through delegating to one or more bean definition readers.protected final voidThis implementation performs an actual refresh of this context's underlying bean factory, shutting down the previous bean factory (if any) and initializing a fresh bean factory for the next phase of the context's lifecycle.voidregisterAlias(String name, String alias) voidregisterBeanDefinition(String beanName, BeanDefinition def) voidremoveAlias(String alias) voidremoveBeanDefinition(String beanName) voidsetAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding) Set whether it should be allowed to override bean definitions by registering a different definition with the same name, automatically replacing the former.voidsetAllowCircularReferences(boolean allowCircularReferences) Set whether to allow circular references between beans - and automatically try to resolve them.从类继承的方法 cn.taketoday.context.support.AbstractApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, addFactoryPostProcessors, applyState, close, containsBean, containsLocalBean, createEnvironment, destroyBeans, doClose, findAnnotationOnBean, findAnnotationOnBean, findSynthesizedAnnotation, finishBeanFactoryInitialization, finishRefresh, formatStartupDate, getAliases, getAnnotatedBeans, getApplicationEventMulticaster, getApplicationListeners, getApplicationName, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBean, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeans, getBeansOfType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getBeansWithAnnotation, getBootstrapContext, getDisplayName, getEnvironment, getExpressionEvaluator, getFactoryPostProcessors, getId, getInjector, getInternalParentBeanFactory, getInternalParentMessageSource, getLifecycleProcessor, getMessage, getMessage, getMessage, getObjectSupplier, getObjectSupplier, getObjectSupplier, getObjectSupplier, getParent, getParentBeanFactory, getPatternResourceLoader, getResources, getStartupDate, getState, getType, getType, hasStarted, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, isTypeMatch, obtainBootstrapContext, obtainFreshBeanFactory, onClose, onRefresh, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, refresh, registerApplicationListeners, registerBeanPostProcessors, registerFrameworkComponents, registerShutdownHook, removeApplicationListener, resetCommonCaches, scan, setBootstrapContext, setDisplayName, setEnvironment, setId, setLifecycleProcessor, setParent, start, stop, toString, unwrapFactory从类继承的方法 cn.taketoday.core.io.DefaultResourceLoader
addProtocolResolver, clearResourceCaches, getClassLoader, getProtocolResolvers, getResource, getResourceByPath, getResourceCache, setClassLoader从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait从接口继承的方法 cn.taketoday.core.AliasRegistry
getAliases从接口继承的方法 cn.taketoday.beans.factory.BeanFactory
getBeanNamesForType, unwrap从接口继承的方法 cn.taketoday.context.ConfigurableApplicationContext
addProtocolResolver, setClassLoader从接口继承的方法 cn.taketoday.core.io.PatternResourceLoader
getResourcesArray从接口继承的方法 cn.taketoday.core.io.ResourceLoader
getClassLoader, getResource
-
构造器详细资料
-
AbstractRefreshableApplicationContext
public AbstractRefreshableApplicationContext()Create a new AbstractRefreshableApplicationContext with no parent. -
AbstractRefreshableApplicationContext
Create a new AbstractRefreshableApplicationContext with the given parent context.- 参数:
parent- the parent context
-
-
方法详细资料
-
createBootstrapContext
从类复制的说明:AbstractApplicationContextReturn the DefinitionLoadingContext to use for loading this context- 指定者:
createBootstrapContext在类中AbstractApplicationContext- 返回:
- the DefinitionLoadingContext for this context
-
setAllowBeanDefinitionOverriding
public void setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding) Set whether it should be allowed to override bean definitions by registering a different definition with the same name, automatically replacing the former. If not, an exception will be thrown. Default is "true". -
setAllowCircularReferences
public void setAllowCircularReferences(boolean allowCircularReferences) Set whether to allow circular references between beans - and automatically try to resolve them.Default is "true". Turn this off to throw an exception when encountering a circular reference, disallowing them completely.
-
refreshBeanFactory
This implementation performs an actual refresh of this context's underlying bean factory, shutting down the previous bean factory (if any) and initializing a fresh bean factory for the next phase of the context's lifecycle.- 指定者:
refreshBeanFactory在类中AbstractApplicationContext- 抛出:
BeansException- if initialization of the bean factory failed
-
cancelRefresh
从类复制的说明:AbstractApplicationContextCancel this context's refresh attempt, after an exception got thrown.- 覆盖:
cancelRefresh在类中AbstractApplicationContext- 参数:
ex- the exception that led to the cancellation
-
closeBeanFactory
protected final void closeBeanFactory()从类复制的说明:AbstractApplicationContextSubclasses must implement this method to release their internal bean factory. This method gets invoked byAbstractApplicationContext.close()after all other shutdown work.Should never throw an exception but rather log shutdown failures.
-
hasBeanFactory
protected final boolean hasBeanFactory()Determine whether this context currently holds a bean factory, i.e. has been refreshed at least once and not been closed yet. -
getBeanFactory
从类复制的说明:AbstractApplicationContextSubclasses must return their internal bean factory here. They should implement the lookup efficiently, so that it can be called repeatedly without a performance penalty.Note: Subclasses should check whether the context is still active before returning the internal bean factory. The internal factory should generally be considered unavailable once the context has been closed.
- 指定者:
getBeanFactory在接口中ApplicationContext- 指定者:
getBeanFactory在接口中ConfigurableApplicationContext- 指定者:
getBeanFactory在类中AbstractApplicationContext- 返回:
- this application context's internal bean factory (never
null) - 另请参阅:
-
assertBeanFactoryActive
protected void assertBeanFactoryActive()Overridden to turn it into a no-op: With AbstractRefreshableApplicationContext,getBeanFactory()serves a strong assertion for an active context anyway. -
createBeanFactory
Create an internal bean factory for this context. Called for eachAbstractApplicationContext.refresh()attempt.The default implementation creates a
StandardBeanFactorywith the internal bean factory of this context's parent as parent bean factory. Can be overridden in subclasses, for example to customize StandardBeanFactory's settings.- 返回:
- the bean factory for this context
- 另请参阅:
-
customizeBeanFactory
Customize the internal bean factory used by this context. Called for eachAbstractApplicationContext.refresh()attempt.The default implementation applies this context's "allowBeanDefinitionOverriding" and "allowCircularReferences" settings, if specified. Can be overridden in subclasses to customize any of
StandardBeanFactory's settings.- 参数:
beanFactory- the newly created bean factory for this context- 另请参阅:
-
loadBeanDefinitions
protected abstract void loadBeanDefinitions(StandardBeanFactory beanFactory) throws BeansException, IOException Load bean definitions into the given bean factory, typically through delegating to one or more bean definition readers.- 参数:
beanFactory- the bean factory to load bean definitions into- 抛出:
BeansException- if parsing of the bean definitions failedIOException- if loading of bean definition files failed
-
getBeanDefinitions
- 指定者:
getBeanDefinitions在接口中BeanDefinitionRegistry- 指定者:
getBeanDefinitions在接口中BeanFactory- 覆盖:
getBeanDefinitions在类中AbstractApplicationContext
-
registerBeanDefinition
- 指定者:
registerBeanDefinition在接口中BeanDefinitionRegistry
-
removeBeanDefinition
- 指定者:
removeBeanDefinition在接口中BeanDefinitionRegistry
-
getBeanDefinition
- 指定者:
getBeanDefinition在接口中BeanDefinitionRegistry- 指定者:
getBeanDefinition在接口中BeanFactory- 覆盖:
getBeanDefinition在类中AbstractApplicationContext
-
getBeanDefinition
- 指定者:
getBeanDefinition在接口中BeanDefinitionRegistry
-
containsBeanDefinition
- 指定者:
containsBeanDefinition在接口中BeanDefinitionRegistry
-
containsBeanDefinition
- 指定者:
containsBeanDefinition在接口中BeanDefinitionRegistry
-
containsBeanDefinition
- 指定者:
containsBeanDefinition在接口中BeanDefinitionRegistry
-
containsBeanDefinition
- 指定者:
containsBeanDefinition在接口中BeanDefinitionRegistry- 指定者:
containsBeanDefinition在接口中BeanFactory- 覆盖:
containsBeanDefinition在类中AbstractApplicationContext
-
getBeanDefinitionNames
- 指定者:
getBeanDefinitionNames在接口中BeanDefinitionRegistry- 指定者:
getBeanDefinitionNames在接口中BeanFactory- 覆盖:
getBeanDefinitionNames在类中AbstractApplicationContext
-
getBeanDefinitionCount
public int getBeanDefinitionCount()- 指定者:
getBeanDefinitionCount在接口中BeanDefinitionRegistry- 指定者:
getBeanDefinitionCount在接口中BeanFactory- 覆盖:
getBeanDefinitionCount在类中AbstractApplicationContext
-
isAllowBeanDefinitionOverriding
public boolean isAllowBeanDefinitionOverriding() -
registerAlias
- 指定者:
registerAlias在接口中cn.taketoday.core.AliasRegistry
-
removeAlias
- 指定者:
removeAlias在接口中cn.taketoday.core.AliasRegistry
-
isAlias
- 指定者:
isAlias在接口中cn.taketoday.core.AliasRegistry
-
getAliasList
- 指定者:
getAliasList在接口中cn.taketoday.core.AliasRegistry
-
isBeanNameInUse
- 指定者:
isBeanNameInUse在接口中BeanDefinitionRegistry
-