public abstract class

InstantiationAwareBeanPostProcessorAdapter

extends Object
implements SmartInstantiationAwareBeanPostProcessor
java.lang.Object
   ↳ org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
Known Direct Subclasses

Class Overview

Adapter that implements all methods on SmartInstantiationAwareBeanPostProcessor as no-ops, which will not change normal processing of each bean instantiated by the container. Subclasses may override merely those methods that they are actually interested in.

Note that this base class is only recommendable if you actually require InstantiationAwareBeanPostProcessor functionality. If all you need is plain BeanPostProcessor functionality, prefer a straight implementation of that (simpler) interface.

Summary

Public Constructors
InstantiationAwareBeanPostProcessorAdapter()
Public Methods
Constructor[]<?> determineCandidateConstructors(Class beanClass, String beanName)
Object getEarlyBeanReference(Object bean, String beanName)
Obtain a reference for early access to the specified bean, typically for the purpose of resolving a circular reference.
Object postProcessAfterInitialization(Object bean, String beanName)
Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method).
boolean postProcessAfterInstantiation(Object bean, String beanName)
Perform operations after the bean has been instantiated, via a constructor or factory method, but before Spring property population (from explicit properties or autowiring) occurs.
Object postProcessBeforeInitialization(Object bean, String beanName)
Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method).
Object postProcessBeforeInstantiation(Class beanClass, String beanName)
PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)
Post-process the given property values before the factory applies them to the given bean.
Class<?> predictBeanType(Class<?> beanClass, String beanName)
Predict the type of the bean to be eventually returned from this processor's postProcessBeforeInstantiation(Class, String) callback.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.beans.factory.config.BeanPostProcessor
From interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
From interface org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor

Public Constructors

public InstantiationAwareBeanPostProcessorAdapter ()

Also: SpringBeans

Public Methods

public Constructor[]<?> determineCandidateConstructors (Class beanClass, String beanName)

Also: SpringBeans

public Object getEarlyBeanReference (Object bean, String beanName)

Also: SpringBeans

Obtain a reference for early access to the specified bean, typically for the purpose of resolving a circular reference.

This callback gives post-processors a chance to expose a wrapper early - that is, before the target bean instance is fully initialized. The exposed object should be equivalent to the what postProcessBeforeInitialization(Object, String) / postProcessAfterInitialization(Object, String) would expose otherwise. Note that the object returned by this method will be used as bean reference unless the post-processor returns a different wrapper from said post-process callbacks. In other words: Those post-process callbacks may either eventually expose the same reference or alternatively return the raw bean instance from those subsequent callbacks (if the wrapper for the affected bean has been built for a call to this method already, it will be exposes as final bean reference by default).

Parameters
bean the raw bean instance
beanName the name of the bean
Returns
  • the object to expose as bean reference (typically with the passed-in bean instance as default)

public Object postProcessAfterInitialization (Object bean, String beanName)

Also: SpringBeans

Apply this BeanPostProcessor to the given new bean instance after any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

In case of a FactoryBean, this callback will be invoked for both the FactoryBean instance and the objects created by the FactoryBean (as of Spring 2.0). The post-processor can decide whether to apply to either the FactoryBean or created objects or both through corresponding bean instanceof FactoryBean checks.

This callback will also be invoked after a short-circuiting triggered by a postProcessBeforeInstantiation(Class, String) method, in contrast to all other BeanPostProcessor callbacks.

Parameters
bean the new bean instance
beanName the name of the bean
Returns
  • the bean instance to use, either the original or a wrapped one; if null, no subsequent BeanPostProcessors will be invoked

public boolean postProcessAfterInstantiation (Object bean, String beanName)

Also: SpringBeans

Perform operations after the bean has been instantiated, via a constructor or factory method, but before Spring property population (from explicit properties or autowiring) occurs.

This is the ideal callback for performing field injection on the given bean instance. See Spring's own AutowiredAnnotationBeanPostProcessor for a typical example.

Parameters
bean the bean instance created, with properties not having been set yet
beanName the name of the bean
Returns
  • true if properties should be set on the bean; false if property population should be skipped. Normal implementations should return true. Returning false will also prevent any subsequent InstantiationAwareBeanPostProcessor instances being invoked on this bean instance.

public Object postProcessBeforeInitialization (Object bean, String beanName)

Also: SpringBeans

Apply this BeanPostProcessor to the given new bean instance before any bean initialization callbacks (like InitializingBean's afterPropertiesSet or a custom init-method). The bean will already be populated with property values. The returned bean instance may be a wrapper around the original.

Parameters
bean the new bean instance
beanName the name of the bean
Returns
  • the bean instance to use, either the original or a wrapped one; if null, no subsequent BeanPostProcessors will be invoked

public Object postProcessBeforeInstantiation (Class beanClass, String beanName)

Also: SpringBeans

public PropertyValues postProcessPropertyValues (PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)

Also: SpringBeans

Post-process the given property values before the factory applies them to the given bean. Allows for checking whether all dependencies have been satisfied, for example based on a "Required" annotation on bean property setters.

Also allows for replacing the property values to apply, typically through creating a new MutablePropertyValues instance based on the original PropertyValues, adding or removing specific values.

Parameters
pvs the property values that the factory is about to apply (never null)
pds the relevant property descriptors for the target bean (with ignored dependency types - which the factory handles specifically - already filtered out)
bean the bean instance created, but whose properties have not yet been set
beanName the name of the bean
Returns
  • the actual property values to apply to to the given bean (can be the passed-in PropertyValues instance), or null to skip property population

public Class<?> predictBeanType (Class<?> beanClass, String beanName)

Also: SpringBeans

Predict the type of the bean to be eventually returned from this processor's postProcessBeforeInstantiation(Class, String) callback.

Parameters
beanClass the raw class of the bean
beanName the name of the bean
Returns
  • the type of the bean, or null if not predictable