Package io.quarkus.arc.impl
Class ArcContainerImpl
- java.lang.Object
-
- io.quarkus.arc.impl.ArcContainerImpl
-
- All Implemented Interfaces:
ArcContainer
public class ArcContainerImpl extends Object implements ArcContainer
-
-
Constructor Summary
Constructors Constructor Description ArcContainerImpl(CurrentContextFactory currentContextFactory)
-
Method Summary
All Methods Static Methods Instance Methods Concrete 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<InjectableBean<?>>
getBeans()
List<InjectableContext>
getContexts(Class<? extends Annotation> scopeType)
CurrentContextFactory
getCurrentContextFactory()
List<InjectableDecorator<?>>
getDecorators()
ExecutorService
getExecutorService()
List<InjectableInterceptor<?>>
getInterceptors()
List<InjectableObserverMethod<?>>
getObservers()
List<RemovedBean>
getRemovedBeans()
Set<Class<? extends Annotation>>
getScopes()
void
init()
static ArcContainerImpl
instance()
<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.<T> List<InstanceHandle<T>>
listAll(Class<T> type, Annotation... qualifiers)
List all beans matching the required type and qualifiers.<T> List<InstanceHandle<T>>
listAll(javax.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
List all beans matching the required type and qualifiers.static void
mockObservers(String beanIdentifier, boolean mock)
void
mockObserversFor(Class<?> beanClass, boolean mock)
InjectableBean<?>
namedBean(String name)
Note that ambiguous names are detected at build time.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()
.void
setExecutor(ExecutorService executor)
void
shutdown()
String
toString()
-
-
-
Constructor Detail
-
ArcContainerImpl
public ArcContainerImpl(CurrentContextFactory currentContextFactory)
-
-
Method Detail
-
init
public void init()
-
getActiveContext
public InjectableContext getActiveContext(Class<? extends Annotation> scopeType)
Description copied from interface:ArcContainer
UnlikeBeanManager.getContext(Class)
this method does not throwContextNotActiveException
if there is no active context for the given scope.- Specified by:
getActiveContext
in interfaceArcContainer
- Returns:
- the active context or null
-
getContexts
public List<InjectableContext> getContexts(Class<? extends Annotation> scopeType)
- Specified by:
getContexts
in interfaceArcContainer
- Returns:
- the matching context objects, never null
-
getScopes
public Set<Class<? extends Annotation>> getScopes()
- Specified by:
getScopes
in interfaceArcContainer
- Returns:
- the set of all supported scopes
-
instance
public <T> InstanceHandle<T> instance(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainer
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Specified by:
instance
in interfaceArcContainer
- Returns:
- a new instance handle
-
instance
public <T> InstanceHandle<T> instance(javax.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainer
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Specified by:
instance
in interfaceArcContainer
- Returns:
- a new instance handle
-
instance
public <X> InstanceHandle<X> instance(Type type, Annotation... qualifiers)
Description copied from interface:ArcContainer
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Specified by:
instance
in interfaceArcContainer
- Returns:
- a new instance handle
-
instanceSupplier
public <T> Supplier<InstanceHandle<T>> instanceSupplier(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainer
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- Specified by:
instanceSupplier
in interfaceArcContainer
- Returns:
-
instance
public <T> InstanceHandle<T> instance(InjectableBean<T> bean)
- Specified by:
instance
in interfaceArcContainer
- Returns:
- a new bean instance handle
-
select
public <T> InjectableInstance<T> select(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainer
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.- Specified by:
select
in interfaceArcContainer
- Returns:
- a new injectable instance that could be used for programmatic lookup
-
select
public <T> InjectableInstance<T> select(javax.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainer
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.- Specified by:
select
in interfaceArcContainer
- Returns:
- a new injectable instance that could be used for programmatic lookup
-
listAll
public <T> List<InstanceHandle<T>> listAll(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainer
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.- Specified by:
listAll
in interfaceArcContainer
- Returns:
- the list of handles for the disambiguated beans
- See Also:
All
-
listAll
public <T> List<InstanceHandle<T>> listAll(javax.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainer
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.- Specified by:
listAll
in interfaceArcContainer
- Returns:
- the list of handles for the disambiguated beans
- See Also:
All
-
isRunning
public boolean isRunning()
Description copied from interface:ArcContainer
Returns true if Arc container is running. This can be used as a quick check to determine CDI availability in Quarkus.- Specified by:
isRunning
in interfaceArcContainer
- Returns:
- true if
ArcContainer
is running, false otherwise
-
bean
public <T> InjectableBean<T> bean(String beanIdentifier)
- Specified by:
bean
in interfaceArcContainer
- Returns:
- an injectable bean or null
- See Also:
InjectableBean.getIdentifier()
-
namedBean
public InjectableBean<?> namedBean(String name)
Description copied from interface:ArcContainer
Note that ambiguous names are detected at build time. Therefore, unlike {@link javax.enterprise.inject.spi.BeanManager.getBeans(String)} this method either returns a resolved bean ornull
if no bean matches.- Specified by:
namedBean
in interfaceArcContainer
- Returns:
- an injectable bean with the given name or null
- See Also:
InjectableBean.getName()
-
instance
public <T> InstanceHandle<T> instance(String name)
Description copied from interface:ArcContainer
Never returns null. However, the handle is empty if no bean matches/multiple beans match the specified name.- Specified by:
instance
in interfaceArcContainer
- Returns:
- a new instance handle
- See Also:
InjectableBean.getName()
-
requestContext
public ManagedContext requestContext()
Description copied from interface:ArcContainer
This method never throwsContextNotActiveException
.- Specified by:
requestContext
in interfaceArcContainer
- Returns:
- the built-in context for
RequestScoped
-
beanManager
public javax.enterprise.inject.spi.BeanManager beanManager()
Description copied from interface:ArcContainer
NOTE: Not all methods are supported!- Specified by:
beanManager
in interfaceArcContainer
- Returns:
- the bean manager
-
getExecutorService
public ExecutorService getExecutorService()
- Specified by:
getExecutorService
in interfaceArcContainer
- Returns:
- the default executor service
-
setExecutor
public void setExecutor(ExecutorService executor)
-
getCurrentContextFactory
public CurrentContextFactory getCurrentContextFactory()
- Specified by:
getCurrentContextFactory
in interfaceArcContainer
- Returns:
- the factory
- See Also:
CurrentContext
-
shutdown
public void shutdown()
-
getBeans
public List<InjectableBean<?>> getBeans()
-
getRemovedBeans
public List<RemovedBean> getRemovedBeans()
-
getInterceptors
public List<InjectableInterceptor<?>> getInterceptors()
-
getDecorators
public List<InjectableDecorator<?>> getDecorators()
-
getObservers
public List<InjectableObserverMethod<?>> getObservers()
-
mockObservers
public static void mockObservers(String beanIdentifier, boolean mock)
-
mockObserversFor
public void mockObserversFor(Class<?> beanClass, boolean mock)
-
instance
public static ArcContainerImpl instance()
-
-