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()
-
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()
Collection<InjectableContext>
getContexts(Class<? extends Annotation> scopeType)
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.static void
mockObservers(String beanIdentifier, boolean mock)
void
mockObserversFor(Class<?> beanClass, boolean mock)
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()
-
-
-
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 Collection<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
-
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 is
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()
-
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)
-
shutdown
public void shutdown()
-
getBeans
public List<InjectableBean<?>> getBeans()
-
getRemovedBeans
public List<RemovedBean> getRemovedBeans()
-
getInterceptors
public List<InjectableInterceptor<?>> getInterceptors()
-
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()
-
-