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, boolean strictMode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete 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.BeanManagerbeanManager()NOTE: Not all methods are supported!InjectableContextgetActiveContext(Class<? extends Annotation> scopeType)UnlikeBeanContainer.getContext(Class)this method does not throwContextNotActiveExceptionif there is no active context for the given scope.List<InjectableBean<?>>getBeans()List<InjectableContext>getContexts(Class<? extends Annotation> scopeType)CurrentContextFactorygetCurrentContextFactory()List<InjectableDecorator<?>>getDecorators()ExecutorServicegetExecutorService()List<InjectableInterceptor<?>>getInterceptors()List<InjectableObserverMethod<?>>getObservers()List<RemovedBean>getRemovedBeans()Set<Class<? extends Annotation>>getScopes()voidinit()static ArcContainerImplinstance()<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.<T> Supplier<InstanceHandle<T>>instanceSupplier(Class<T> type, Annotation... qualifiers)This method is deprecated and will be removed in future versions.booleanisRunning()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)static voidmockObservers(String beanIdentifier, boolean mock)voidmockObserversFor(Class<?> beanClass, boolean mock)InjectableBean<?>namedBean(String name)Note that ambiguous names are detected at build time.ManagedContextrequestContext()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().voidsetExecutor(ExecutorService executor)voidshutdown()booleanstrictCompatibility()Indicates whether container runs in strict compatibility mode.StringtoString()
-
-
-
Constructor Detail
-
ArcContainerImpl
public ArcContainerImpl(CurrentContextFactory currentContextFactory, boolean strictMode)
-
-
Method Detail
-
init
public void init()
-
getActiveContext
public InjectableContext getActiveContext(Class<? extends Annotation> scopeType)
Description copied from interface:ArcContainerUnlikeBeanContainer.getContext(Class)this method does not throwContextNotActiveExceptionif there is no active context for the given scope.- Specified by:
getActiveContextin interfaceArcContainer- Returns:
- the active context or null
-
getContexts
public List<InjectableContext> getContexts(Class<? extends Annotation> scopeType)
- Specified by:
getContextsin interfaceArcContainer- Returns:
- the matching context objects, never null
-
getScopes
public Set<Class<? extends Annotation>> getScopes()
- Specified by:
getScopesin interfaceArcContainer- Returns:
- the set of all supported scopes
-
instance
public <T> InstanceHandle<T> instance(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainerNever returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Specified by:
instancein interfaceArcContainer- Returns:
- a new instance handle
-
instance
public <T> InstanceHandle<T> instance(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainerNever returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Specified by:
instancein interfaceArcContainer- Returns:
- a new instance handle
-
instance
public <X> InstanceHandle<X> instance(Type type, Annotation... qualifiers)
Description copied from interface:ArcContainerNever returns null. However, the handle is empty if no bean matches/multiple beans match the specified type and qualifiers.- Specified by:
instancein interfaceArcContainer- Returns:
- a new instance handle
-
beanInstanceSupplier
public <T> Supplier<InstanceHandle<T>> beanInstanceSupplier(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainerReturns 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. This behavior differs to standard CDI rules where an ambiguous dependency would exist. see https://github.com/quarkusio/quarkus/issues/3369- Specified by:
beanInstanceSupplierin interfaceArcContainer- Returns:
-
instanceSupplier
public <T> Supplier<InstanceHandle<T>> instanceSupplier(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainerThis method is deprecated and will be removed in future versions. UseArcContainer.beanInstanceSupplier(Class, Annotation...)instead. As opposed toArcContainer.beanInstanceSupplier(Class, Annotation...), this method does NOT follow CDI resolution rules and in case of ambiguous resolution performs a choice based on the class type parameter.- Specified by:
instanceSupplierin interfaceArcContainer- Returns:
-
instance
public <T> InstanceHandle<T> instance(InjectableBean<T> bean)
- Specified by:
instancein interfaceArcContainer- Returns:
- a new bean instance handle
-
select
public <T> InjectableInstance<T> select(Class<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainerInstances 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:
selectin interfaceArcContainer- Returns:
- a new injectable instance that could be used for programmatic lookup
-
select
public <T> InjectableInstance<T> select(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainerInstances 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:
selectin 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:ArcContainerList 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:
listAllin interfaceArcContainer- Returns:
- the list of handles for the disambiguated beans
- See Also:
All
-
listAll
public <T> List<InstanceHandle<T>> listAll(jakarta.enterprise.util.TypeLiteral<T> type, Annotation... qualifiers)
Description copied from interface:ArcContainerList 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:
listAllin interfaceArcContainer- Returns:
- the list of handles for the disambiguated beans
- See Also:
All
-
listAll
public <X> List<InstanceHandle<X>> listAll(Type type, Annotation... qualifiers)
- Specified by:
listAllin interfaceArcContainer- Returns:
- the list of handles for the disambiguated beans
- See Also:
ArcContainer.listAll(Class, Annotation...)
-
isRunning
public boolean isRunning()
Description copied from interface:ArcContainerReturns true if Arc container is running. This can be used as a quick check to determine CDI availability in Quarkus.- Specified by:
isRunningin interfaceArcContainer- Returns:
- true if
ArcContaineris running, false otherwise
-
bean
public <T> InjectableBean<T> bean(String beanIdentifier)
- Specified by:
beanin interfaceArcContainer- Returns:
- an injectable bean or null
- See Also:
InjectableBean.getIdentifier()
-
namedBean
public InjectableBean<?> namedBean(String name)
Description copied from interface:ArcContainerNote 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 ornullif no bean matches.- Specified by:
namedBeanin 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:ArcContainerNever returns null. However, the handle is empty if no bean matches/multiple beans match the specified name.- Specified by:
instancein interfaceArcContainer- Returns:
- a new instance handle
- See Also:
InjectableBean.getName()
-
requestContext
public ManagedContext requestContext()
Description copied from interface:ArcContainerThis method never throwsContextNotActiveException.- Specified by:
requestContextin interfaceArcContainer- Returns:
- the built-in context for
RequestScoped
-
beanManager
public jakarta.enterprise.inject.spi.BeanManager beanManager()
Description copied from interface:ArcContainerNOTE: Not all methods are supported!- Specified by:
beanManagerin interfaceArcContainer- Returns:
- the bean manager
-
getExecutorService
public ExecutorService getExecutorService()
- Specified by:
getExecutorServicein interfaceArcContainer- Returns:
- the default executor service
-
setExecutor
public void setExecutor(ExecutorService executor)
-
getCurrentContextFactory
public CurrentContextFactory getCurrentContextFactory()
- Specified by:
getCurrentContextFactoryin interfaceArcContainer- Returns:
- the factory
- See Also:
CurrentContext
-
strictCompatibility
public boolean strictCompatibility()
Description copied from interface:ArcContainerIndicates whether container runs in strict compatibility mode. Default value is false.- Specified by:
strictCompatibilityin interfaceArcContainer- Returns:
- true is strict mode is enabled, false otherwise.
-
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()
-
-