org.springframework.context.access
public class: ContextBeanFactoryReference [javadoc |
source]
java.lang.Object
org.springframework.context.access.ContextBeanFactoryReference
All Implemented Interfaces:
BeanFactoryReference
ApplicationContext-specific implementation of BeanFactoryReference,
wrapping a newly created ApplicationContext, closing it on release.
As per BeanFactoryReference contract, release may be called
more than once, with subsequent calls not doing anything. However, calling
getFactory after a release call will cause an exception.
Also see:
- org.springframework.context.ConfigurableApplicationContext#close
- author:
Juergen - Hoeller
- author:
Colin - Sampaleanu
- since:
13.02.2004 -
| Method from org.springframework.context.access.ContextBeanFactoryReference Summary: |
|---|
|
getFactory, release |
| Method from org.springframework.context.access.ContextBeanFactoryReference Detail: |
public BeanFactory getFactory() {
if (this.applicationContext == null) {
throw new IllegalStateException(
"ApplicationContext owned by this BeanFactoryReference has been released");
}
return this.applicationContext;
}
|
public void release() {
if (this.applicationContext != null) {
ApplicationContext savedCtx;
// We don't actually guarantee thread-safety, but it's not a lot of extra work.
synchronized (this) {
savedCtx = this.applicationContext;
this.applicationContext = null;
}
if (savedCtx != null && savedCtx instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) savedCtx).close();
}
}
}
|