|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.io.DefaultResourceLoader org.springframework.context.support.AbstractApplicationContext org.springframework.context.support.AbstractRefreshableApplicationContext org.springframework.config.java.context.JavaConfigApplicationContext
public class JavaConfigApplicationContext
Implementation of ApplicationContext
that accepts @Configuration
class literals and/or base package paths containing @Configuration
classes.
This feature enables users to avoid XML entirely and go "pure Java" with their configurations.
As with many ApplicationContext
implementations, a number of constructors are
provided, most of which cause a AbstractApplicationContext.refresh()
immediately for convenience. Others, such as
JavaConfigApplicationContext()
do not, and leave the context "open for configuration"
such that additional methods such as addConfigClass(Class)
,
setParent(ApplicationContext)
, etc may be called. See individual constructors for more
detail.
for use in web applications
Field Summary |
---|
Fields inherited from class org.springframework.context.support.AbstractApplicationContext |
---|
APPLICATION_EVENT_MULTICASTER_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME |
Fields inherited from interface org.springframework.context.ConfigurableApplicationContext |
---|
CONFIG_LOCATION_DELIMITERS, LOAD_TIME_WEAVER_BEAN_NAME |
Fields inherited from interface org.springframework.beans.factory.BeanFactory |
---|
FACTORY_BEAN_PREFIX |
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver |
---|
CLASSPATH_ALL_URL_PREFIX |
Fields inherited from interface org.springframework.core.io.ResourceLoader |
---|
CLASSPATH_URL_PREFIX |
Constructor Summary | |
---|---|
JavaConfigApplicationContext()
TODO: JAVADOC |
|
JavaConfigApplicationContext(org.springframework.context.ApplicationContext parent,
java.lang.Class<?>... classes)
|
|
JavaConfigApplicationContext(java.lang.Class<?>... classes)
|
|
JavaConfigApplicationContext(java.lang.Class<?>[] classes,
java.lang.String[] basePackages)
|
|
JavaConfigApplicationContext(JavaConfigApplicationContext parent)
Create a new context with parent as the parent. |
|
JavaConfigApplicationContext(java.lang.String... basePackages)
|
Method Summary | ||
---|---|---|
void |
addBasePackage(java.lang.String basePackage)
Allows for incrementally building up the base packages to be scanned by this context. |
|
void |
addConfigClass(java.lang.Class<?> cls)
Allows for incrementally building up the configuration classes to be processed by this context. |
|
protected void |
finishRefresh()
|
|
|
getBean(java.lang.Class<T> type)
Return an instance of the given type. |
|
|
getBean(java.lang.Class<T> type,
java.lang.String beanName)
Return an instance named beanName and of type type. |
|
BeanNamingStrategy |
getBeanNamingStrategy()
|
|
protected void |
invokeBeanFactoryPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
|
|
protected void |
loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
Loads any specified @Configuration classes
as bean definitions within this context's BeanFactory for later processing
by.ConfigurationPostProcessor |
|
void |
setBeanNamingStrategy(BeanNamingStrategy namingStrategy)
|
|
void |
setParent(org.springframework.context.ApplicationContext parent)
|
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext |
---|
closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences |
Methods inherited from class org.springframework.context.support.AbstractApplicationContext |
---|
addApplicationListener, addBeanFactoryPostProcessor, addListener, cancelRefresh, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, destroyBeans, doClose, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getResources, getStartupDate, getType, initApplicationEventMulticaster, initMessageSource, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setId, start, stop, toString |
Methods inherited from class org.springframework.core.io.DefaultResourceLoader |
---|
getClassLoader, getResource, getResourceByPath, setClassLoader |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.context.ConfigurableApplicationContext |
---|
addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, isActive, refresh, registerShutdownHook |
Methods inherited from interface org.springframework.context.ApplicationContext |
---|
getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate |
Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory |
---|
containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType |
Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory |
---|
containsLocalBean, getParentBeanFactory |
Methods inherited from interface org.springframework.beans.factory.BeanFactory |
---|
containsBean, getAliases, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch |
Methods inherited from interface org.springframework.context.MessageSource |
---|
getMessage, getMessage, getMessage |
Methods inherited from interface org.springframework.context.ApplicationEventPublisher |
---|
publishEvent |
Methods inherited from interface org.springframework.core.io.support.ResourcePatternResolver |
---|
getResources |
Methods inherited from interface org.springframework.core.io.ResourceLoader |
---|
getClassLoader, getResource |
Methods inherited from interface org.springframework.context.Lifecycle |
---|
isRunning, start, stop |
Constructor Detail |
---|
public JavaConfigApplicationContext()
public JavaConfigApplicationContext(java.lang.Class<?>... classes)
public JavaConfigApplicationContext(java.lang.String... basePackages)
public JavaConfigApplicationContext(JavaConfigApplicationContext parent)
parent
- public JavaConfigApplicationContext(java.lang.Class<?>[] classes, java.lang.String[] basePackages)
public JavaConfigApplicationContext(org.springframework.context.ApplicationContext parent, java.lang.Class<?>... classes)
Method Detail |
---|
protected void invokeBeanFactoryPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
invokeBeanFactoryPostProcessors
in class org.springframework.context.support.AbstractApplicationContext
protected void finishRefresh()
finishRefresh
in class org.springframework.context.support.AbstractApplicationContext
protected void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory) throws java.io.IOException, org.springframework.beans.BeansException
@Configuration
classes
as bean definitions within this context's BeanFactory for later processing
by.ConfigurationPostProcessor
loadBeanDefinitions
in class org.springframework.context.support.AbstractRefreshableApplicationContext
java.io.IOException
org.springframework.beans.BeansException
JavaConfigApplicationContext(Class...)
,
addConfigClass(Class)
public void setParent(org.springframework.context.ApplicationContext parent)
setParent
in interface org.springframework.context.ConfigurableApplicationContext
setParent
in class org.springframework.context.support.AbstractApplicationContext
public void setBeanNamingStrategy(BeanNamingStrategy namingStrategy)
public BeanNamingStrategy getBeanNamingStrategy()
public void addBasePackage(java.lang.String basePackage)
ConfigurableJavaConfigApplicationContext
Configuration
class
definitions within, but it is not considered an error if none are found.
This method may only be called on a context still 'open for configuration' meaning
that the user will need to manually call refresh() after all base packages have been
added.
addBasePackage
in interface ConfigurableJavaConfigApplicationContext
basePackage
- a package to scan (recursively) for any classes annotated with
Configuration
public void addConfigClass(java.lang.Class<?> cls)
ConfigurableJavaConfigApplicationContext
addConfigClass
in interface ConfigurableJavaConfigApplicationContext
cls
- a class annotated with Configuration
public <T> T getBean(java.lang.Class<T> type)
org.springframework.config.java.internal.factory.TypeSafeBeanFactory
Primary
getBean
in interface org.springframework.config.java.internal.factory.TypeSafeBeanFactory
type
- desired instance type
Primary
public <T> T getBean(java.lang.Class<T> type, java.lang.String beanName)
org.springframework.config.java.internal.factory.TypeSafeBeanFactory
Primary
This method is similar to its predecessor BeanFactory.getBean(String, Class)
, but
this variant takes advantages of generics and removes the casting burden from the caller.
getBean
in interface org.springframework.config.java.internal.factory.TypeSafeBeanFactory
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |