Package org.springframework.beans.factory.support

# Class FactoryBeanRegistrySupport

java.lang.Object
org.springframework.core.SimpleAliasRegistry
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry
org.springframework.beans.factory.support.FactoryBeanRegistrySupport

All Implemented Interfaces:
  `SingletonBeanRegistry`, `org.springframework.core.AliasRegistry`

Direct Known Subclasses:
  `AbstractBeanFactory`

public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanRegistry
Support base class for singleton registries which need to handle `FactoryBean` instances, integrated with `DefaultSingletonBeanRegistry`'s singleton management.

Serves as base class for `AbstractBeanFactory`.

Since:
  2.5.1
Author:
  Juergen Hoeller

## Field Summary

### Fields inherited from class org.springframework.core.SimpleAliasRegistry

`logger`

## Constructor Summary

Constructors
Constructor
Description
`FactoryBeanRegistrySupport()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`clearSingletonCache()`
Overridden to clear the FactoryBean object cache as well.
`protected Object`
`getCachedObjectForFactoryBean(String beanName)`
Obtain an object to expose from the given FactoryBean, if available in cached form.
`protected FactoryBean<?>`
`getFactoryBean(String beanName, Object beanInstance)`
Get a FactoryBean for the given bean if possible.
`protected Object`
`getObjectFromFactoryBean(FactoryBean<?> factory, String beanName, boolean shouldPostProcess)`
Obtain an object to expose from the given FactoryBean.
`protected Class<?>`
`getTypeForFactoryBean(FactoryBean<?> factoryBean)`
Determine the type for the given FactoryBean.
`protected Object`
`postProcessObjectFromFactoryBean(Object object, String beanName)`
Post-process the given object that has been obtained from the FactoryBean.
`protected void`
`removeSingleton(String beanName)`
Overridden to clear the FactoryBean object cache as well.

### Methods inherited from class org.springframework.beans.factory.support.DefaultSingletonBeanRegistry

`addSingleton, addSingletonCallback, addSingletonFactory, afterSingletonCreation, beforeSingletonCreation, containsSingleton, destroyBean, destroySingleton, destroySingletons, getDependenciesForBean, getDependentBeans, getSingleton, getSingleton, getSingleton, getSingletonCount, getSingletonMutex, getSingletonNames, hasDependentBean, isActuallyInCreation, isCurrentlyInCreation, isCurrentThreadAllowedToHoldSingletonLock, isDependent, isSingletonCurrentlyInCreation, onSuppressedException, registerContainedBean, registerDependentBean, registerDisposableBean, registerSingleton, setCurrentlyInCreation`

### Methods inherited from class org.springframework.core.SimpleAliasRegistry

`allowAliasOverriding, canonicalName, checkForAliasCircle, getAliases, hasAlias, isAlias, registerAlias, removeAlias, resolveAliases`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### FactoryBeanRegistrySupport

public FactoryBeanRegistrySupport()

## Method Details

### getTypeForFactoryBean

@Nullable protected Class<?> getTypeForFactoryBean(FactoryBean<?> factoryBean)
Determine the type for the given FactoryBean.

Parameters:
  `factoryBean` - the FactoryBean instance to check
Returns:
  the FactoryBean's object type, or `null` if the type cannot be determined yet

### getCachedObjectForFactoryBean

@Nullable protected Object getCachedObjectForFactoryBean(String beanName)
Obtain an object to expose from the given FactoryBean, if available in cached form. Quick check for minimal synchronization.

Parameters:
  `beanName` - the name of the bean
Returns:
  the object obtained from the FactoryBean, or `null` if not available

### getObjectFromFactoryBean

protected Object getObjectFromFactoryBean(FactoryBean<?> factory, String beanName, boolean shouldPostProcess)
Obtain an object to expose from the given FactoryBean.

Parameters:
  `factory` - the FactoryBean instance
  `beanName` - the name of the bean
  `shouldPostProcess` - whether the bean is subject to post-processing
Returns:
  the object obtained from the FactoryBean
Throws:
  `BeanCreationException` - if FactoryBean object creation failed
See Also:
  - `FactoryBean.getObject()`

### postProcessObjectFromFactoryBean

protected Object postProcessObjectFromFactoryBean(Object object, String beanName) throws BeansException
Post-process the given object that has been obtained from the FactoryBean. The resulting object will get exposed for bean references.

The default implementation simply returns the given object as-is. Subclasses may override this, for example, to apply post-processors.

Parameters:
  `object` - the object obtained from the FactoryBean.
  `beanName` - the name of the bean
Returns:
  the object to expose
Throws:
  `BeansException` - if any post-processing failed

### getFactoryBean

protected FactoryBean<?> getFactoryBean(String beanName, Object beanInstance) throws BeansException
Get a FactoryBean for the given bean if possible.

Parameters:
  `beanName` - the name of the bean
  `beanInstance` - the corresponding bean instance
Returns:
  the bean instance as FactoryBean
Throws:
  `BeansException` - if the given bean cannot be exposed as a FactoryBean

### removeSingleton

protected void removeSingleton(String beanName)
Overridden to clear the FactoryBean object cache as well.

Overrides:
  `removeSingleton` in class `DefaultSingletonBeanRegistry`
Parameters:
  `beanName` - the name of the bean

### clearSingletonCache

protected void clearSingletonCache()
Overridden to clear the FactoryBean object cache as well.

Overrides:
  `clearSingletonCache` in class `DefaultSingletonBeanRegistry`