Class LifecycleBeanPostProcessor
java.lang.Object
org.apache.shiro.spring.LifecycleBeanPostProcessor
- All Implemented Interfaces:
BeanPostProcessor,DestructionAwareBeanPostProcessor,Ordered,PriorityOrdered
public class LifecycleBeanPostProcessor
extends Object
implements DestructionAwareBeanPostProcessor, PriorityOrdered
Bean post processor for Spring that automatically calls the init() and/or
destroy() methods on Shiro objects that implement the Initializable
or Destroyable interfaces, respectfully. This post processor makes it easier
to configure Shiro beans in Spring, since the user never has to worry about whether or not if they
have to specify init-method and destroy-method bean attributes.
Warning: This post processor has no way to determine if init() or destroy() have already been called, so if you define this post processor in your applicationContext, do not also call these methods manually or via Spring's init-method or destroy-method bean attributes.
- Since:
- 0.2
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionDefault Constructor.LifecycleBeanPostProcessor(int order) Constructor with definableorder value. -
Method Summary
Modifier and TypeMethodDescriptionintgetOrder()Order value of this BeanPostProcessor.postProcessAfterInitialization(Object object, String name) Does nothing - merely returns the object argument immediately.voidpostProcessBeforeDestruction(Object object, String name) Calls the destroy() methods on the bean if it implementsDestroyablepostProcessBeforeInitialization(Object object, String name) Calls the init() methods on the bean if it implementsInitializablebooleanrequiresDestruction(Object bean) Return true only ifbeanimplements Destroyable.
-
Constructor Details
-
LifecycleBeanPostProcessor
public LifecycleBeanPostProcessor()Default Constructor. -
LifecycleBeanPostProcessor
Constructor with definableorder value.- Parameters:
order- order value of this BeanPostProcessor.
-
-
Method Details
-
postProcessBeforeInitialization
Calls the init() methods on the bean if it implementsInitializable- Specified by:
postProcessBeforeInitializationin interfaceBeanPostProcessor- Parameters:
object- the object being initialized.name- the name of the bean being initialized.- Returns:
- the initialized bean.
- Throws:
BeansException- if any exception is thrown during initialization.
-
postProcessAfterInitialization
Does nothing - merely returns the object argument immediately.- Specified by:
postProcessAfterInitializationin interfaceBeanPostProcessor- Throws:
BeansException
-
postProcessBeforeDestruction
Calls the destroy() methods on the bean if it implementsDestroyable- Specified by:
postProcessBeforeDestructionin interfaceDestructionAwareBeanPostProcessor- Parameters:
object- the object being initialized.name- the name of the bean being initialized.- Throws:
BeansException- if any exception is thrown during initialization.
-
getOrder
-
requiresDestruction
Return true only ifbeanimplements Destroyable.- Specified by:
requiresDestructionin interfaceDestructionAwareBeanPostProcessor- Parameters:
bean- bean to check if requires destruction.- Returns:
- true only if
beanimplements Destroyable. - Since:
- 1.4
-