Package io.quarkus.arc.runtime
Class BeanContainerImpl
- java.lang.Object
-
- io.quarkus.arc.runtime.BeanContainerImpl
-
- All Implemented Interfaces:
BeanContainer
class BeanContainerImpl extends Object implements BeanContainer
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.quarkus.arc.runtime.BeanContainer
BeanContainer.Factory<T>, BeanContainer.Instance<T>
-
-
Constructor Summary
Constructors Constructor Description BeanContainerImpl(ArcContainer container)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
beanInstance(Class<T> beanType, Annotation... beanQualifiers)
Resolves a bean instance for given bean type and qualifiers.<T> BeanContainer.Factory<T>
beanInstanceFactory(Class<T> type, Annotation... qualifiers)
Returns an instance factory for given bean type and qualifiers.<T> BeanContainer.Factory<T>
beanInstanceFactory(Supplier<BeanContainer.Factory<T>> fallbackSupplier, Class<T> type, Annotation... qualifiers)
Returns an instance factory for given bean type and qualifiers.ManagedContext
requestContext()
ManagedContext requestContext = beanContainer.requestContext(); if (requestContext.isActive()) { // Perform action } else { try { requestContext.activate(); // Perform action } finally { requestContext.terminate(); } }
-
-
-
Constructor Detail
-
BeanContainerImpl
BeanContainerImpl(ArcContainer container)
-
-
Method Detail
-
beanInstance
public <T> T beanInstance(Class<T> beanType, Annotation... beanQualifiers)
Description copied from interface:BeanContainer
Resolves a bean instance for given bean type and qualifiers. Performs standard CDI resolution meaning it either returns a bean instance or throws a corresponding exception if the dependency is either unsatisfied or ambiguous.- Specified by:
beanInstance
in interfaceBeanContainer
- Parameters:
beanType
- type of the beanbeanQualifiers
- bean qualifiers- Returns:
- a bean instance; never
null
-
beanInstanceFactory
public <T> BeanContainer.Factory<T> beanInstanceFactory(Class<T> type, Annotation... qualifiers)
Description copied from interface:BeanContainer
Returns an instance factory for given bean type and qualifiers. This method performs CDI ambiguous dependency resolution and throws and exception if there are two or more beans with given type and qualifiers. If no matching bean is found, uses a default fallback factory that will attempt to instantiate a non-CDI object of the given class via no-args constructor. If you need custom factory behavior, take a look atBeanContainer.beanInstanceFactory(Supplier, Class, Annotation...)
- Specified by:
beanInstanceFactory
in interfaceBeanContainer
- Parameters:
type
- bean typequalifiers
- bean qualifiers- Returns:
- a bean instance factory, never
null
-
beanInstanceFactory
public <T> BeanContainer.Factory<T> beanInstanceFactory(Supplier<BeanContainer.Factory<T>> fallbackSupplier, Class<T> type, Annotation... qualifiers)
Description copied from interface:BeanContainer
Returns an instance factory for given bean type and qualifiers. This method performs CDI ambiguous dependency resolution and throws and exception if there are two or more beans with given type and qualifiers. If no matching bean is found, delegates all calls to the supplied factory fallback.- Specified by:
beanInstanceFactory
in interfaceBeanContainer
- Parameters:
fallbackSupplier
- supplier to delegate to if there is no beantype
- bean typequalifiers
- bean qualifiers- Returns:
- a bean instance factory, never
null
-
requestContext
public ManagedContext requestContext()
Description copied from interface:BeanContainer
ManagedContext requestContext = beanContainer.requestContext(); if (requestContext.isActive()) { // Perform action } else { try { requestContext.activate(); // Perform action } finally { requestContext.terminate(); } }
- Specified by:
requestContext
in interfaceBeanContainer
- Returns:
- the context for
RequestScoped
-
-