Class ContextBeanFactoryReference
- java.lang.Object
- org.springframework.context.access.ContextBeanFactoryReference
- All Implemented Interfaces:
BeanFactoryReference
public class ContextBeanFactoryReference extends Object implements BeanFactoryReference
ApplicationContext-specific implementation of BeanFactoryReference, wrapping a newly created ApplicationContext, closing it on release.As per BeanFactoryReference contract,
releasemay be called more than once, with subsequent calls not doing anything. However, callinggetFactoryafter areleasecall will cause an exception.- Since:
- 13.02.2004
- Author:
- Juergen Hoeller, Colin Sampaleanu
- See Also:
ConfigurableApplicationContext.close()
Constructor Summary
Constructors Constructor Description ContextBeanFactoryReference(ApplicationContext applicationContext)Create a new ContextBeanFactoryReference for the given context.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BeanFactorygetFactory()Return theBeanFactoryinstance held by this reference.voidrelease()Indicate that theBeanFactoryinstance referred to by this object is not needed any longer by the client code which obtained theBeanFactoryReference.
Constructor Detail
ContextBeanFactoryReference
public ContextBeanFactoryReference(ApplicationContext applicationContext)
Create a new ContextBeanFactoryReference for the given context.- Parameters:
applicationContext- the ApplicationContext to wrap
Method Detail
getFactory
public BeanFactory getFactory()
Description copied from interface:BeanFactoryReferenceReturn theBeanFactoryinstance held by this reference.- Specified by:
getFactoryin interfaceBeanFactoryReference
release
public void release()
Description copied from interface:BeanFactoryReferenceIndicate that theBeanFactoryinstance referred to by this object is not needed any longer by the client code which obtained theBeanFactoryReference.Depending on the actual implementation of
BeanFactoryLocator, and the actual type ofBeanFactory, this may possibly not actually do anything; alternately in the case of a 'closeable'BeanFactoryor derived class (such asApplicationContext) may 'close' it, or may 'close' it once no more references remain.In an EJB usage scenario this would normally be called from
ejbRemove()andejbPassivate().This is safe to call multiple times.
- Specified by:
releasein interfaceBeanFactoryReference- See Also:
BeanFactoryLocator,ContextBeanFactoryReference,ConfigurableApplicationContext.close()