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)
javax.enterprise.inject.spi.BeanManager
beanManager()
NOTE: Not all methods are supported!InjectableContext
getActiveContext(Class<? extends Annotation> scopeType)
UnlikeBeanManager.getContext(Class)
this method does not throwContextNotActiveException
if there is no active context for the given scope.List<InjectableContext>
getContexts(Class<? extends Annotation> scopeType)
ExecutorService
getExecutorService()
Set<Class<? extends Annotation>>
getScopes()
<T> InstanceHandle<T>
instance(InjectableBean<T> bean)
<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.<T> InstanceHandle<T>
instance(javax.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Never returns null.<T> Supplier<InstanceHandle<T>>
instanceSupplier(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.boolean
isRunning()
Returns true if Arc container is running.ManagedContext
requestContext()
This method never throwsContextNotActiveException
.<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()
.<T> InjectableInstance<T>
select(javax.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()
.
-
-
-
Method Detail
-
getActiveContext
InjectableContext getActiveContext(Class<? extends Annotation> scopeType)
UnlikeBeanManager.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(javax.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()
-
instanceSupplier
<T> Supplier<InstanceHandle<T>> instanceSupplier(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. Note that if there are multiple sub classes of the given type this will return the exact match. This means that this can be used to directly instantiate superclasses of other beans without causing problems. see https://github.com/quarkusio/quarkus/issues/3369- 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(javax.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
-
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()
-
requestContext
ManagedContext requestContext()
This method never throwsContextNotActiveException
.- Returns:
- the built-in context for
RequestScoped
-
beanManager
javax.enterprise.inject.spi.BeanManager beanManager()
NOTE: Not all methods are supported!- Returns:
- the bean manager
-
getExecutorService
ExecutorService getExecutorService()
- Returns:
- the default executor service
-
-