org.springframework.beans.factory.config
Interface InstantiationAwareBeanPostProcessor

All Superinterfaces:
BeanPostProcessor
All Known Implementing Classes:
AbstractAdvisorAutoProxyCreator, AbstractAutoProxyCreator, BeanNameAutoProxyCreator, DefaultAdvisorAutoProxyCreator

public interface InstantiationAwareBeanPostProcessor
extends BeanPostProcessor

Subinterface of BeanPostProcessor that adds a before-instantiation callback.

Typically used to suppress default instantiation for specific target beans, for example to create proxies with special TargetSources (pooling targets, lazily initializing targets, etc).

Since:
1.2
Author:
Juergen Hoeller
See Also:
AbstractAutoProxyCreator.setCustomTargetSourceCreators(org.springframework.aop.framework.autoproxy.TargetSourceCreator[]), AbstractPoolingTargetSourceCreator, LazyInitTargetSourceCreator

Method Summary
 Object postProcessBeforeInstantiation(Class beanClass, String beanName)
          Apply this BeanPostProcessor before the target bean gets instantiated.
 
Methods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor
postProcessAfterInitialization, postProcessBeforeInitialization
 

Method Detail

postProcessBeforeInstantiation

Object postProcessBeforeInstantiation(Class beanClass,
                                      String beanName)
                                      throws BeansException
Apply this BeanPostProcessor before the target bean gets instantiated. The returned bean object may be a proxy to use instead of the target bean, effectively suppressing default instantiation of the target bean.

If a non-null object is returned by this method, the bean creation process will be short-circuited. The returned bean object will not be processed any further; in particular, no further BeanPostProcessor callbacks will be applied to it. This mechanism is mainly intended for exposing a proxy instead of an actual target bean.

This callback will only be applied to bean definitions with a bean class. In particular, it will not be applied to beans with a "factory-method".

Parameters:
beanClass - the class of the bean to be instantiated
beanName - the name of the bean
Returns:
the bean object to expose instead of a default instance of the target bean
Throws:
BeansException - in case of errors
See Also:
AbstractBeanDefinition.hasBeanClass(), AbstractBeanDefinition.getFactoryMethodName()


Copyright (c) 2002-2005 The Spring Framework Project.