org.springframework.config.java.context
Class AnnotationApplicationContext

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
                  extended by org.springframework.config.java.context.AnnotationApplicationContext
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

public class AnnotationApplicationContext
extends AbstractAnnotationApplicationContext

Annotation-aware application context. This class extends AbstractAnnotationApplicationContext and adds support for reading an application context definition/metadata directly from a class.

Author:
Costin Leau

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
AnnotationApplicationContext()
          Create a new AnnotationApplicationContext w/o any settings.
AnnotationApplicationContext(org.springframework.context.ApplicationContext parent)
          Create a new AnnotationApplicationContext with the given parent.
AnnotationApplicationContext(java.lang.Class... classes)
          Create a new AnnotationApplicationContext from the given classes (AbstractApplicationContext.refresh() is being called).
AnnotationApplicationContext(java.lang.String... locations)
          Create a new AnnotationApplicationContext from the given locations (AbstractApplicationContext.refresh() is being called).
 
Method Summary
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.
 void setConfigClasses(java.lang.Class... classes)
          Indicate the Classes that hold annotations suitable for configuring the current application context.
 void setConfigLocations(java.lang.String... locations)
          Set the configuration locations from Strings.
 void setConfigResources(org.springframework.core.io.Resource... resources)
          Indicate the configuration locations as Resources.
 
Methods inherited from class org.springframework.config.java.context.AbstractAnnotationApplicationContext
containsConfiguration, createAnnotationBeanDefinitionReader, loadBeanDefinitions, loadBeanDefinitions, loadBeanDefinitions, registerDefaultPostProcessors
 
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

AnnotationApplicationContext

public AnnotationApplicationContext()
Create a new AnnotationApplicationContext w/o any settings.

See Also:
DefaultResourceLoader.setClassLoader(ClassLoader), setConfigClasses(Class[]), setConfigLocations(String[]), setConfigResources(Resource[])

AnnotationApplicationContext

public AnnotationApplicationContext(org.springframework.context.ApplicationContext parent)
Create a new AnnotationApplicationContext with the given parent. The instance can be further configured before calling AbstractApplicationContext.refresh().

Parameters:
parent - the parent application context
See Also:
DefaultResourceLoader.setClassLoader(ClassLoader), setConfigClasses(Class[]), setConfigLocations(String[]), setConfigResources(Resource[])

AnnotationApplicationContext

public AnnotationApplicationContext(java.lang.String... locations)
Create a new AnnotationApplicationContext from the given locations (AbstractApplicationContext.refresh() is being called).

Parameters:
locations - the metadata locations

AnnotationApplicationContext

public AnnotationApplicationContext(java.lang.Class... classes)
Create a new AnnotationApplicationContext from the given classes (AbstractApplicationContext.refresh() is being called).

Parameters:
classes -
Method Detail

getConfigLocations

protected java.lang.String[] getConfigLocations()
Description copied from class: AbstractAnnotationApplicationContext
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.

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

getConfigResources

protected org.springframework.core.io.Resource[] getConfigResources()
Description copied from class: AbstractAnnotationApplicationContext
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.

Overrides:
getConfigResources in class AbstractAnnotationApplicationContext
Returns:
an array of Resource objects, or null if none
See Also:
AbstractAnnotationApplicationContext.getConfigLocations()

getConfigClasses

protected java.lang.Class[] getConfigClasses()
Description copied from class: AbstractAnnotationApplicationContext
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).

Overrides:
getConfigClasses in class AbstractAnnotationApplicationContext
Returns:
an array of Class objects, or null if none
See Also:
AbstractAnnotationApplicationContext.getConfigLocations()

setConfigLocations

public void setConfigLocations(java.lang.String... locations)
Set the configuration locations from Strings. These will be converted into Spring's Resource using the current $ResourceLoader.

Parameters:
locations -

setConfigResources

public void setConfigResources(org.springframework.core.io.Resource... resources)
Indicate the configuration locations as Resources.

Parameters:
resources -

setConfigClasses

public void setConfigClasses(java.lang.Class... classes)
Indicate the Classes that hold annotations suitable for configuring the current application context.

Parameters:
classes -


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