类 AbstractApplicationContext
- 所有已实现的接口:
BeanFactory,HierarchicalBeanFactory,DependencyInjectorProvider,ApplicationContext,ApplicationEventPublisher,ConfigurableApplicationContext,Lifecycle,MessageSource,cn.taketoday.core.env.EnvironmentCapable,cn.taketoday.core.io.PatternResourceLoader,cn.taketoday.core.io.ResourceLoader,Closeable,AutoCloseable
ApplicationContext
interface. Doesn't mandate the type of storage used for configuration; simply
implements common context functionality. Uses the Template Method design pattern,
requiring concrete subclasses to implement abstract methods.
In contrast to a plain BeanFactory, an ApplicationContext is supposed
to detect special beans defined in its internal bean factory:
Therefore, this class automatically registers
BeanFactoryPostProcessors,
BeanPostProcessors, and
ApplicationListeners which are defined as beans in the context.
Implements resource loading by extending PathMatchingPatternResourceLoader.
Consequently, treats non-URL resource paths as class path resources
(supporting full class path resource names that include the package path,
e.g. "mypackage/myresource.dat")
- 作者:
- TODAY 2018-09-09 22:02
-
嵌套类概要
从类继承的嵌套类/接口 cn.taketoday.core.io.DefaultResourceLoader
cn.taketoday.core.io.DefaultResourceLoader.ClassPathContextResource从接口继承的嵌套类/接口 cn.taketoday.context.ApplicationContext
ApplicationContext.State -
字段概要
字段修饰符和类型字段说明static final StringName of the ApplicationEventMulticaster bean in the factory.static final StringName of the LifecycleProcessor bean in the factory.protected final cn.taketoday.logging.Loggerstatic final StringName of the MessageSource bean in the factory.从接口继承的字段 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 AbstractApplicationContext with no parent.Create a new AbstractApplicationContext with the given parent context. -
方法概要
修饰符和类型方法说明voidaddApplicationListener(ApplicationListener<?> listener) Add a new ApplicationListener that will be notified on context events such as context refresh and context shutdown.voidaddBeanFactoryPostProcessor(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.voidaddFactoryPostProcessors(BeanFactoryPostProcessor... postProcessors) protected voidprotected voidAssert that this context's BeanFactory is currently active, throwing anIllegalStateExceptionif it isn't.protected voidCancel this context's refresh attempt, after an exception got thrown.voidclose()Close this application context, destroying all beans in its bean factory.protected voidSubclasses must implement this method to release their internal bean factory.booleancontainsBean(String name) booleancontainsBeanDefinition(String beanName) booleancontainsLocalBean(String name) protected abstract BootstrapContextReturn the DefinitionLoadingContext to use for loading this contextprotected cn.taketoday.core.env.ConfigurableEnvironmentCreate and return a newStandardEnvironment.protected voidTemplate method for destroying all beans that this context manages.protected voiddoClose()Actually performs context closing: publishes a ContextClosedEvent and destroys the singletons in the bean factory of this application context.<A extends Annotation>
cn.taketoday.core.annotation.MergedAnnotation<A>findAnnotationOnBean(String beanName, Class<A> annotationType) <A extends Annotation>
cn.taketoday.core.annotation.MergedAnnotation<A>findAnnotationOnBean(String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) <A extends Annotation>
AfindSynthesizedAnnotation(String beanName, Class<A> annotationType) protected voidfinishBeanFactoryInitialization(ConfigurableBeanFactory beanFactory) Finish the initialization of this context's bean factory, initializing all remaining singleton beans.protected voidFinish the refresh of this context, invoking the LifecycleProcessor's onRefresh() method and publishing theContextRefreshedEvent.String[]getAliases(String name) <T> List<T>getAnnotatedBeans(Class<? extends Annotation> annotationType) Return the internal ApplicationEventMulticaster used by the context.Return the list of statically specified ApplicationListeners.Return this application name for this context.Expose AutowireCapableBeanFactory functionality for this context.<T> T<T> T<T> TgetBeanDefinition(String beanName) intString[]abstract ConfigurableBeanFactorySubclasses must return their internal bean factory here.getBeanNamesForAnnotation(Class<? extends Annotation> annotationType) getBeanNamesForType(cn.taketoday.core.ResolvableType requiredType) getBeanNamesForType(cn.taketoday.core.ResolvableType requiredType, boolean includeNonSingletons, boolean allowEagerInit) getBeanNamesForType(Class<?> requiredType, boolean includeNonSingletons) getBeanNamesForType(Class<?> requiredType, boolean includeNonSingletons, boolean allowEagerInit) <T> List<T>getBeansOfType(cn.taketoday.core.ResolvableType requiredType, boolean includeNonSingletons, boolean allowEagerInit) getBeansOfType(Class<T> requiredType) getBeansOfType(Class<T> requiredType, boolean includeNonSingletons, boolean allowEagerInit) getBeansWithAnnotation(Class<? extends Annotation> annotationType) getBeansWithAnnotation(Class<? extends Annotation> annotationType, boolean includeNonSingletons) Returns BootstrapContextReturn a friendly name for this context.cn.taketoday.core.env.ConfigurableEnvironmentGet configurable environmentgetId()Return the unique id of this application context.protected BeanFactoryReturn the internal bean factory of the parent context if it implements ConfigurableApplicationContext; else, return the parent context itself.protected MessageSourceReturn the internal message source of the parent context if it is an AbstractApplicationContext too; else, return the parent context itself.Return the internal LifecycleProcessor used by the context.getMessage(MessageSourceResolvable resolvable, Locale locale) Try to resolve the message using all the attributes contained within theMessageSourceResolvableargument that was passed in.getMessage(String code, Object[] args, String defaultMessage, Locale locale) Try to resolve the message.getMessage(String code, Object[] args, Locale locale) Try to resolve the message.<T> ObjectSupplier<T>getObjectSupplier(cn.taketoday.core.ResolvableType requiredType) <T> ObjectSupplier<T>getObjectSupplier(cn.taketoday.core.ResolvableType requiredType, boolean allowEagerInit) <T> ObjectSupplier<T>getObjectSupplier(Class<T> requiredType) <T> ObjectSupplier<T>getObjectSupplier(Class<T> requiredType, boolean allowEagerInit) Return the parent context, ornullif there is no parent (that is, this context is the root of the context hierarchy).protected cn.taketoday.core.io.PatternResourceLoaderReturn the ResourcePatternResolver to use for resolving location patterns into Resource instances.Set<cn.taketoday.core.io.Resource>getResources(String locationPattern) longGet the context startup time stampgetState()Get context's stateClass<?>Class<?>booleanContext has startedprotected voidInitialize the ApplicationEventMulticaster.protected voidInitialize the LifecycleProcessor.protected voidInitialize the MessageSource.protected voidload properties files or itself strategiesprotected voidinvokeBeanFactoryPostProcessors(ConfigurableBeanFactory beanFactory) Instantiate and invoke all registered BeanFactoryPostProcessor beans, respecting explicit order if given.booleanisActive()Determine whether this application context is active, that is, whether it has been refreshed at least once and has not been closed yet.booleanisPrototype(String name) booleanCheck whether this component is currently running.booleanisSingleton(String name) booleanisTypeMatch(String name, cn.taketoday.core.ResolvableType typeToMatch) booleanisTypeMatch(String name, Class<?> typeToMatch) protected final BootstrapContextprotected ConfigurableBeanFactoryTell the subclass to refresh the internal bean factory.protected voidonClose()Template method which can be overridden to add context-specific shutdown work.protected voidInitialization singletons that has already in contextprotected voidpostProcessBeanFactory(ConfigurableBeanFactory beanFactory) Modify the application context's internal bean factory after its standard initialization.voidprepareBeanFactory(ConfigurableBeanFactory beanFactory) Configure the factory's standard context characteristics, such as the context's ClassLoader and post-processors.protected voidPrepare to load contextvoidpublishEvent(Object event) Notify all matching listeners registered with this application of an event.protected voidpublishEvent(Object event, cn.taketoday.core.ResolvableType eventType) Publish the given event to all listeners.voidrefresh()Load or refresh the persistent representation of the configuration, which might be from Java-based configuration or some other format.protected abstract voidSubclasses must implement this method to perform the actual configuration load.protected voidprotected voidregisterBeanPostProcessors(ConfigurableBeanFactory beanFactory) Instantiate and register all BeanPostProcessor beans, respecting explicit order if given.protected voidregisterFrameworkComponents(ConfigurableBeanFactory beanFactory) Register Framework BeansvoidRegister a shutdown hook namedContextShutdownHookwith the JVM runtime, closing this context on JVM shutdown unless it has already been closed at that time.voidremoveApplicationListener(ApplicationListener<?> listener) Remove the given ApplicationListener from this context's set of listeners, assuming it got registered viaConfigurableApplicationContext.addApplicationListener(cn.taketoday.context.ApplicationListener<?>)before.protected voidReset reflection metadata caches, in particular theReflectionUtils,AnnotationUtils,ResolvableTypevoidvoidsetBootstrapContext(BootstrapContext bootstrapContext) set BootstrapContextvoidsetDisplayName(String displayName) Set a friendly name for this context.voidsetEnvironment(cn.taketoday.core.env.ConfigurableEnvironment environment) Set theEnvironmentfor this application context.voidSet the unique id of this application context.voidsetLifecycleProcessor(LifecycleProcessor lifecycleProcessor) voidsetParent(ApplicationContext parent) Set the parent of this application context.voidstart()Start this component.voidstop()Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.toString()Return information about this context.<T> TunwrapFactory(Class<T> requiredType) unwrap bean-factory torequiredType从类继承的方法 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.beans.factory.BeanFactory
getBeanNamesForType, unwrap从接口继承的方法 cn.taketoday.context.ConfigurableApplicationContext
addProtocolResolver, setClassLoader从接口继承的方法 cn.taketoday.core.io.PatternResourceLoader
getResourcesArray从接口继承的方法 cn.taketoday.core.io.ResourceLoader
getClassLoader, getResource
-
字段详细资料
-
log
protected final cn.taketoday.logging.Logger log -
APPLICATION_EVENT_MULTICASTER_BEAN_NAME
Name of the ApplicationEventMulticaster bean in the factory. If none is supplied, a default SimpleApplicationEventMulticaster is used. -
MESSAGE_SOURCE_BEAN_NAME
Name of the MessageSource bean in the factory. If none is supplied, message resolution is delegated to the parent.- 另请参阅:
-
LIFECYCLE_PROCESSOR_BEAN_NAME
Name of the LifecycleProcessor bean in the factory. If none is supplied, a DefaultLifecycleProcessor is used.
-
-
构造器详细资料
-
AbstractApplicationContext
public AbstractApplicationContext()Create a new AbstractApplicationContext with no parent. -
AbstractApplicationContext
Create a new AbstractApplicationContext with the given parent context.- 参数:
parent- the parent context
-
-
方法详细资料
-
createBootstrapContext
Return the DefinitionLoadingContext to use for loading this context- 返回:
- the DefinitionLoadingContext for this context
- 从以下版本开始:
- 4.0
-
setBootstrapContext
set BootstrapContext- 参数:
bootstrapContext- BootstrapContext- 从以下版本开始:
- 4.0
-
getBootstrapContext
Returns BootstrapContext- 返回:
- Returns BootstrapContext
- 从以下版本开始:
- 4.0
-
obtainBootstrapContext
-
getResources
- 指定者:
getResources在接口中cn.taketoday.core.io.PatternResourceLoader- 抛出:
IOException
-
scan
public void scan(String locationPattern, cn.taketoday.core.io.ResourceConsumer consumer) throws IOException - 指定者:
scan在接口中cn.taketoday.core.io.PatternResourceLoader- 抛出:
IOException
-
getPatternResourceLoader
protected cn.taketoday.core.io.PatternResourceLoader getPatternResourceLoader()Return the ResourcePatternResolver to use for resolving location patterns into Resource instances. Default is aPathMatchingPatternResourceLoader, supporting Ant-style location patterns.Can be overridden in subclasses, for extended resolution strategies, for example in a web environment.
Do not call this when needing to resolve a location pattern. Call the context's
getResourcesmethod instead, which will delegate to the ResourcePatternResolver.- 返回:
- the ResourcePatternResolver for this context
- 另请参阅:
-
getResources(java.lang.String)PathMatchingPatternResourceLoader
-
setId
Set the unique id of this application context.Default is the object id of the context instance, or the name of the context bean if the context is itself defined as a bean.
- 指定者:
setId在接口中ConfigurableApplicationContext- 参数:
id- the unique id of the context
-
getId
从接口复制的说明:ApplicationContextReturn the unique id of this application context.- 指定者:
getId在接口中ApplicationContext- 返回:
- the unique id of the context, or
nullif none
-
getApplicationName
Return this application name for this context.- 指定者:
getApplicationName在接口中ApplicationContext- 返回:
- a display name for this context (never
null)
-
setDisplayName
Set a friendly name for this context. Typically done during initialization of concrete context implementations.Default is the object id of the context instance.
- 从以下版本开始:
- 4.0
-
getDisplayName
Return a friendly name for this context.- 指定者:
getDisplayName在接口中ApplicationContext- 返回:
- a display name for this context (never
null) - 从以下版本开始:
- 4.0
-
getParent
Return the parent context, ornullif there is no parent (that is, this context is the root of the context hierarchy).- 指定者:
getParent在接口中ApplicationContext- 返回:
- the parent context, or
nullif there is no parent
-
getAutowireCapableBeanFactory
从接口复制的说明:ApplicationContextExpose AutowireCapableBeanFactory functionality for this context.This is not typically used by application code, except for the purpose of initializing bean instances that live outside of the application context, applying the bean lifecycle (fully or partly) to them.
Alternatively, the internal BeanFactory exposed by the
ConfigurableApplicationContextinterface offers access to theAutowireCapableBeanFactoryinterface too. The present method mainly serves as a convenient, specific facility on the ApplicationContext interface.NOTE: this method will consistently throw IllegalStateException after the application context has been closed. In current Framework versions, only refreshable application contexts behave that way; all application context implementations will be required to comply.
- 指定者:
getAutowireCapableBeanFactory在接口中ApplicationContext- 返回:
- the AutowireCapableBeanFactory for this context
- 另请参阅:
-
getExpressionEvaluator
- 指定者:
getExpressionEvaluator在接口中ApplicationContext- 返回:
- ExpressionEvaluator of this context
-
getParentBeanFactory
- 指定者:
getParentBeanFactory在接口中HierarchicalBeanFactory
-
containsLocalBean
- 指定者:
containsLocalBean在接口中HierarchicalBeanFactory
-
getInternalParentBeanFactory
Return the internal bean factory of the parent context if it implements ConfigurableApplicationContext; else, return the parent context itself. -
getMessage
public String getMessage(String code, @Nullable Object[] args, @Nullable String defaultMessage, Locale locale) 从接口复制的说明:MessageSourceTry to resolve the message. Return default message if no message was found.- 指定者:
getMessage在接口中MessageSource- 参数:
code- the message code to look up, e.g. 'calculator.noRateSet'. MessageSource users are encouraged to base message names on qualified class or package names, avoiding potential conflicts and ensuring maximum clarity.args- an array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornullif nonedefaultMessage- a default message to return if the lookup failslocale- the locale in which to do the lookup- 返回:
- the resolved message if the lookup was successful, otherwise
the default message passed as a parameter (which may be
null) - 另请参阅:
-
getMessage
public String getMessage(String code, @Nullable Object[] args, Locale locale) throws NoSuchMessageException 从接口复制的说明:MessageSourceTry to resolve the message. Treat as an error if the message can't be found.- 指定者:
getMessage在接口中MessageSource- 参数:
code- the message code to look up, e.g. 'calculator.noRateSet'. MessageSource users are encouraged to base message names on qualified class or package names, avoiding potential conflicts and ensuring maximum clarity.args- an array of arguments that will be filled in for params within the message (params look like "{0}", "{1,date}", "{2,time}" within a message), ornullif nonelocale- the locale in which to do the lookup- 返回:
- the resolved message (never
null) - 抛出:
NoSuchMessageException- if no corresponding message was found- 另请参阅:
-
getMessage
public String getMessage(MessageSourceResolvable resolvable, Locale locale) throws NoSuchMessageException 从接口复制的说明:MessageSourceTry to resolve the message using all the attributes contained within theMessageSourceResolvableargument that was passed in.NOTE: We must throw a
NoSuchMessageExceptionon this method since at the time of calling this method we aren't able to determine if thedefaultMessageproperty of the resolvable isnullor not.- 指定者:
getMessage在接口中MessageSource- 参数:
resolvable- the value object storing attributes required to resolve a message (may include a default message)locale- the locale in which to do the lookup- 返回:
- the resolved message (never
nullsince even aMessageSourceResolvable-provided default message needs to be non-null) - 抛出:
NoSuchMessageException- if no corresponding message was found (and no default message was provided by theMessageSourceResolvable)- 另请参阅:
-
getInternalParentMessageSource
Return the internal message source of the parent context if it is an AbstractApplicationContext too; else, return the parent context itself. -
resetCommonCaches
protected void resetCommonCaches()Reset reflection metadata caches, in particular theReflectionUtils,AnnotationUtils,ResolvableType- 从以下版本开始:
- 4.0
- 另请参阅:
-
ReflectionUtils.clearCache()AnnotationUtils.clearCache()ResolvableType.clearCache()
-
refresh
从接口复制的说明:ConfigurableApplicationContextLoad or refresh the persistent representation of the configuration, which might be from Java-based configuration 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.
- 指定者:
refresh在接口中ConfigurableApplicationContext- 抛出:
ApplicationContextException- if the bean factory could not be initializedIllegalStateException- if already initialized and multiple refresh attempts are not supportedBeansException
-
prepareRefresh
protected void prepareRefresh()Prepare to load context -
initPropertySources
load properties files or itself strategies
-
registerFrameworkComponents
Register Framework Beans -
onRefresh
protected void onRefresh()Initialization singletons that has already in context -
obtainFreshBeanFactory
Tell the subclass to refresh the internal bean factory.- 返回:
- the fresh BeanFactory instance
- 从以下版本开始:
- 4.0
- 另请参阅:
-
prepareBeanFactory
Configure the factory's standard context characteristics, such as the context's ClassLoader and post-processors.- 参数:
beanFactory- the BeanFactory to configure
-
postProcessBeanFactory
Modify the application context's internal bean factory after its standard initialization. All bean definitions will have been loaded, but no beans will have been instantiated yet. This allows for registering special BeanPostProcessors etc in certain ApplicationContext implementations.- 参数:
beanFactory- the bean factory used by the application context
-
invokeBeanFactoryPostProcessors
Instantiate and invoke all registered BeanFactoryPostProcessor beans, respecting explicit order if given.Must be called before singleton instantiation.
-
registerBeanPostProcessors
Instantiate and register all BeanPostProcessor beans, respecting explicit order if given.Must be called before any instantiation of application beans.
-
initMessageSource
protected void initMessageSource()Initialize the MessageSource. Use parent's if none defined in this context. -
cancelRefresh
Cancel this context's refresh attempt, after an exception got thrown.- 参数:
ex- the exception that led to the cancellation
-
doClose
protected void doClose()Actually performs context closing: publishes a ContextClosedEvent and destroys the singletons in the bean factory of this application context.Called by both
close()and a JVM shutdown hook, if any.- 从以下版本开始:
- 4.0
- 另请参阅:
-
registerShutdownHook
public void registerShutdownHook()Register a shutdown hook namedContextShutdownHookwith the JVM runtime, closing this context on JVM shutdown unless it has already been closed at that time.Delegates to
doClose()for the actual closing procedure. -
close
public void close()Close this application context, destroying all beans in its bean factory.Delegates to
doClose()for the actual closing procedure. Also removes a JVM shutdown hook, if registered, as it's not needed anymore.- 指定者:
close在接口中ApplicationContext- 指定者:
close在接口中AutoCloseable- 指定者:
close在接口中Closeable- 指定者:
close在接口中ConfigurableApplicationContext- 另请参阅:
-
destroyBeans
protected void destroyBeans()Template method for destroying all beans that this context manages. The default implementation destroy all cached singletons in this context, invokingDisposableBean.destroy()and/or the specified "destroy-method".Can be overridden to add context-specific bean destruction steps right before or right after standard singleton destruction, while the context's BeanFactory is still active.
- 从以下版本开始:
- 4.0
- 另请参阅:
-
onClose
protected void onClose()Template method which can be overridden to add context-specific shutdown work. The default implementation is empty.Called at the end of
doClose()'s shutdown procedure, after this context's BeanFactory has been closed. If custom shutdown logic needs to execute while the BeanFactory is still active, override thedestroyBeans()method instead.- 从以下版本开始:
- 4.0
-
isActive
public boolean isActive()从接口复制的说明:ConfigurableApplicationContextDetermine whether this application context is active, that is, whether it has been refreshed at least once and has not been closed yet.- 指定者:
isActive在接口中ConfigurableApplicationContext- 返回:
- whether the context is still active
- 另请参阅:
-
unwrapFactory
从接口复制的说明:ApplicationContextunwrap bean-factory torequiredType- 指定者:
unwrapFactory在接口中ApplicationContext- 另请参阅:
-
hasStarted
public boolean hasStarted()从接口复制的说明:ApplicationContextContext has started- 指定者:
hasStarted在接口中ApplicationContext- 返回:
- is started
-
getState
从接口复制的说明:ApplicationContextGet context's state- 指定者:
getState在接口中ApplicationContext- 返回:
- context's state
-
applyState
-
getStartupDate
public long getStartupDate()从接口复制的说明:ApplicationContextGet the context startup time stamp- 指定者:
getStartupDate在接口中ApplicationContext- 返回:
- startup timestamp
-
setParent
Set the parent of this application context.The parent environment is merged with this (child) application context environment if the parent is non-
nulland its environment is an instance ofConfigurableEnvironment.- 指定者:
setParent在接口中ConfigurableApplicationContext- 参数:
parent- the parent context- 另请参阅:
-
ConfigurableEnvironment.merge(ConfigurableEnvironment)
-
getEnvironment
public cn.taketoday.core.env.ConfigurableEnvironment getEnvironment()从接口复制的说明:ConfigurableApplicationContextGet configurable environment- 指定者:
getEnvironment在接口中ApplicationContext- 指定者:
getEnvironment在接口中ConfigurableApplicationContext- 指定者:
getEnvironment在接口中cn.taketoday.core.env.EnvironmentCapable- 返回:
ConfigurableEnvironmentnever be null
-
createEnvironment
protected cn.taketoday.core.env.ConfigurableEnvironment createEnvironment()Create and return a newStandardEnvironment.Subclasses may override this method in order to supply a custom
ConfigurableEnvironmentimplementation. -
setEnvironment
public void setEnvironment(cn.taketoday.core.env.ConfigurableEnvironment environment) 从接口复制的说明:ConfigurableApplicationContextSet theEnvironmentfor this application context.- 指定者:
setEnvironment在接口中ConfigurableApplicationContext- 参数:
environment- the new environment
-
addBeanFactoryPostProcessor
从接口复制的说明:ConfigurableApplicationContextAdd 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.- 指定者:
addBeanFactoryPostProcessor在接口中ConfigurableApplicationContext- 参数:
postProcessor- the factory processor to register
-
assertBeanFactoryActive
protected void assertBeanFactoryActive()Assert that this context's BeanFactory is currently active, throwing anIllegalStateExceptionif it isn't.Invoked by all
BeanFactorydelegation methods that depend on an active context, i.e. in particular all bean accessor methods. -
getBean
- 指定者:
getBean在接口中BeanFactory
-
getBean
- 指定者:
getBean在接口中BeanFactory- 抛出:
BeansException
-
getBean
- 指定者:
getBean在接口中BeanFactory
-
getBean
- 指定者:
getBean在接口中BeanFactory- 抛出:
BeansException
-
getBean
- 指定者:
getBean在接口中BeanFactory
-
findSynthesizedAnnotation
- 指定者:
findSynthesizedAnnotation在接口中BeanFactory
-
findAnnotationOnBean
public <A extends Annotation> cn.taketoday.core.annotation.MergedAnnotation<A> findAnnotationOnBean(String beanName, Class<A> annotationType) throws NoSuchBeanDefinitionException - 指定者:
findAnnotationOnBean在接口中BeanFactory- 抛出:
NoSuchBeanDefinitionException
-
findAnnotationOnBean
public <A extends Annotation> cn.taketoday.core.annotation.MergedAnnotation<A> findAnnotationOnBean(String beanName, Class<A> annotationType, boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException - 指定者:
findAnnotationOnBean在接口中BeanFactory- 抛出:
NoSuchBeanDefinitionException
-
getAnnotatedBeans
- 指定者:
getAnnotatedBeans在接口中BeanFactory
-
getBeansWithAnnotation
- 指定者:
getBeansWithAnnotation在接口中BeanFactory
-
getBeansWithAnnotation
public Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType, boolean includeNonSingletons) - 指定者:
getBeansWithAnnotation在接口中BeanFactory
-
getBeanDefinitions
- 指定者:
getBeanDefinitions在接口中BeanFactory
-
isSingleton
- 指定者:
isSingleton在接口中BeanFactory
-
isPrototype
- 指定者:
isPrototype在接口中BeanFactory
-
getType
- 指定者:
getType在接口中BeanFactory
-
getType
@Nullable public Class<?> getType(String name, boolean allowFactoryBeanInit) throws NoSuchBeanDefinitionException - 指定者:
getType在接口中BeanFactory- 抛出:
NoSuchBeanDefinitionException
-
getBeanNamesForAnnotation
- 指定者:
getBeanNamesForAnnotation在接口中BeanFactory
-
containsBean
- 指定者:
containsBean在接口中BeanFactory
-
isTypeMatch
- 指定者:
isTypeMatch在接口中BeanFactory- 抛出:
NoSuchBeanDefinitionException
-
isTypeMatch
public boolean isTypeMatch(String name, cn.taketoday.core.ResolvableType typeToMatch) throws NoSuchBeanDefinitionException - 指定者:
isTypeMatch在接口中BeanFactory- 抛出:
NoSuchBeanDefinitionException
-
getObjectSupplier
- 指定者:
getObjectSupplier在接口中BeanFactory
-
getObjectSupplier
- 指定者:
getObjectSupplier在接口中BeanFactory
-
getObjectSupplier
- 指定者:
getObjectSupplier在接口中BeanFactory
-
getObjectSupplier
public <T> ObjectSupplier<T> getObjectSupplier(cn.taketoday.core.ResolvableType requiredType, boolean allowEagerInit) - 指定者:
getObjectSupplier在接口中BeanFactory
-
getAliases
- 指定者:
getAliases在接口中BeanFactory
-
getBeans
- 指定者:
getBeans在接口中BeanFactory
-
getBeanNamesForType
- 指定者:
getBeanNamesForType在接口中BeanFactory
-
getBeanNamesForType
public Set<String> getBeanNamesForType(Class<?> requiredType, boolean includeNonSingletons, boolean allowEagerInit) - 指定者:
getBeanNamesForType在接口中BeanFactory
-
getBeansOfType
- 指定者:
getBeansOfType在接口中BeanFactory
-
getBeansOfType
public <T> Map<String,T> getBeansOfType(Class<T> requiredType, boolean includeNonSingletons, boolean allowEagerInit) - 指定者:
getBeansOfType在接口中BeanFactory
-
getBeansOfType
public <T> Map<String,T> getBeansOfType(cn.taketoday.core.ResolvableType requiredType, boolean includeNonSingletons, boolean allowEagerInit) - 指定者:
getBeansOfType在接口中BeanFactory
-
getBeanNamesForType
- 指定者:
getBeanNamesForType在接口中BeanFactory
-
getBeanNamesForType
public Set<String> getBeanNamesForType(cn.taketoday.core.ResolvableType requiredType, boolean includeNonSingletons, boolean allowEagerInit) - 指定者:
getBeanNamesForType在接口中BeanFactory
-
containsBeanDefinition
- 指定者:
containsBeanDefinition在接口中BeanFactory
-
getBeanDefinition
- 指定者:
getBeanDefinition在接口中BeanFactory- 抛出:
BeansException
-
getBeanDefinitionCount
public int getBeanDefinitionCount()- 指定者:
getBeanDefinitionCount在接口中BeanFactory
-
getBeanDefinitionNames
- 指定者:
getBeanDefinitionNames在接口中BeanFactory
-
getInjector
- 指定者:
getInjector在接口中DependencyInjectorProvider
-
getFactoryPostProcessors
-
addFactoryPostProcessors
-
start
public void start()从接口复制的说明:LifecycleStart this component.Should not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal to all components that apply.
-
stop
public void stop()从接口复制的说明:LifecycleStop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycleand itsstop(Runnable)variant when asynchronous stop behavior is necessary.Note that this stop notification is not guaranteed to come before destruction: On regular shutdown,
Lifecyclebeans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.Should not throw an exception if the component is not running (not started yet).
In the case of a container, this will propagate the stop signal to all components that apply.
-
isRunning
public boolean isRunning()从接口复制的说明:LifecycleCheck whether this component is currently running.In the case of a container, this will return
trueonly if all components that apply are currently running. -
setLifecycleProcessor
-
initLifecycleProcessor
protected void initLifecycleProcessor()Initialize the LifecycleProcessor. Uses DefaultLifecycleProcessor if none defined in the context. -
getLifecycleProcessor
Return the internal LifecycleProcessor used by the context.- 返回:
- the internal LifecycleProcessor (never
null) - 抛出:
IllegalStateException- if the context has not been initialized yet
-
getApplicationEventMulticaster
Return the internal ApplicationEventMulticaster used by the context.- 返回:
- the internal ApplicationEventMulticaster (never
null) - 抛出:
IllegalStateException- if the context has not been initialized yet
-
initApplicationEventMulticaster
protected void initApplicationEventMulticaster()Initialize the ApplicationEventMulticaster. Uses SimpleApplicationEventMulticaster if none defined in the context. -
getApplicationListeners
Return the list of statically specified ApplicationListeners. -
publishEvent
从接口复制的说明:ApplicationEventPublisherNotify all matching listeners registered with this application of an event.Such an event publication step is effectively a hand-off to the multicaster and does not imply synchronous/asynchronous execution or even immediate execution at all. Event listeners are encouraged to be as efficient as possible, individually using asynchronous execution for longer-running and potentially blocking operations.
- 指定者:
publishEvent在接口中ApplicationEventPublisher- 参数:
event- the event to publish- 另请参阅:
-
publishEvent
Publish the given event to all listeners.- 参数:
event- the event to publish (may be anApplicationEventeventType- the resolved event type, if known- 从以下版本开始:
- 4.0
-
registerApplicationListeners
protected void registerApplicationListeners() -
addApplicationListener
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.
- 指定者:
addApplicationListener在接口中ConfigurableApplicationContext- 参数:
listener- the ApplicationListener to register- 另请参阅:
-
removeApplicationListener
从接口复制的说明:ConfigurableApplicationContextRemove the given ApplicationListener from this context's set of listeners, assuming it got registered viaConfigurableApplicationContext.addApplicationListener(cn.taketoday.context.ApplicationListener<?>)before.- 指定者:
removeApplicationListener在接口中ConfigurableApplicationContext- 参数:
listener- the ApplicationListener to deregister
-
finishBeanFactoryInitialization
Finish the initialization of this context's bean factory, initializing all remaining singleton beans. -
finishRefresh
protected void finishRefresh()Finish the refresh of this context, invoking the LifecycleProcessor's onRefresh() method and publishing theContextRefreshedEvent. -
refreshBeanFactory
Subclasses must implement this method to perform the actual configuration load. The method is invoked byrefresh()before any other initialization work.A subclass will either create a new bean factory and hold a reference to it, or return a single BeanFactory instance that it holds. In the latter case, it will usually throw an IllegalStateException if refreshing the context more than once.
- 抛出:
BeansException- if initialization of the bean factory failedIllegalStateException- if already initialized and multiple refresh attempts are not supported- 从以下版本开始:
- 4.0
-
closeBeanFactory
protected void closeBeanFactory()Subclasses must implement this method to release their internal bean factory. This method gets invoked byclose()after all other shutdown work.Should never throw an exception but rather log shutdown failures.
- 从以下版本开始:
- 4.0
-
getBeanFactory
Subclasses 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- 返回:
- this application context's internal bean factory (never
null) - 抛出:
IllegalStateException- if the context does not hold an internal bean factory yet (usually ifrefresh()has never been called) or if the context has been closed already- 另请参阅:
-
toString
Return information about this context. -
formatStartupDate
-