Interface ObjectFactory<T>

Type Parameters:
T - the object type
All Known Subinterfaces:
ObjectProvider<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ObjectFactory<T>
Defines a factory which can return an Object instance (possibly shared or independent) when invoked.

This interface is typically used to encapsulate a generic factory which returns a new instance (prototype) of some target object on each invocation.

This interface is similar to FactoryBean, but implementations of the latter are normally meant to be defined as SPI instances in a BeanFactory, while implementations of this class are normally meant to be fed as an API to other beans (through injection). As such, the getObject() method has different exception handling behavior.

Since:
1.0.2
Author:
Colin Sampaleanu
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Return an instance (possibly shared or independent) of the object managed by this factory.
  • Method Details

    • getObject

      T getObject() throws BeansException
      Return an instance (possibly shared or independent) of the object managed by this factory.
      Returns:
      the resulting instance
      Throws:
      BeansException - in case of creation errors