Interface ExtendedInstance.Handle<T>

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

    public static interface ExtendedInstance.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.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Delegates to destroy(), if the contextual reference is not a normal scoped bean.
      void destroy()
      Destroy the contextual instance.
      T get()
      The contextual reference is obtained lazily, i.e.
      jakarta.enterprise.inject.spi.Bean<T> getBean()  
    • Method Detail

      • 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 ExtendedInstance.Handle that previously successfully destroyed its underlying contextual reference
        See Also:
        Provider.get()
      • getBean

        jakarta.enterprise.inject.spi.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:
        Instance.destroy(Object)
      • close

        void close()
        Delegates to destroy(), if the contextual reference is not a normal scoped bean.
        Specified by:
        close in interface AutoCloseable