Package net.shibboleth.shared.spring.factory

# Class AbstractComponentAwareFactoryBean<T>

java.lang.Object
net.shibboleth.shared.spring.factory.AbstractFactoryBean<T>
net.shibboleth.shared.spring.factory.AbstractComponentAwareFactoryBean<T>

Type Parameters:
  `T` - The type to implement

All Implemented Interfaces:
  `Aware`, `BeanClassLoaderAware`, `BeanFactoryAware`, `DisposableBean`, `FactoryBean<T>`, `InitializingBean`

Direct Known Subclasses:
  `EvaluableScriptFactoryBean`, `HttpHostFactoryBean`, `PatternFactoryBean`, `UsernamePasswoordCredentialsFactoryBean`

public abstract class AbstractComponentAwareFactoryBean<T> extends AbstractFactoryBean<T>
A Factory bean which is aware of the component lifecycle interfaces.

## Field Summary

Fields
Modifier and Type
Field
Description
`private boolean`
`throwIfNull`
Flag controlling null behavior.

### Fields inherited from interface org.springframework.beans.factory.FactoryBean

`OBJECT_TYPE_ATTRIBUTE`

## Constructor Summary

Constructors
Constructor
Description
`AbstractComponentAwareFactoryBean()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected final T`
`createInstance()`
Call the parent class to create the object, then initialize it aposite.
`protected void`
`destroyInstance(T instance)`
Callback for destroying a singleton instance.
`protected abstract T`
`doCreateInstance()`
Call the parent class to create the instance.
`void`
`setThrowIfNull(boolean flag)`
Sets whether to raise an exception if a null is returned from `doCreateInstance()`.

### Methods inherited from class net.shibboleth.shared.spring.factory.AbstractFactoryBean

`afterPropertiesSet, destroy, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, getObjectType, isSingleton, setBeanClassLoader, setBeanFactory, setSingleton`

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

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

## Field Details

### throwIfNull

private boolean throwIfNull
Flag controlling null behavior.

## Constructor Details

### AbstractComponentAwareFactoryBean

public AbstractComponentAwareFactoryBean()
Constructor.

## Method Details

### destroyInstance

protected void destroyInstance(@Nullable T instance) throws Exception
Callback for destroying a singleton instance. Subclasses may override this to destroy the previously created instance.

The default implementation is empty.

Call our destroy method if aposite.

Overrides:
  `destroyInstance` in class `AbstractFactoryBean<T>`
Parameters:
  `instance` - the singleton instance, as returned by `AbstractFactoryBean.createInstance()`
Throws:
  `Exception` - in case of shutdown errors
See Also:
  - `AbstractFactoryBean.createInstance()`

### setThrowIfNull

public void setThrowIfNull(boolean flag)
Sets whether to raise an exception if a null is returned from `doCreateInstance()`.

Defaults to true.

Parameters:
  `flag` -
Since:
  9.1.0

### createInstance

@Nullable protected final T createInstance() throws Exception

Call the parent class to create the object, then initialize it aposite.

Template method that subclasses must override to construct the object returned by this factory.

Invoked on initialization of this FactoryBean in case of a singleton; else, on each `AbstractFactoryBean.getObject()` call..

Specified by:
  `createInstance` in class `AbstractFactoryBean<T>`
Returns:
  the object returned by this factory
Throws:
  `Exception` - if an exception occurred during object creation
See Also:
  - `AbstractFactoryBean.getObject()`

### doCreateInstance

@Nullable protected abstract T doCreateInstance() throws Exception
Call the parent class to create the instance.

Returns:
  the bean.
Throws:
  `Exception` - if needed.