Package io.quarkus.arc
Interface ArcContainer
-
- All Known Implementing Classes:
ArcContainerImpl
public interface ArcContainer
Represents a container instance.- Author:
- Martin Kouba
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T> InjectableBean<T>
bean(String beanIdentifier)
<T> Supplier<InstanceHandle<T>>
beanInstanceSupplier(Class<T> type, Annotation... qualifiers)
Returns a supplier that can be used to create new instances, or null if no matching bean can be found.jakarta.enterprise.inject.spi.BeanManager
beanManager()
NOTE: Not all methods are supported!InjectableContext
getActiveContext(Class<? extends Annotation> scopeType)
UnlikeBeanContainer.getContext(Class)
this method does not throwContextNotActiveException
if there is no active context for the given scope.List<InjectableContext>
getContexts(Class<? extends Annotation> scopeType)
CurrentContextFactory
getCurrentContextFactory()
ExecutorService
getExecutorService()
Set<Class<? extends Annotation>>
getScopes()
<T> InstanceHandle<T>
instance(InjectableBean<T> bean)
<T> InstanceHandle<T>
instance(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Never returns null.<T> InstanceHandle<T>
instance(Class<T> type, Annotation... qualifiers)
Never returns null.<X> InstanceHandle<X>
instance(Type type, Annotation... qualifiers)
Never returns null.<T> InstanceHandle<T>
instance(String name)
Never returns null.boolean
isRunning()
Returns true if Arc container is running.<T> List<InstanceHandle<T>>
listAll(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
List all beans matching the required type and qualifiers.<T> List<InstanceHandle<T>>
listAll(Class<T> type, Annotation... qualifiers)
List all beans matching the required type and qualifiers.<X> List<InstanceHandle<X>>
listAll(Type type, Annotation... qualifiers)
InjectableBean<?>
namedBean(String name)
Note that ambiguous names are detected at build time.ManagedContext
requestContext()
This method never throwsContextNotActiveException
.<T> InjectableInstance<T>
select(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Instances of dependent scoped beans obtained with the returned injectable instance must be explicitly destroyed, either via theInstance.destroy(Object)
method invoked upon the same injectable instance or withInstanceHandle.destroy()
.<T> InjectableInstance<T>
select(Class<T> type, Annotation... qualifiers)
Instances of dependent scoped beans obtained with the returned injectable instance must be explicitly destroyed, either via theInstance.destroy(Object)
method invoked upon the same injectable instance or withInstanceHandle.destroy()
.boolean
strictCompatibility()
Indicates whether container runs in strict compatibility mode.
-
-
-
Method Detail
-
getActiveContext
InjectableContext getActiveContext(Class<? extends Annotation> scopeType)
UnlikeBeanContainer.getContext(Class)
this method does not throwContextNotActiveException
if there is no active context for the given scope.- Parameters:
scopeType
-- Returns:
- the active context or null
- Throws:
IllegalArgumentException
- if there is more than one active context for the given scope
-
getContexts
List<InjectableContext> getContexts(Class<? extends Annotation> scopeType)
- Parameters:
scopeType
-- Returns:
- the matching context objects, never null
-
getScopes
Set<Class<? extends Annotation>> getScopes()
- Returns:
- the set of all supported scopes
-
instance
<T> InstanceHandle<T> instance(Class<T> type, Annotation... qualifiers)
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Parameters:
type
-qualifiers
-- Returns:
- a new instance handle
- Throws:
IllegalArgumentException
- if an instance of an annotation that is not a qualifier type is given
-
instance
<T> InstanceHandle<T> instance(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Parameters:
type
-qualifiers
-- Returns:
- a new instance handle
- Throws:
IllegalArgumentException
- if an instance of an annotation that is not a qualifier type is given
-
instance
<X> InstanceHandle<X> instance(Type type, Annotation... qualifiers)
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Parameters:
type
-qualifiers
-- Returns:
- a new instance handle
- Throws:
IllegalArgumentException
- if an instance of an annotation that is not a qualifier type is given
-
instance
<T> InstanceHandle<T> instance(String name)
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified name.- Parameters:
name
-- Returns:
- a new instance handle
- See Also:
InjectableBean.getName()
-
beanInstanceSupplier
<T> Supplier<InstanceHandle<T>> beanInstanceSupplier(Class<T> type, Annotation... qualifiers)
Returns a supplier that can be used to create new instances, or null if no matching bean can be found.- Type Parameters:
T
-- Parameters:
type
-qualifiers
-- Returns:
-
instance
<T> InstanceHandle<T> instance(InjectableBean<T> bean)
- Parameters:
bean
-- Returns:
- a new bean instance handle
-
select
<T> InjectableInstance<T> select(Class<T> type, Annotation... qualifiers)
Instances of dependent scoped beans obtained with the returned injectable instance must be explicitly destroyed, either via theInstance.destroy(Object)
method invoked upon the same injectable instance or withInstanceHandle.destroy()
. If no qualifier is passed, the @Default qualifier is assumed.- Type Parameters:
T
-- Parameters:
type
-qualifiers
-- Returns:
- a new injectable instance that could be used for programmatic lookup
-
select
<T> InjectableInstance<T> select(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Instances of dependent scoped beans obtained with the returned injectable instance must be explicitly destroyed, either via theInstance.destroy(Object)
method invoked upon the same injectable instance or withInstanceHandle.destroy()
. If no qualifier is passed, the @Default qualifier is assumed.- Type Parameters:
T
-- Parameters:
type
-qualifiers
-- Returns:
- a new injectable instance that could be used for programmatic lookup
-
listAll
<T> List<InstanceHandle<T>> listAll(Class<T> type, Annotation... qualifiers)
List all beans matching the required type and qualifiers.Instances of dependent scoped beans should be explicitly destroyed with
InstanceHandle.destroy()
.The list is sorted by
InjectableBean.getPriority()
. Higher priority goes first.- Type Parameters:
T
-- Parameters:
type
-qualifiers
-- Returns:
- the list of handles for the disambiguated beans
- See Also:
All
-
listAll
<T> List<InstanceHandle<T>> listAll(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
List all beans matching the required type and qualifiers.Instances of dependent scoped beans should be explicitly destroyed with
InstanceHandle.destroy()
.The list of is sorted by
InjectableBean.getPriority()
. Higher priority goes first.- Type Parameters:
T
-- Parameters:
type
-qualifiers
-- Returns:
- the list of handles for the disambiguated beans
- See Also:
All
-
listAll
<X> List<InstanceHandle<X>> listAll(Type type, Annotation... qualifiers)
- Type Parameters:
X
-- Parameters:
type
-qualifiers
-- Returns:
- the list of handles for the disambiguated beans
- See Also:
listAll(Class, Annotation...)
-
isRunning
boolean isRunning()
Returns true if Arc container is running. This can be used as a quick check to determine CDI availability in Quarkus.- Returns:
- true if
ArcContainer
is running, false otherwise
-
bean
<T> InjectableBean<T> bean(String beanIdentifier)
- Parameters:
beanIdentifier
-- Returns:
- an injectable bean or null
- See Also:
InjectableBean.getIdentifier()
-
namedBean
InjectableBean<?> namedBean(String name)
Note that ambiguous names are detected at build time. Therefore, unlike {@link jakarta.enterprise.inject.spi.BeanManager.getBeans(String)} this method either returns a resolved bean ornull
if no bean matches.- Parameters:
name
-- Returns:
- an injectable bean with the given name or null
- See Also:
InjectableBean.getName()
-
requestContext
ManagedContext requestContext()
This method never throwsContextNotActiveException
.- Returns:
- the built-in context for
RequestScoped
-
beanManager
jakarta.enterprise.inject.spi.BeanManager beanManager()
NOTE: Not all methods are supported!- Returns:
- the bean manager
-
getExecutorService
ExecutorService getExecutorService()
- Returns:
- the default executor service
-
getCurrentContextFactory
CurrentContextFactory getCurrentContextFactory()
- Returns:
- the factory
- See Also:
CurrentContext
-
strictCompatibility
boolean strictCompatibility()
Indicates whether container runs in strict compatibility mode. Default value is false.- Returns:
- true is strict mode is enabled, false otherwise.
-
-