Class LifecycleBeanPostProcessor

java.lang.Object
org.apache.shiro.spring.LifecycleBeanPostProcessor
All Implemented Interfaces:
org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.core.Ordered, org.springframework.core.PriorityOrdered

public class LifecycleBeanPostProcessor extends Object implements org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.core.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
  • Constructor Details

    • LifecycleBeanPostProcessor

      public LifecycleBeanPostProcessor()
      Default Constructor.
    • LifecycleBeanPostProcessor

      public LifecycleBeanPostProcessor(int order)
      Constructor with definable order value.
      Parameters:
      order - order value of this BeanPostProcessor.
  • Method Details

    • postProcessBeforeInitialization

      public Object postProcessBeforeInitialization(Object object, String name) throws org.springframework.beans.BeansException
      Calls the init() methods on the bean if it implements Initializable
      Specified by:
      postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
      Parameters:
      object - the object being initialized.
      name - the name of the bean being initialized.
      Returns:
      the initialized bean.
      Throws:
      org.springframework.beans.BeansException - if any exception is thrown during initialization.
    • postProcessAfterInitialization

      public Object postProcessAfterInitialization(Object object, String name) throws org.springframework.beans.BeansException
      Does nothing - merely returns the object argument immediately.
      Specified by:
      postProcessAfterInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • postProcessBeforeDestruction

      public void postProcessBeforeDestruction(Object object, String name) throws org.springframework.beans.BeansException
      Calls the destroy() methods on the bean if it implements Destroyable
      Specified by:
      postProcessBeforeDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
      Parameters:
      object - the object being initialized.
      name - the name of the bean being initialized.
      Throws:
      org.springframework.beans.BeansException - if any exception is thrown during initialization.
    • getOrder

      public int getOrder()
      Order value of this BeanPostProcessor.
      Specified by:
      getOrder in interface org.springframework.core.Ordered
      Returns:
      order value.
    • requiresDestruction

      public boolean requiresDestruction(Object bean)
      Return true only if bean implements Destroyable.
      Specified by:
      requiresDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
      Parameters:
      bean - bean to check if requires destruction.
      Returns:
      true only if bean implements Destroyable.
      Since:
      1.4