org.springframework.config.java.context
Class JavaConfigWebApplicationContext

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.web.context.support.AbstractRefreshableWebApplicationContext
                  extended by org.springframework.config.java.context.JavaConfigWebApplicationContext
All Implemented Interfaces:
BeanFactory, DisposableBean, HierarchicalBeanFactory, ListableBeanFactory, ApplicationContext, ApplicationEventPublisher, ConfigurableApplicationContext, Lifecycle, MessageSource, ResourceLoader, ResourcePatternResolver, ThemeSource, ConfigurableWebApplicationContext, WebApplicationContext

public class JavaConfigWebApplicationContext
extends AbstractRefreshableWebApplicationContext

JavaConfig ApplicationContext implementation for use in the web tier. May be supplied as the commandClass parameter to Spring MVC's DispatcherServlet

Author:
Chris Beams
See Also:
JavaConfigApplicationContext, WebApplicationContext, DispatcherServlet

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.web.context.ConfigurableWebApplicationContext
CONFIG_LOCATION_DELIMITERS
 
Fields inherited from interface org.springframework.web.context.WebApplicationContext
ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, SCOPE_GLOBAL_SESSION, SCOPE_REQUEST, SCOPE_SESSION
 
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
 
Fields inherited from interface org.springframework.context.ConfigurableApplicationContext
LOAD_TIME_WEAVER_BEAN_NAME
 
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
JavaConfigWebApplicationContext()
           
 
Method Summary
<T> T
getBean(Class<T> type)
          Return an instance of the given type.
<T> T
getBean(Class<T> type, String beanName)
          Return an instance named beanName and of type type.
protected  void initConfigLocations()
           
protected  void loadBeanDefinitions(DefaultListableBeanFactory beanFactory)
          Processes contents of configLocations, setting the values of configClasses and basePackages appropriately.
protected  void prepareRefresh()
           
protected  void registerDefaultPostProcessors()
          Register the default post processors used for parsing Spring classes.
 
Methods inherited from class org.springframework.web.context.support.AbstractRefreshableWebApplicationContext
getConfigLocations, getDefaultConfigLocations, getNamespace, getResourceByPath, getResourcePatternResolver, getServletConfig, getServletContext, getTheme, onRefresh, postProcessBeanFactory, resolvePath, setConfigLocations, setNamespace, setServletConfig, setServletContext
 
Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext
closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, refreshBeanFactory
 
Methods inherited from class org.springframework.context.support.AbstractApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, addListener, cancelRefresh, close, containsBean, containsBeanDefinition, containsLocalBean, destroy, destroyBeans, doClose, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getDisplayName, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResources, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleDependentBeans, initMessageSource, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, prepareBeanFactory, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setParent, start, stop, toString
 
Methods inherited from class org.springframework.core.io.DefaultResourceLoader
getClassLoader, getResource, setClassLoader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
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.ApplicationContext
getAutowireCapableBeanFactory, getDisplayName, 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.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.ConfigurableApplicationContext
addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, isActive, refresh, registerShutdownHook, setParent
 
Methods inherited from interface org.springframework.context.ApplicationContext
getAutowireCapableBeanFactory, getDisplayName, 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.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

JavaConfigWebApplicationContext

public JavaConfigWebApplicationContext()
Method Detail

prepareRefresh

protected void prepareRefresh()
Overrides:
prepareRefresh in class AbstractApplicationContext

initConfigLocations

protected void initConfigLocations()

loadBeanDefinitions

protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory)
                            throws IOException
Processes contents of configLocations, setting the values of configClasses and basePackages appropriately.

Specified by:
loadBeanDefinitions in class AbstractRefreshableApplicationContext
Throws:
IllegalArgumentException - if the configLocations array is null, contains any null elements, or contains names of any classes that cannot be found
IOException

registerDefaultPostProcessors

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

See Also:
JavaConfigBeanFactoryPostProcessorRegistry

getBean

public <T> T getBean(Class<T> type)
Return an instance of the given type. If multiple instances of the same type exist, instances are inspected to see if exactly one is marked as Primary

Parameters:
type - desired instance type
Returns:
instance matching type
See Also:
Primary

getBean

public <T> T getBean(Class<T> type,
                     String beanName)
Return an instance named beanName and of type type. Useful in disambiguation cases where there is more than one bean of a given type within the factory and none is marked as 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.



Copyright 2005-2008 Spring Framework. All Rights Reserved.