HHH-13309 Relax constraints on the accepted extended bean manager type

This commit is contained in:
Yoann Rodière 2019-03-11 09:16:22 +01:00
parent 8dbd6a234b
commit b79d0f9628
3 changed files with 20 additions and 3 deletions

View File

@ -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 );
}
} );
}
/**

View File

@ -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(

View File

@ -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;