org.apache.shiro.spring
Class LifecycleBeanPostProcessor

java.lang.Object
  extended by org.apache.shiro.spring.LifecycleBeanPostProcessor
All Implemented Interfaces:
BeanPostProcessor, DestructionAwareBeanPostProcessor

public class LifecycleBeanPostProcessor
extends Object
implements DestructionAwareBeanPostProcessor

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
Author:
Jeremy Haile

Constructor Summary
LifecycleBeanPostProcessor()
           
 
Method Summary
 Object postProcessAfterInitialization(Object object, String name)
          Does nothing - merely returns the object argument immediately.
 void postProcessBeforeDestruction(Object object, String name)
          Calls the destroy() methods on the bean if it implements Destroyable
 Object postProcessBeforeInitialization(Object object, String name)
          Calls the init() methods on the bean if it implements Initializable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LifecycleBeanPostProcessor

public LifecycleBeanPostProcessor()
Method Detail

postProcessBeforeInitialization

public Object postProcessBeforeInitialization(Object object,
                                              String name)
                                       throws BeansException
Calls the init() methods on the bean if it implements Initializable

Specified by:
postProcessBeforeInitialization in interface BeanPostProcessor
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

public Object postProcessAfterInitialization(Object object,
                                             String name)
                                      throws BeansException
Does nothing - merely returns the object argument immediately.

Specified by:
postProcessAfterInitialization in interface BeanPostProcessor
Throws:
BeansException

postProcessBeforeDestruction

public void postProcessBeforeDestruction(Object object,
                                         String name)
                                  throws BeansException
Calls the destroy() methods on the bean if it implements Destroyable

Specified by:
postProcessBeforeDestruction in interface DestructionAwareBeanPostProcessor
Parameters:
object - the object being initialized.
name - the name of the bean being initialized.
Throws:
BeansException - if any exception is thrown during initialization.


Copyright © 2004-2010 The Apache Software Foundation. All Rights Reserved.