org.springframework.context.access
Class ContextSingletonBeanFactoryLocator

java.lang.Object
  extended byorg.springframework.beans.factory.access.SingletonBeanFactoryLocator
      extended byorg.springframework.context.access.ContextSingletonBeanFactoryLocator
All Implemented Interfaces:
BeanFactoryLocator

public class ContextSingletonBeanFactoryLocator
extends SingletonBeanFactoryLocator

Variant of SingletonBeanFactoryLocator which creates its internal bean factory reference definition as an ApplicationContext instead of SingletonBeanFactoryLocator's BeanFactory. For almost all usage scenarios, this will not make a difference, since withing that ApplicationContext or BeanFactory you are still free to create either BeanFactories or ApplicationContexts. The main reason one would need to use this class is if BeanPostProcessing (or other ApplicationContext specific features are needed in the bean reference definition itself.

Note: This class uses beanRefContext.xml as the default name for the bean factory reference definition. It is not possible nor legal to share definitions with SingletonBeanFactoryLocator at the same time.

Version:
$Revision: 1.4 $, $Id: ContextSingletonBeanFactoryLocator.java,v 1.4 2004/03/18 02:46:13 trisberg Exp $
Author:
Colin Sampaleanu
See Also:
DefaultLocatorFactory

Field Summary
static java.lang.String BEANS_REFS_XML_NAME
           
 
Fields inherited from class org.springframework.beans.factory.access.SingletonBeanFactoryLocator
logger
 
Constructor Summary
protected ContextSingletonBeanFactoryLocator()
          Constructor which uses the default "bean-refs.xml", as the name of the definition file(s).
protected ContextSingletonBeanFactoryLocator(java.lang.String resourceName)
          Constructor which uses the the specified name as the name of the definition file(s).
 
Method Summary
protected  BeanFactory createDefinition(java.lang.String[] resources)
          Overrides default method to create definition object as an ApplicationContext instead of the default BeanFactory.
protected  void destroyDefinition(BeanFactory groupDef, java.lang.String resourceName)
          Overrides default method to work with ApplicationContext
static BeanFactoryLocator getInstance()
          Returns an instance which uses the default "beanRefContext.xml", as the name of the definition file(s).
static BeanFactoryLocator getInstance(java.lang.String selector)
          Returns an instance which uses the the specified selector, as the name of the definition file(s).
 
Methods inherited from class org.springframework.beans.factory.access.SingletonBeanFactoryLocator
getAllDefinitionResources, useBeanFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BEANS_REFS_XML_NAME

public static final java.lang.String BEANS_REFS_XML_NAME
See Also:
Constant Field Values
Constructor Detail

ContextSingletonBeanFactoryLocator

protected ContextSingletonBeanFactoryLocator()
Constructor which uses the default "bean-refs.xml", as the name of the definition file(s). All resources returned by the definition classloader's getResources() method with this name will be combined to create a definition.


ContextSingletonBeanFactoryLocator

protected ContextSingletonBeanFactoryLocator(java.lang.String resourceName)
Constructor which uses the the specified name as the name of the definition file(s). All resources returned by the definition classloader's getResources() method with this name will be combined to create a definition.

Method Detail

getInstance

public static BeanFactoryLocator getInstance()
                                      throws BeansException
Returns an instance which uses the default "beanRefContext.xml", as the name of the definition file(s). All resources returned by the current thread's context classloader's getResources() method with this name will be combined to create a definition, which is just a BeanFactory.

Throws:
BeansException

getInstance

public static BeanFactoryLocator getInstance(java.lang.String selector)
                                      throws BeansException
Returns an instance which uses the the specified selector, as the name of the definition file(s). All resources returned by the current thread's context classloader's getResources() method with this name will be combined to create a definition, which is just a a BeanFactory.

Parameters:
selector - the name of the resource(s) which will be read and combine to form the definition for the SingletonBeanFactoryLocator instance
Throws:
BeansException

createDefinition

protected BeanFactory createDefinition(java.lang.String[] resources)
                                throws BeansException
Overrides default method to create definition object as an ApplicationContext instead of the default BeanFactory. This does not affect what can actually be loaded by that definition.

Overrides:
createDefinition in class SingletonBeanFactoryLocator
Throws:
BeansException

destroyDefinition

protected void destroyDefinition(BeanFactory groupDef,
                                 java.lang.String resourceName)
                          throws BeansException
Overrides default method to work with ApplicationContext

Overrides:
destroyDefinition in class SingletonBeanFactoryLocator
Throws:
BeansException


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