Package io.smallrye.beanbag
Class Scope
java.lang.Object
io.smallrye.beanbag.Scope
A (potentially nested) scope from which bean instances may be acquired.
-
Method Summary
Modifier and TypeMethodDescription<T> List<T>getAllBeans(Class<T> type) Get all constructable beans of the given type.<T> List<T>getAllBeans(Class<T> type, DependencyFilter filter) Get all constructable beans of the given type.<T> List<T>getAllBeans(Class<T> type, String name) Get all constructable beans of the given type and name.<T> List<T>getAllBeans(Class<T> type, String name, DependencyFilter filter) Get all constructable beans of the given type and name.getAllBeansWithNames(Class<T> type, DependencyFilter filter) Get all constructable beans of the given type as a map.<T> TgetBean(Class<T> type, String name, boolean optional, DependencyFilter filter) Get a single bean with the given type and name, with configurable optionality.<T> TgetOptionalBean(Class<T> type) Get a single bean with the given type, if it exists and can be instantiated.<T> TgetOptionalBean(Class<T> type, String name) Get a single bean with the given type and name, if it exists and can be instantiated.<T> TgetOptionalBean(Class<T> type, String name, DependencyFilter filter) Get a single bean with the given type and name, if it exists and can be instantiated.<T> TrequireBean(Class<T> type) Require a single bean with the given type.<T> TrequireBean(Class<T> type, String name) Require a single bean with the given type and name.
-
Method Details
-
getAllBeans
Get all constructable beans of the given type.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)- Returns:
- the (possibly empty) list of all matching beans
-
getAllBeans
Get all constructable beans of the given type. The filter is applied to each bean to determine whether it should be instantiated.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)filter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the (possibly empty) list of all matching beans
-
getAllBeans
Get all constructable beans of the given type and name.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)name- the name of the bean which should be returned, or""for any (must not benull)- Returns:
- the (possibly empty) list of all matching beans
-
getAllBeans
Get all constructable beans of the given type and name. The filter is applied to each bean to determine whether it should be instantiated.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)name- the name of the bean which should be returned, or""for any (must not benull)filter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the (possibly empty) list of all matching beans
-
getAllBeansWithNames
Get all constructable beans of the given type as a map. The filter is applied to each bean to determine whether it should be instantiated.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)filter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the (possibly empty) list of all matching beans
-
requireBean
Require a single bean with the given type.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)- Returns:
- the single bean (not
null) - Throws:
NoSuchBeanException- if the bean is not presentBeanInstantiationException- if some error occurred when instantiating the bean
-
requireBean
Require a single bean with the given type and name.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)name- the name of the bean which should be returned, or""for any (must not benull)- Returns:
- the single bean (not
null) - Throws:
NoSuchBeanException- if the bean is not presentBeanInstantiationException- if some error occurred when instantiating the bean
-
getOptionalBean
Get a single bean with the given type, if it exists and can be instantiated.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)- Returns:
- the single bean, or
nullif it is not present
-
getOptionalBean
Get a single bean with the given type and name, if it exists and can be instantiated.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)name- the name of the bean which should be returned, or""for any (must not benull)- Returns:
- the single bean, or
nullif it is not present
-
getOptionalBean
Get a single bean with the given type and name, if it exists and can be instantiated. The filter is applied to each bean to determine whether it should be instantiated.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)name- the name of the bean which should be returned, or""for any (must not benull)filter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the single bean, or
nullif it is not present
-
getBean
Get a single bean with the given type and name, with configurable optionality. The filter is applied to each bean to determine whether it should be instantiated.- Type Parameters:
T- the allowed bean type- Parameters:
type- the allowed bean type class (must not benull)name- the name of the bean which should be returned, or""for any (must not benull)optional-trueto return null if no bean matches, orfalseto throw an exception if no bean matchesfilter- the filter to apply to determine whether a given bean should be included (must not benull)- Returns:
- the single bean, or
nullif it is not present - Throws:
NoSuchBeanException- if the bean is not present
-
getContainer
-