Package jakarta.enterprise.inject
Interface Instance.Handle<T>
- Type Parameters:
T
- the required bean type
- All Superinterfaces:
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
-
Method Details
-
get
T get()The contextual reference is obtained lazily, i.e. when first needed.- Returns:
- the contextual reference
- Throws:
IllegalStateException
- If the producingInstance
does not existIllegalStateException
- If invoked onInstance.Handle
that previously successfully destroyed its underlying contextual reference- See Also:
-
getBean
- Returns:
- the bean metadata
-
destroy
void destroy()Destroy the contextual instance. It's a no-op if:- See Also:
-
close
void close()Delegates todestroy()
.- Specified by:
close
in interfaceAutoCloseable
-