org.springframework.beans.factory.access

## Interface BeanFactoryReference

- All Known Implementing Classes:
    ContextBeanFactoryReference

      public interface BeanFactoryReference

  Used to track a reference to a `BeanFactory` obtained through a `BeanFactoryLocator`.

  It is safe to call `release()` multiple times, but `getFactory()` must not be called after calling release.

  Author:
    Colin Sampaleanu
  See Also:
    `BeanFactoryLocator`, `ContextBeanFactoryReference`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `BeanFactory` | `getFactory()` Return the `BeanFactory` instance held by this reference.
    `void` | `release()` Indicate that the `BeanFactory` instance referred to by this object is not needed any longer by the client code which obtained the `BeanFactoryReference`.

- - ### Method Detail

    - #### getFactory

          BeanFactory getFactory()

      Return the `BeanFactory` instance held by this reference.
      Throws:
        `IllegalStateException` - if invoked after `release()` has been called

    - #### release

          void release()

      Indicate that the `BeanFactory` instance referred to by this object is not needed any longer by the client code which obtained the `BeanFactoryReference`.

      Depending on the actual implementation of `BeanFactoryLocator`, and the actual type of `BeanFactory`, this may possibly not actually do anything; alternately in the case of a 'closeable' `BeanFactory` or derived class (such as `ApplicationContext`) may 'close' it, or may 'close' it once no more references remain.

      In an EJB usage scenario this would normally be called from `ejbRemove()` and `ejbPassivate()`.

      This is safe to call multiple times.

      See Also:
        `BeanFactoryLocator`, `ContextBeanFactoryReference`, `ConfigurableApplicationContext.close()`