diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/event/spi/jpa/ExtendedBeanManager.java b/hibernate-core/src/main/java/org/hibernate/jpa/event/spi/jpa/ExtendedBeanManager.java index 784ddf5684..f197c9fddc 100644 --- a/hibernate-core/src/main/java/org/hibernate/jpa/event/spi/jpa/ExtendedBeanManager.java +++ b/hibernate-core/src/main/java/org/hibernate/jpa/event/spi/jpa/ExtendedBeanManager.java @@ -6,6 +6,8 @@ */ package org.hibernate.jpa.event.spi.jpa; +import javax.enterprise.inject.spi.BeanManager; + /** * @deprecated Use {@link org.hibernate.resource.beans.container.spi.ExtendedBeanManager} instead */ @@ -15,7 +17,22 @@ public interface ExtendedBeanManager extends org.hibernate.resource.beans.contai @Override default void registerLifecycleListener(org.hibernate.resource.beans.container.spi.ExtendedBeanManager.LifecycleListener lifecycleListener) { - registerLifecycleListener( (LifecycleListener) lifecycleListener ); + /* + * Casting the argument to our own LifecycleListener interface won't work here, + * since we would be down-casting and the argument may not implement the correct interface. + * Just use an adaptor. + */ + registerLifecycleListener( new LifecycleListener() { + @Override + public void beanManagerInitialized(BeanManager beanManager) { + lifecycleListener.beanManagerInitialized( beanManager ); + } + + @Override + public void beforeBeanManagerDestroyed(BeanManager beanManager) { + lifecycleListener.beforeBeanManagerDestroyed( beanManager ); + } + } ); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerBuilder.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerBuilder.java index 86f1decfdd..a9f0133a02 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerBuilder.java @@ -35,7 +35,7 @@ public class CdiBeanContainerBuilder { private static final String CONTAINER_FQN_DELAYED = "org.hibernate.resource.beans.container.internal.CdiBeanContainerDelayedAccessImpl"; private static final String CONTAINER_FQN_EXTENDED = "org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl"; - private static final String BEAN_MANAGER_EXTENSION_FQN = "org.hibernate.jpa.event.spi.jpa.ExtendedBeanManager"; + private static final String BEAN_MANAGER_EXTENSION_FQN = "org.hibernate.resource.beans.container.spi.ExtendedBeanManager"; @SuppressWarnings("unchecked") public static BeanContainer fromBeanManagerReference( diff --git a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerExtendedAccessImpl.java b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerExtendedAccessImpl.java index c05f44d14d..84356a03c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerExtendedAccessImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/beans/container/internal/CdiBeanContainerExtendedAccessImpl.java @@ -8,11 +8,11 @@ package org.hibernate.resource.beans.container.internal; import javax.enterprise.inject.spi.BeanManager; -import org.hibernate.jpa.event.spi.jpa.ExtendedBeanManager; import org.hibernate.resource.beans.container.spi.AbstractCdiBeanContainer; import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy; import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor; +import org.hibernate.resource.beans.container.spi.ExtendedBeanManager; import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.jboss.logging.Logger;