Interface Instance.Handle<T>

Type Parameters:
T - the required bean type
All Superinterfaces:
AutoCloseable
Enclosing interface:
Instance<T>

public static interface Instance.Handle<T> extends AutoCloseable
This interface represents a contextual reference handle.

Allows to inspect the metadata of the relevant bean before resolving its contextual reference and also to destroy the underlying contextual instance.

Author:
Matej Novotny
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Delegates to destroy().
    void
    Destroy the contextual instance.
    get()
    The contextual reference is obtained lazily, i.e.
     
  • Method Details

    • get

      T get()
      The contextual reference is obtained lazily, i.e. when first needed.
      Returns:
      the contextual reference
      Throws:
      IllegalStateException - If the producing Instance does not exist
      IllegalStateException - If invoked on Instance.Handle that previously successfully destroyed its underlying contextual reference
      See Also:
      • Provider.get()
    • getBean

      Bean<T> getBean()
      Returns:
      the bean metadata
    • destroy

      void destroy()
      Destroy the contextual instance. It's a no-op if:
      • called multiple times
      • if the producing Instance does not exist
      • if the handle does not hold a contextual reference, i.e. get() was never called
      See Also:
    • close

      void close()
      Delegates to destroy().
      Specified by:
      close in interface AutoCloseable