|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.beans.factory.support.DisposableBeanAdapter
class DisposableBeanAdapter
Adapter that implements the DisposableBean
and Runnable
interfaces
performing various destruction steps on a given bean instance:
AbstractBeanFactory
,
DisposableBean
,
DestructionAwareBeanPostProcessor
,
AbstractBeanDefinition.getDestroyMethodName()
Field Summary | |
---|---|
private java.security.AccessControlContext |
acc
|
private java.lang.Object |
bean
|
private java.lang.String |
beanName
|
private java.util.List<DestructionAwareBeanPostProcessor> |
beanPostProcessors
|
private java.lang.reflect.Method |
destroyMethod
|
private java.lang.String |
destroyMethodName
|
private boolean |
invokeDisposableBean
|
private static Log |
logger
|
private boolean |
nonPublicAccessAllowed
|
Constructor Summary | |
---|---|
private |
DisposableBeanAdapter(java.lang.Object bean,
java.lang.String beanName,
boolean invokeDisposableBean,
boolean nonPublicAccessAllowed,
java.lang.String destroyMethodName,
java.util.List<DestructionAwareBeanPostProcessor> postProcessors)
Create a new DisposableBeanAdapter for the given bean. |
|
DisposableBeanAdapter(java.lang.Object bean,
java.lang.String beanName,
RootBeanDefinition beanDefinition,
java.util.List<BeanPostProcessor> postProcessors,
java.security.AccessControlContext acc)
Create a new DisposableBeanAdapter for the given bean. |
Method Summary | |
---|---|
void |
destroy()
Invoked by a BeanFactory on destruction of a singleton. |
private java.lang.reflect.Method |
determineDestroyMethod()
|
private java.util.List<DestructionAwareBeanPostProcessor> |
filterPostProcessors(java.util.List<BeanPostProcessor> postProcessors)
Search for all DestructionAwareBeanPostProcessors in the List. |
private java.lang.reflect.Method |
findDestroyMethod()
|
private void |
inferDestroyMethodIfNecessary(RootBeanDefinition beanDefinition)
If the current value of the given beanDefinition's destroyMethodName property is AbstractBeanDefinition.INFER_METHOD , then attempt to infer a destroy method. |
private void |
invokeCustomDestroyMethod(java.lang.reflect.Method destroyMethod)
Invoke the specified custom destroy method on the given bean. |
void |
run()
|
protected java.lang.Object |
writeReplace()
Serializes a copy of the state of this class, filtering out non-serializable BeanPostProcessors. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Log logger
private final java.lang.Object bean
private final java.lang.String beanName
private final boolean invokeDisposableBean
private final boolean nonPublicAccessAllowed
private java.lang.String destroyMethodName
private transient java.lang.reflect.Method destroyMethod
private java.util.List<DestructionAwareBeanPostProcessor> beanPostProcessors
private final java.security.AccessControlContext acc
Constructor Detail |
---|
public DisposableBeanAdapter(java.lang.Object bean, java.lang.String beanName, RootBeanDefinition beanDefinition, java.util.List<BeanPostProcessor> postProcessors, java.security.AccessControlContext acc)
bean
- the bean instance (never null
)beanName
- the name of the beanbeanDefinition
- the merged bean definitionpostProcessors
- the List of BeanPostProcessors
(potentially DestructionAwareBeanPostProcessor), if anyprivate DisposableBeanAdapter(java.lang.Object bean, java.lang.String beanName, boolean invokeDisposableBean, boolean nonPublicAccessAllowed, java.lang.String destroyMethodName, java.util.List<DestructionAwareBeanPostProcessor> postProcessors)
Method Detail |
---|
private void inferDestroyMethodIfNecessary(RootBeanDefinition beanDefinition)
AbstractBeanDefinition.INFER_METHOD
, then attempt to infer a destroy method.
Candidate methods are currently limited to public, no-arg methods named 'close'
(whether declared locally or inherited). The given beanDefinition's
destroyMethodName is updated to be null if no such method is found, otherwise set
to the name of the inferred method. This constant serves as the default for the
@Bean#destroyMethod
attribute and the value of the constant may also be
used in XML within the <bean destroy-method="">
or <beans default-destroy-method="">
attributes.
private java.util.List<DestructionAwareBeanPostProcessor> filterPostProcessors(java.util.List<BeanPostProcessor> postProcessors)
postProcessors
- the List to search
public void run()
run
in interface java.lang.Runnable
public void destroy()
DisposableBean
destroy
in interface DisposableBean
private java.lang.reflect.Method determineDestroyMethod()
private java.lang.reflect.Method findDestroyMethod()
private void invokeCustomDestroyMethod(java.lang.reflect.Method destroyMethod)
This implementation invokes a no-arg method if found, else checking for a method with a single boolean argument (passing in "true", assuming a "force" parameter), else logging an error.
protected java.lang.Object writeReplace()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |