Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.beans.factory.config
Class InstantiationAwareBeanPostProcessorAdapter

    java.lang.Object
      org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter

All Implemented Interfaces:
  BeanPostProcessor, InstantiationAwareBeanPostProcessor, SmartInstantiationAwareBeanPostProcessor

Direct Known Subclasses:
  RequiredAnnotationBeanPostProcessor, ScriptFactoryPostProcessor

    public abstract class InstantiationAwareBeanPostProcessorAdapter

extends Object
implements SmartInstantiationAwareBeanPostProcessor

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.

Since:
  2.0
Author:
  Rod Johnson, Juergen Hoeller

Constructor Summary
`InstantiationAwareBeanPostProcessorAdapter()`

Method Summary
`Constructor` | `determineConstructor(Class beanClass, String beanName)` Determine the constructor to use for the given bean.
`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)` Apply this BeanPostProcessor before the target bean gets instantiated.
`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 `InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class, java.lang.String)` callback.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### InstantiationAwareBeanPostProcessorAdapter

    public InstantiationAwareBeanPostProcessorAdapter()

Method Detail

### predictBeanType

    public Class predictBeanType(Class beanClass,
                                 String beanName)

  Description copied from interface: `SmartInstantiationAwareBeanPostProcessor`
  Predict the type of the bean to be eventually returned from this processor's `InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class, java.lang.String)` callback.

  Specified by:
    `predictBeanType` in interface `SmartInstantiationAwareBeanPostProcessor`
  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

### determineConstructor

    public Constructor determineConstructor(Class beanClass,
                                            String beanName)
                                     throws BeansException

  Description copied from interface: `SmartInstantiationAwareBeanPostProcessor`
  Determine the constructor to use for the given bean.

  Specified by:
    `determineConstructor` in interface `SmartInstantiationAwareBeanPostProcessor`
  Parameters:
    `beanClass` - the raw class of the bean
    `beanName` - the name of the bean
  Returns:
    the constructor to use, or `null` if none specified
  Throws:
    `BeansException` - in case of errors

### postProcessBeforeInstantiation

    public Object postProcessBeforeInstantiation(Class beanClass,
                                                 String beanName)
                                          throws BeansException

  Description copied from interface: `InstantiationAwareBeanPostProcessor`
  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 only further processing applied is the `BeanPostProcessor.postProcessAfterInitialization(java.lang.Object, java.lang.String)` callback from the configured `BeanPostProcessors`.

  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".

  Post-processors may implement the extended `SmartInstantiationAwareBeanPostProcessor` interface in order to predict the type of the bean object that they are going to return here.

  Specified by:
    `postProcessBeforeInstantiation` in interface `InstantiationAwareBeanPostProcessor`
  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, or `null` to proceed with default instantiation
  Throws:
    `BeansException` - in case of errors
  See Also:
    `AbstractBeanDefinition.hasBeanClass()`, `AbstractBeanDefinition.getFactoryMethodName()`

### postProcessAfterInstantiation

    public boolean postProcessAfterInstantiation(Object bean,
                                                 String beanName)
                                          throws BeansException

  Description copied from interface: `InstantiationAwareBeanPostProcessor`
  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.

  Specified by:
    `postProcessAfterInstantiation` in interface `InstantiationAwareBeanPostProcessor`
  Parameters:
    `bean` - the bean instance created, but whose properties have not yet been set
    `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.
  Throws:
    `BeansException` - in case of errors

### postProcessPropertyValues

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

  Description copied from interface: `InstantiationAwareBeanPostProcessor`
  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.

  Specified by:
    `postProcessPropertyValues` in interface `InstantiationAwareBeanPostProcessor`
  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
  Throws:
    `BeansException` - in case of errors
  See Also:
    `MutablePropertyValues`

### postProcessBeforeInitialization

    public Object postProcessBeforeInitialization(Object bean,
                                                  String beanName)
                                           throws BeansException

  Description copied from interface: `BeanPostProcessor`
  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.

  Specified by:
    `postProcessBeforeInitialization` in interface `BeanPostProcessor`
  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
  Throws:
    `BeansException` - in case of errors
  See Also:
    `InitializingBean.afterPropertiesSet()`

### postProcessAfterInitialization

    public Object postProcessAfterInitialization(Object bean,
                                                 String beanName)
                                          throws BeansException

  Description copied from interface: `BeanPostProcessor`
  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 `InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation(java.lang.Class, java.lang.String)` method, in contrast to all other BeanPostProcessor callbacks.

  Specified by:
    `postProcessAfterInitialization` in interface `BeanPostProcessor`
  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
  Throws:
    `BeansException` - in case of errors
  See Also:
    `InitializingBean.afterPropertiesSet()`, `FactoryBean`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| The Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2007 The Spring Framework.