org.springframework.context.support
Class StaticApplicationContext

java.lang.Object
  extended byorg.springframework.core.io.DefaultResourceLoader
      extended byorg.springframework.context.support.AbstractApplicationContext
          extended byorg.springframework.context.support.StaticApplicationContext
All Implemented Interfaces:
ApplicationContext, BeanFactory, ConfigurableApplicationContext, HierarchicalBeanFactory, ListableBeanFactory, MessageSource, ResourceLoader
Direct Known Subclasses:
StaticWebApplicationContext

public class StaticApplicationContext
extends AbstractApplicationContext

ApplicationContext that allows concrete registration of beans and messages in code, rather than from external configuration sources. Mainly useful for testing.

Author:
Rod Johnson

Field Summary
 
Fields inherited from class org.springframework.context.support.AbstractApplicationContext
logger, MESSAGE_SOURCE_BEAN_NAME
 
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
 
Constructor Summary
StaticApplicationContext()
          Create new StaticApplicationContext.
StaticApplicationContext(ApplicationContext parent)
          Create new StaticApplicationContext with the given parent.
 
Method Summary
 void addMessage(java.lang.String code, java.util.Locale locale, java.lang.String defaultMessage)
          Associate the given message with the given code.
 ConfigurableListableBeanFactory getBeanFactory()
          Return underlying bean factory for super class.
 DefaultListableBeanFactory getDefaultListableBeanFactory()
          Return the underlying bean factory of this context.
protected  void refreshBeanFactory()
          Do nothing: We rely on callers to update our public methods.
 void registerPrototype(java.lang.String name, java.lang.Class clazz, MutablePropertyValues pvs)
          Register a prototype bean with the default bean factory.
 void registerSingleton(java.lang.String name, java.lang.Class clazz, MutablePropertyValues pvs)
          Register a singleton bean with the default bean factory.
 
Methods inherited from class org.springframework.context.support.AbstractApplicationContext
addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, getAliases, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeansOfType, getDisplayName, getInternalParentBeanFactory, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, isSingleton, onRefresh, postProcessBeanFactory, publishEvent, refresh, setDisplayName, setParent, toString
 
Methods inherited from class org.springframework.core.io.DefaultResourceLoader
getResource, getResourceByPath
 
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
getResource
 

Constructor Detail

StaticApplicationContext

public StaticApplicationContext()
                         throws BeansException
Create new StaticApplicationContext.


StaticApplicationContext

public StaticApplicationContext(ApplicationContext parent)
                         throws BeansException
Create new StaticApplicationContext with the given parent.

Parameters:
parent - the parent application context
Method Detail

getDefaultListableBeanFactory

public DefaultListableBeanFactory getDefaultListableBeanFactory()
Return the underlying bean factory of this context.


getBeanFactory

public ConfigurableListableBeanFactory getBeanFactory()
Return underlying bean factory for super class.

Specified by:
getBeanFactory in interface ConfigurableApplicationContext
Specified by:
getBeanFactory in class AbstractApplicationContext
Returns:
this application context's internal bean factory

refreshBeanFactory

protected void refreshBeanFactory()
Do nothing: We rely on callers to update our public methods.

Specified by:
refreshBeanFactory in class AbstractApplicationContext
See Also:
AbstractApplicationContext.refresh()

registerSingleton

public void registerSingleton(java.lang.String name,
                              java.lang.Class clazz,
                              MutablePropertyValues pvs)
                       throws BeansException
Register a singleton bean with the default bean factory.

Throws:
BeansException

registerPrototype

public void registerPrototype(java.lang.String name,
                              java.lang.Class clazz,
                              MutablePropertyValues pvs)
                       throws BeansException
Register a prototype bean with the default bean factory.

Throws:
BeansException

addMessage

public void addMessage(java.lang.String code,
                       java.util.Locale locale,
                       java.lang.String defaultMessage)
Associate the given message with the given code.

Parameters:
code - lookup code
locale - locale message should be found within
defaultMessage - message associated with this lookup code


Copyright (C) 2003-2004 The Spring Framework Project.