Class HibernateExtendedBeanManager

  • All Implemented Interfaces:

    public class HibernateExtendedBeanManager
    extends java.lang.Object
    implements ExtendedBeanManager
    HibernateExtendedBeanManager helps defer the registering of entity listeners, with the CDI BeanManager until after the persistence unit is available for lookup by CDI bean(s). This solves the WFLY-2387 issue of JPA entity listeners referencing the CDI bean, when the bean cycles back to the persistence unit, or a different persistence unit.
    • Constructor Detail

      • HibernateExtendedBeanManager

        public HibernateExtendedBeanManager​(BeanManager beanManager)
    • Method Detail

      • registerLifecycleListener

        public void registerLifecycleListener​(ExtendedBeanManager.LifecycleListener lifecycleListener)
        Hibernate calls registerLifecycleListener to register N callbacks to be notified when the CDI BeanManager can safely be used. The CDI BeanManager can safely be used when the CDI AfterDeploymentValidation event is reached.
        Specified by:
        registerLifecycleListener in interface ExtendedBeanManager
        lifecycleListener - Note: Caller (BeanManagerAfterDeploymentValidation) is expected to synchronize calls to registerLifecycleListener() + beanManagerIsAvailableForUse(), which protects HibernateExtendedBeanManager.lifecycleListeners from being read/written from multiple concurrent threads. There are many writer threads (one per deployed persistence unit) and one reader/writer thread expected to be triggered by one AfterDeploymentValidation event per deployment.
      • beanManagerIsAvailableForUse

        public void beanManagerIsAvailableForUse()