org.springframework.config.java.context
Class AbstractAnnotationApplicationContext

java.lang.Object
  extended by org.springframework.core.io.DefaultResourceLoader
      extended by org.springframework.context.support.AbstractApplicationContext
          extended by org.springframework.context.support.AbstractRefreshableApplicationContext
              extended by org.springframework.config.java.context.AbstractAnnotationApplicationContext
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.context.ApplicationContext, org.springframework.context.ApplicationEventPublisher, org.springframework.context.ConfigurableApplicationContext, org.springframework.context.Lifecycle, org.springframework.context.MessageSource, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver
Direct Known Subclasses:
AnnotationApplicationContext

public abstract class AbstractAnnotationApplicationContext
extends org.springframework.context.support.AbstractRefreshableApplicationContext

Convenient superclass for ApplicationContext implementations that read bean definitions from class bytecode.

This class registers each bean definition with the DefaultListableBeanFactory superclass, and relies on the latter's implementation of the BeanFactory interface. It supports singletons, prototypes, and references to both kinds of bean.

Author:
Costin Leau
See Also:
DefaultListableBeanFactory

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.beans.factory.BeanFactory
FACTORY_BEAN_PREFIX
 
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
AbstractAnnotationApplicationContext()
           
AbstractAnnotationApplicationContext(org.springframework.context.ApplicationContext parent)
           
 
Method Summary
protected  boolean containsConfiguration(java.lang.Class<?> clazz)
          Discriminator between configuration and non-configuration classes.
protected  AbstractClassScanningBeanDefinitionReader createAnnotationBeanDefinitionReader(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
           
protected  java.lang.Class[] getConfigClasses()
          Return an array of Class objects which act as definition files for a spring context.
protected  java.lang.String[] getConfigLocations()
          Return an array of resource locations, referring to the class bean definition files that this context should be built with.
protected  org.springframework.core.io.Resource[] getConfigResources()
          Return an array of Resource objects, referring to the class bean definition files that this context should be built with.
protected  void loadBeanDefinitions(AbstractClassScanningBeanDefinitionReader reader)
          Load bean definitions with the given AbstractAnnotationBeanDefinitionReader.
protected  void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
           
protected  int loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory, java.lang.Class... configClasses)
          Load bean definitions from configuration classes.
protected  void registerDefaultPostProcessors()
          Register the default post processors used for parsing Spring classes.
 
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext
closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, refreshBeanFactory
 
Methods inherited from class org.springframework.context.support.AbstractApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, destroyBeans, doClose, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getInternalParentBeanFactory, getInternalParentMessageSource, getLifecycleBeans, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getResources, getStartupDate, getType, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, onClose, onRefresh, postProcessBeanFactory, publishEvent, refresh, registerShutdownHook, setDisplayName, setParent, 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.core.io.ResourceLoader
getClassLoader, getResource
 

Constructor Detail

AbstractAnnotationApplicationContext

public AbstractAnnotationApplicationContext()

AbstractAnnotationApplicationContext

public AbstractAnnotationApplicationContext(org.springframework.context.ApplicationContext parent)
Method Detail

registerDefaultPostProcessors

protected void registerDefaultPostProcessors()
Register the default post processors used for parsing Spring classes.


loadBeanDefinitions

protected void loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)
                            throws java.io.IOException,
                                   org.springframework.beans.BeansException
Specified by:
loadBeanDefinitions in class org.springframework.context.support.AbstractRefreshableApplicationContext
Throws:
java.io.IOException
org.springframework.beans.BeansException

createAnnotationBeanDefinitionReader

protected AbstractClassScanningBeanDefinitionReader createAnnotationBeanDefinitionReader(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory)

loadBeanDefinitions

protected void loadBeanDefinitions(AbstractClassScanningBeanDefinitionReader reader)
                            throws org.springframework.beans.BeansException,
                                   java.io.IOException
Load bean definitions with the given AbstractAnnotationBeanDefinitionReader.

The lifecycle of the bean factory is handled by the refreshBeanFactory method; therefore this method is just supposed to load and/or register bean definitions.

Delegates to a ResourcePatternResolver for resolving location patterns into Resource instances.

Throws:
org.springframework.beans.BeansException - in case of bean registration errors
java.io.IOException - if the required class definition isn't found
See Also:
AbstractRefreshableApplicationContext.refreshBeanFactory(), getConfigLocations(), AbstractApplicationContext.getResources(java.lang.String), AbstractApplicationContext.getResourcePatternResolver()

loadBeanDefinitions

protected int loadBeanDefinitions(org.springframework.beans.factory.support.DefaultListableBeanFactory beanFactory,
                                  java.lang.Class... configClasses)
Load bean definitions from configuration classes.

Since Class objects cannot be easily translated into a byte array or InputStream, they have be parsed separately.

Parameters:
configClasses -

containsConfiguration

protected boolean containsConfiguration(java.lang.Class<?> clazz)
Discriminator between configuration and non-configuration classes.

Parameters:
clazz -
Returns:

getConfigResources

protected org.springframework.core.io.Resource[] getConfigResources()
Return an array of Resource objects, referring to the class bean definition files that this context should be built with.

Default implementation returns null. Subclasses can override this to provide pre-built Resource objects rather than location Strings.

Returns:
an array of Resource objects, or null if none
See Also:
getConfigLocations()

getConfigLocations

protected java.lang.String[] getConfigLocations()
Return an array of resource locations, referring to the class bean definition files that this context should be built with. Can also include location patterns, which will get resolved via a ResourcePatternResolver.

Default implementation returns null. Subclasses can override this to provide a set of resource locations to load bean definitions from.

Returns:
an array of resource locations, or null if none
See Also:
AbstractApplicationContext.getResources(java.lang.String), AbstractApplicationContext.getResourcePatternResolver()

getConfigClasses

protected java.lang.Class[] getConfigClasses()
Return an array of Class objects which act as definition files for a spring context.

Default implementation returns null. Subclasses can override this to provide pre-built Class objects rather than location Strings or Resources. This class should be mainly use when runtime generating classes are used (runtime compiled Groovy scripts or ASM 'synthetic' classes).

Returns:
an array of Class objects, or null if none
See Also:
getConfigLocations()


Copyright © 2005-2007 Spring Framework. All Rights Reserved.