Class QuarkusArcBeanContainer
java.lang.Object
org.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer
io.quarkus.hibernate.orm.runtime.cdi.QuarkusArcBeanContainer
- All Implemented Interfaces:
org.hibernate.resource.beans.container.internal.CdiBasedBeanContainer,org.hibernate.resource.beans.container.spi.BeanContainer,org.hibernate.service.spi.Stoppable
@Singleton
public class QuarkusArcBeanContainer
extends org.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer
A
BeanContainer that works with other build-time elements in Quarkus to
achieve a behavior that is as unsurprising as possible, while complying with the Jakarta Persistence spec where possible.
The effective behavior is as follows:
- When a class is annotated with a scope, such as
@ApplicationScopedor@Dependent, we will comply with that (with some gotchas, see last item). This is not in line with the behavior from the Jakarta Persitence spec, which would ignore explicit scopes. - When a class is NOT annotated with any scope, it will behave as a
@DependentCDI bean, at least for attribute converters and entity listeners (with some gotchas, see last item). This is in line with what the Jakarta Persistence spec requires. - Regardless of the above, when a class is annotated with @Vetoed, it will never be instantiated through CDI, but rather through Hibernate ORM's reflection instantiation. This may or may not be in line with the behavior described in the Jakarta Persistence spec -- I did not check -- but seems sensible and intuitive enough.
- Hibernate ORM's internal behavior means components may be cached at the persistence unit level,
so even for
@Dependentcomponents, there would be at most one instance per persistence unit. TODO: this is what we've always done and what we assume in tests, but is this what we want?Note this behavior is only possible because we give attribute converters and entity listeners the dependent scope by default: see
io.quarkus.hibernate.orm.deployment.HibernateOrmCdiProcessor#registerBeans.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.hibernate.resource.beans.container.spi.BeanContainer
org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions -
Field Summary
FieldsModifier and TypeFieldDescription(package private) jakarta.enterprise.inject.spi.BeanManager -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected <B> org.hibernate.resource.beans.container.spi.ContainedBeanImplementor<B> createBean(Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy lifecycleStrategy, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) protected <B> org.hibernate.resource.beans.container.spi.ContainedBeanImplementor<B> createBean(String name, Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy lifecycleStrategy, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) voiddestroy()This will happen after Hibernate ORM is stopped; see io.quarkus.hibernate.orm.runtime.JPAConfig#destroy(java.lang.Object).<B> org.hibernate.resource.beans.container.spi.ContainedBean<B> getBean(Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) <B> org.hibernate.resource.beans.container.spi.ContainedBean<B> getBean(String beanName, Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) jakarta.enterprise.inject.spi.BeanManagerMethods inherited from class org.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer
forEachBean, stop
-
Field Details
-
beanManager
@Inject jakarta.enterprise.inject.spi.BeanManager beanManager
-
-
Constructor Details
-
QuarkusArcBeanContainer
public QuarkusArcBeanContainer()
-
-
Method Details
-
getUsableBeanManager
public jakarta.enterprise.inject.spi.BeanManager getUsableBeanManager() -
getBean
public <B> org.hibernate.resource.beans.container.spi.ContainedBean<B> getBean(Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) - Specified by:
getBeanin interfaceorg.hibernate.resource.beans.container.spi.BeanContainer- Overrides:
getBeanin classorg.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer
-
getBean
public <B> org.hibernate.resource.beans.container.spi.ContainedBean<B> getBean(String beanName, Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) - Specified by:
getBeanin interfaceorg.hibernate.resource.beans.container.spi.BeanContainer- Overrides:
getBeanin classorg.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer
-
createBean
protected <B> org.hibernate.resource.beans.container.spi.ContainedBeanImplementor<B> createBean(Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy lifecycleStrategy, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) - Specified by:
createBeanin classorg.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer
-
createBean
protected <B> org.hibernate.resource.beans.container.spi.ContainedBeanImplementor<B> createBean(String name, Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy lifecycleStrategy, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer) - Specified by:
createBeanin classorg.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer
-
destroy
@PreDestroy public void destroy()This will happen after Hibernate ORM is stopped; see io.quarkus.hibernate.orm.runtime.JPAConfig#destroy(java.lang.Object).
-