HHH-12133 - Create ManagedBeanRegistry and ManagedBean

- addressed concerns discussed with Yoann
This commit is contained in:
Steve Ebersole 2018-01-17 11:43:59 -06:00
parent 521ee44f8e
commit f1263f8c7c
17 changed files with 227 additions and 184 deletions

View File

@ -8,11 +8,11 @@ package org.hibernate.resource.beans.container.internal;
import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.BeanManager;
import org.hibernate.resource.beans.container.spi.BeanContainerImplementor; import org.hibernate.resource.beans.container.spi.BeanContainer;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface CdiBasedBeanContainer extends BeanContainerImplementor { public interface CdiBasedBeanContainer extends BeanContainer {
BeanManager getUsableBeanManager(); BeanManager getUsableBeanManager();
} }

View File

@ -16,7 +16,7 @@ import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.config.spi.StandardConverters; import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.jpa.AvailableSettings; import org.hibernate.jpa.AvailableSettings;
import org.hibernate.resource.beans.container.spi.BeanContainerImplementor; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistryInitiator; import org.hibernate.resource.beans.spi.ManagedBeanRegistryInitiator;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
@ -38,14 +38,14 @@ public class CdiBeanContainerBuilder {
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.jpa.event.spi.jpa.ExtendedBeanManager";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static BeanContainerImplementor fromBeanManagerReference( public static BeanContainer fromBeanManagerReference(
Object beanManagerRef, Object beanManagerRef,
ServiceRegistry serviceRegistry) { ServiceRegistry serviceRegistry) {
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
final Class beanManagerClass = ManagedBeanRegistryInitiator.cdiBeanManagerClass( classLoaderService ); final Class beanManagerClass = ManagedBeanRegistryInitiator.cdiBeanManagerClass( classLoaderService );
final Class extendedBeanManagerClass = getHibernateClass( BEAN_MANAGER_EXTENSION_FQN ); final Class extendedBeanManagerClass = getHibernateClass( BEAN_MANAGER_EXTENSION_FQN );
final Class<? extends BeanContainerImplementor> containerClass; final Class<? extends BeanContainer> containerClass;
final Class ctorArgType; final Class ctorArgType;
if ( extendedBeanManagerClass.isInstance( beanManagerRef ) ) { if ( extendedBeanManagerClass.isInstance( beanManagerRef ) ) {
@ -66,7 +66,7 @@ public class CdiBeanContainerBuilder {
} }
try { try {
final Constructor<? extends BeanContainerImplementor> ctor = containerClass.getDeclaredConstructor( ctorArgType ); final Constructor<? extends BeanContainer> ctor = containerClass.getDeclaredConstructor( ctorArgType );
try { try {
ReflectHelper.ensureAccessibility( ctor ); ReflectHelper.ensureAccessibility( ctor );
return ctor.newInstance( ctorArgType.cast( beanManagerRef ) ); return ctor.newInstance( ctorArgType.cast( beanManagerRef ) );

View File

@ -10,7 +10,6 @@ import javax.enterprise.inject.spi.BeanManager;
import org.hibernate.resource.beans.container.spi.AbstractBeanContainer; import org.hibernate.resource.beans.container.spi.AbstractBeanContainer;
import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy; 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.ContainedBeanImplementor;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
@ -31,7 +30,7 @@ public class CdiBeanContainerDelayedAccessImpl extends AbstractBeanContainer {
} }
@Override @Override
protected <B> ContainedBean<B> createBean( protected <B> ContainedBeanImplementor<B> createBean(
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,
BeanInstanceProducer fallbackProducer) { BeanInstanceProducer fallbackProducer) {
@ -39,7 +38,7 @@ public class CdiBeanContainerDelayedAccessImpl extends AbstractBeanContainer {
} }
@Override @Override
protected <B> ContainedBean<B> createBean( protected <B> ContainedBeanImplementor<B> createBean(
String name, String name,
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,

View File

@ -13,7 +13,6 @@ import org.hibernate.resource.beans.container.spi.AbstractBeanContainer;
import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy; import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy;
import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor; import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor;
import org.hibernate.resource.beans.internal.Helper;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
@ -38,14 +37,12 @@ public class CdiBeanContainerExtendedAccessImpl
} }
@Override @Override
protected <B> ContainedBean<B> createBean( protected <B> ContainedBeanImplementor<B> createBean(
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,
BeanInstanceProducer fallbackProducer) { BeanInstanceProducer fallbackProducer) {
if ( usableBeanManager == null ) { if ( usableBeanManager == null ) {
final BeanImpl<B> bean = new BeanImpl<>( beanType, lifecycleStrategy, fallbackProducer ); return new BeanImpl<>( beanType, lifecycleStrategy, fallbackProducer );
registerContainedBean( beanType.getName(), bean );
return bean;
} }
else { else {
return lifecycleStrategy.createBean( beanType, fallbackProducer, this ); return lifecycleStrategy.createBean( beanType, fallbackProducer, this );
@ -53,20 +50,18 @@ public class CdiBeanContainerExtendedAccessImpl
} }
@Override @Override
protected <B> ContainedBean<B> createBean( protected <B> ContainedBeanImplementor<B> createBean(
String name, String name,
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,
BeanInstanceProducer fallbackProducer) { BeanInstanceProducer fallbackProducer) {
if ( usableBeanManager == null ) { if ( usableBeanManager == null ) {
final NamedBeanImpl<B> bean = new NamedBeanImpl<>( return new NamedBeanImpl<>(
name, name,
beanType, beanType,
lifecycleStrategy, lifecycleStrategy,
fallbackProducer fallbackProducer
); );
registerContainedBean( Helper.INSTANCE.determineBeanRegistrationKey( name, beanType), bean );
return bean;
} }
else { else {
return lifecycleStrategy.createBean( name, beanType, fallbackProducer, this ); return lifecycleStrategy.createBean( name, beanType, fallbackProducer, this );
@ -187,26 +182,22 @@ public class CdiBeanContainerExtendedAccessImpl
} }
@Override @Override
public ContainedBeanImplementor findRegistered(String key) { public <B> ContainedBean<B> getBean(
return CdiBeanContainerExtendedAccessImpl.this.findRegistered( key ); Class<B> beanType,
} LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) {
@Override // todo (5.3) : should this throw an exception instead?
public void registerContainedBean(String key, ContainedBeanImplementor bean) { return CdiBeanContainerExtendedAccessImpl.this.getBean( beanType, lifecycleOptions, fallbackProducer );
}
@Override
public <B> ContainedBean<B> getBean(Class<B> beanType, BeanLifecycleStrategy lifecycleStrategy, BeanInstanceProducer fallbackProducer) {
return CdiBeanContainerExtendedAccessImpl.this.getBean( beanType, lifecycleStrategy, fallbackProducer );
} }
@Override @Override
public <B> ContainedBean<B> getBean( public <B> ContainedBean<B> getBean(
String name, String beanName,
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) { BeanInstanceProducer fallbackProducer) {
return CdiBeanContainerExtendedAccessImpl.this.getBean( name, beanType, lifecycleStrategy, fallbackProducer ); // todo (5.3) : should this throw an exception instead?
return CdiBeanContainerExtendedAccessImpl.this.getBean( beanName, beanType, lifecycleOptions, fallbackProducer );
} }
@Override @Override

View File

@ -10,7 +10,6 @@ import javax.enterprise.inject.spi.BeanManager;
import org.hibernate.resource.beans.container.spi.AbstractBeanContainer; import org.hibernate.resource.beans.container.spi.AbstractBeanContainer;
import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy; 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.ContainedBeanImplementor;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
@ -36,23 +35,17 @@ public class CdiBeanContainerImmediateAccessImpl extends AbstractBeanContainer {
} }
@Override @Override
protected <B> ContainedBean<B> createBean( protected <B> ContainedBeanImplementor<B> createBean(
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,
BeanInstanceProducer fallbackProducer) { BeanInstanceProducer fallbackProducer) {
final ContainedBeanImplementor<B> bean = lifecycleStrategy.createBean( final ContainedBeanImplementor<B> bean = lifecycleStrategy.createBean( beanType, fallbackProducer, this );
beanType,
fallbackProducer,
this
);
bean.initialize(); bean.initialize();
return bean; return bean;
} }
@Override @Override
protected <B> ContainedBean<B> createBean( protected <B> ContainedBeanImplementor<B> createBean(
String name, String name,
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,
@ -63,9 +56,7 @@ public class CdiBeanContainerImmediateAccessImpl extends AbstractBeanContainer {
fallbackProducer, fallbackProducer,
this this
); );
bean.initialize(); bean.initialize();
return bean; return bean;
} }
} }

View File

@ -10,7 +10,7 @@ import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.inject.Instance; import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.BeanManager;
import org.hibernate.resource.beans.container.spi.BeanContainerImplementor; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy; import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy;
import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor; import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
@ -36,27 +36,13 @@ public class ContainerManagedLifecycleStrategy implements BeanLifecycleStrategy
// private constructor, do not use // private constructor, do not use
} }
@Override
public <B> ContainedBeanImplementor<B> findRegisteredBean(
Class<B> beanClass,
BeanContainerImplementor container) {
return null;
}
@Override
public <B> ContainedBeanImplementor<B> findRegisteredBean(
String beanName,
Class<B> beanClass,
BeanContainerImplementor container) {
return null;
}
@Override @Override
public <B> ContainedBeanImplementor<B> createBean( public <B> ContainedBeanImplementor<B> createBean(
Class<B> beanClass, Class<B> beanClass,
BeanInstanceProducer fallbackProducer, BeanInstanceProducer fallbackProducer,
BeanContainerImplementor container) { BeanContainer beanContainer) {
return new BeanImpl<>( beanClass, fallbackProducer, ( (CdiBasedBeanContainer) container ).getUsableBeanManager() ); return new BeanImpl<>( beanClass, fallbackProducer, ( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager() );
} }
@Override @Override
@ -64,8 +50,8 @@ public class ContainerManagedLifecycleStrategy implements BeanLifecycleStrategy
String beanName, String beanName,
Class<B> beanClass, Class<B> beanClass,
BeanInstanceProducer fallbackProducer, BeanInstanceProducer fallbackProducer,
BeanContainerImplementor container) { BeanContainer beanContainer) {
return new NamedBeanImpl<>( beanName, beanClass, fallbackProducer, ( (CdiBasedBeanContainer) container ).getUsableBeanManager() ); return new NamedBeanImpl<>( beanName, beanClass, fallbackProducer, ( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager() );
} }

View File

@ -13,7 +13,7 @@ import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.InjectionTarget; import javax.enterprise.inject.spi.InjectionTarget;
import org.hibernate.resource.beans.container.spi.BeanContainerImplementor; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy; import org.hibernate.resource.beans.container.spi.BeanLifecycleStrategy;
import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor; import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
@ -41,31 +41,16 @@ public class JpaCompliantLifecycleStrategy implements BeanLifecycleStrategy {
// private constructor, do not use // private constructor, do not use
} }
@Override
@SuppressWarnings("unchecked")
public <B> ContainedBeanImplementor<B> findRegisteredBean(
Class<B> beanClass,
BeanContainerImplementor container) {
return container.findRegistered( beanClass.getName() );
}
@Override
@SuppressWarnings("unchecked")
public <B> ContainedBeanImplementor<B> findRegisteredBean(
String beanName,
Class<B> beanClass,
BeanContainerImplementor container) {
return container.findRegistered( beanClass.getName() + ':' + beanName );
}
@Override @Override
public <B> ContainedBeanImplementor<B> createBean( public <B> ContainedBeanImplementor<B> createBean(
Class<B> beanClass, Class<B> beanClass,
BeanInstanceProducer fallbackProducer, BeanInstanceProducer fallbackProducer,
BeanContainerImplementor container) { BeanContainer beanContainer) {
final BeanImpl<B> bean = new BeanImpl<>( beanClass, fallbackProducer, ( (CdiBasedBeanContainer) container ).getUsableBeanManager() ); return new BeanImpl<>(
container.registerContainedBean( beanClass.getName(), bean ); beanClass,
return bean; fallbackProducer,
( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager()
);
} }
@Override @Override
@ -73,12 +58,17 @@ public class JpaCompliantLifecycleStrategy implements BeanLifecycleStrategy {
String beanName, String beanName,
Class<B> beanClass, Class<B> beanClass,
BeanInstanceProducer fallbackProducer, BeanInstanceProducer fallbackProducer,
BeanContainerImplementor container) { BeanContainer beanContainer) {
final NamedBeanImpl<B> bean = new NamedBeanImpl<>( beanName, beanClass, fallbackProducer, ( (CdiBasedBeanContainer) container ).getUsableBeanManager() ); return new NamedBeanImpl<>(
container.registerContainedBean( beanClass.getName(), bean ); beanName,
return bean; beanClass,
fallbackProducer,
( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager()
);
} }
private static class BeanImpl<B> implements ContainedBeanImplementor<B> { private static class BeanImpl<B> implements ContainedBeanImplementor<B> {
private final Class<B> beanType; private final Class<B> beanType;

View File

@ -6,65 +6,128 @@
*/ */
package org.hibernate.resource.beans.container.spi; package org.hibernate.resource.beans.container.spi;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.resource.beans.container.internal.CdiBasedBeanContainer; import org.hibernate.resource.beans.container.internal.CdiBasedBeanContainer;
import org.hibernate.resource.beans.container.internal.ContainerManagedLifecycleStrategy;
import org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy;
import org.hibernate.resource.beans.internal.BeansMessageLogger; import org.hibernate.resource.beans.internal.BeansMessageLogger;
import org.hibernate.resource.beans.internal.Helper;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public abstract class AbstractBeanContainer implements CdiBasedBeanContainer { public abstract class AbstractBeanContainer implements CdiBasedBeanContainer {
private Map<String,ContainedBeanImplementor<?>> registrations = new HashMap<>(); private Map<String,ContainedBeanImplementor<?>> beanCache = new HashMap<>();
private List<ContainedBeanImplementor<?>> registeredBeans = new ArrayList<>();
@Override @Override
public final void registerContainedBean(String key, ContainedBeanImplementor bean) { public <B> ContainedBean<B> getBean(
registrations.put( key, bean );
}
@Override
public final ContainedBeanImplementor findRegistered(String key) {
return registrations.get( key );
}
@Override
@SuppressWarnings("unchecked")
public final <B> ContainedBean<B> getBean(
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) { BeanInstanceProducer fallbackProducer) {
final ContainedBean existing = lifecycleStrategy.findRegisteredBean( beanType, this ); if ( lifecycleOptions.canUseCachedReferences() ) {
return getCacheableBean( beanType, lifecycleOptions, fallbackProducer );
}
else {
return createBean( beanType, lifecycleOptions, fallbackProducer );
}
}
@SuppressWarnings("unchecked")
private <B> ContainedBean<B> getCacheableBean(
Class<B> beanType,
LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) {
final String beanCacheKey = Helper.INSTANCE.determineBeanCacheKey( beanType );
final ContainedBeanImplementor existing = beanCache.get( beanCacheKey );
if ( existing != null ) { if ( existing != null ) {
return existing; return existing;
} }
return createBean( beanType, lifecycleStrategy, fallbackProducer ); final ContainedBeanImplementor bean = createBean( beanType, lifecycleOptions, fallbackProducer );
beanCache.put( beanCacheKey, bean );
return bean;
} }
protected abstract <B> ContainedBean<B> createBean( @SuppressWarnings("unchecked")
private <B> ContainedBeanImplementor<B> createBean(
Class<B> beanType,
LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) {
final ContainedBeanImplementor bean = createBean(
beanType,
lifecycleOptions.useJpaCompliantCreation()
? JpaCompliantLifecycleStrategy.INSTANCE
: ContainerManagedLifecycleStrategy.INSTANCE,
fallbackProducer
);
registeredBeans.add( bean );
return bean;
}
protected abstract <B> ContainedBeanImplementor<B> createBean(
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,
BeanInstanceProducer fallbackProducer); BeanInstanceProducer fallbackProducer);
@Override @Override
@SuppressWarnings("unchecked") public <B> ContainedBean<B> getBean(
public final <B> ContainedBean<B> getBean( String beanName,
String name,
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) { BeanInstanceProducer fallbackProducer) {
final ContainedBean existing = lifecycleStrategy.findRegisteredBean( name, beanType, this ); if ( lifecycleOptions.canUseCachedReferences() ) {
return getCacheableBean( beanName, beanType, lifecycleOptions, fallbackProducer );
}
else {
return createBean( beanName, beanType, lifecycleOptions, fallbackProducer );
}
}
@SuppressWarnings("unchecked")
private <B> ContainedBeanImplementor<B> getCacheableBean(
String beanName,
Class<B> beanType,
LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) {
final String beanCacheKey = Helper.INSTANCE.determineBeanCacheKey( beanName, beanType );
final ContainedBeanImplementor existing = beanCache.get( beanCacheKey );
if ( existing != null ) { if ( existing != null ) {
return existing; return existing;
} }
return createBean( name, beanType, lifecycleStrategy, fallbackProducer ); final ContainedBeanImplementor bean = createBean( beanName, beanType, lifecycleOptions, fallbackProducer );
beanCache.put( beanCacheKey, bean );
return bean;
} }
protected abstract <B> ContainedBean<B> createBean( @SuppressWarnings("unchecked")
private <B> ContainedBeanImplementor<B> createBean(
String beanName,
Class<B> beanType,
LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer) {
final ContainedBeanImplementor bean = createBean(
beanName,
beanType,
lifecycleOptions.useJpaCompliantCreation()
? JpaCompliantLifecycleStrategy.INSTANCE
: ContainerManagedLifecycleStrategy.INSTANCE,
fallbackProducer
);
registeredBeans.add( bean );
return bean;
}
protected abstract <B> ContainedBeanImplementor<B> createBean(
String name, String name,
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, BeanLifecycleStrategy lifecycleStrategy,
@ -73,14 +136,15 @@ public abstract class AbstractBeanContainer implements CdiBasedBeanContainer {
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
protected final void forEachBean(Consumer<ContainedBeanImplementor<?>> consumer) { protected final void forEachBean(Consumer<ContainedBeanImplementor<?>> consumer) {
registrations.values().forEach( consumer ); registeredBeans.forEach( consumer );
} }
@Override @Override
public final void stop() { public final void stop() {
BeansMessageLogger.BEANS_LOGGER.stoppingBeanContainer( this ); BeansMessageLogger.BEANS_LOGGER.stoppingBeanContainer( this );
forEachBean( ContainedBeanImplementor::release ); forEachBean( ContainedBeanImplementor::release );
registrations.clear(); registeredBeans.clear();
beanCache.clear();
} }
} }

View File

@ -15,14 +15,19 @@ import org.hibernate.service.spi.Stoppable;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface BeanContainer extends Stoppable { public interface BeanContainer extends Stoppable {
interface LifecycleOptions {
boolean canUseCachedReferences();
boolean useJpaCompliantCreation();
}
<B> ContainedBean<B> getBean( <B> ContainedBean<B> getBean(
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer); BeanInstanceProducer fallbackProducer);
<B> ContainedBean<B> getBean( <B> ContainedBean<B> getBean(
String name, String name,
Class<B> beanType, Class<B> beanType,
BeanLifecycleStrategy lifecycleStrategy, LifecycleOptions lifecycleOptions,
BeanInstanceProducer fallbackProducer); BeanInstanceProducer fallbackProducer);
} }

View File

@ -1,15 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
*/
package org.hibernate.resource.beans.container.spi;
/**
* @author Steve Ebersole
*/
public interface BeanContainerImplementor extends BeanContainer {
ContainedBeanImplementor findRegistered(String key);
void registerContainedBean(String key, ContainedBeanImplementor bean);
}

View File

@ -6,27 +6,20 @@
*/ */
package org.hibernate.resource.beans.container.spi; package org.hibernate.resource.beans.container.spi;
import javax.enterprise.inject.spi.BeanManager;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
/** /**
* Models how the lifecycle for a bean should be managed. * Models how the lifecycle for a bean should be managed.
*/ */
public interface BeanLifecycleStrategy { public interface BeanLifecycleStrategy {
<B> ContainedBeanImplementor<B> findRegisteredBean(Class<B> beanClass, BeanContainerImplementor container);
<B> ContainedBeanImplementor<B> findRegisteredBean(String beanName, Class<B> beanClass, BeanContainerImplementor container);
<B> ContainedBeanImplementor<B> createBean( <B> ContainedBeanImplementor<B> createBean(
Class<B> beanClass, Class<B> beanClass,
BeanInstanceProducer fallbackProducer, BeanInstanceProducer fallbackProducer,
BeanContainerImplementor container); BeanContainer beanContainer);
<B> ContainedBeanImplementor<B> createBean( <B> ContainedBeanImplementor<B> createBean(
String beanName, String beanName,
Class<B> beanClass, Class<B> beanClass,
BeanInstanceProducer fallbackProducer, BeanInstanceProducer fallbackProducer,
BeanContainerImplementor container); BeanContainer beanContainer);
} }

View File

@ -22,11 +22,11 @@ public class Helper {
private Helper() { private Helper() {
} }
public String determineBeanRegistrationKey(Class beanType) { public String determineBeanCacheKey(Class beanType) {
return beanType.getName(); return beanType.getName();
} }
public String determineBeanRegistrationKey(String name, Class beanType) { public String determineBeanCacheKey(String name, Class beanType) {
return beanType.getName() + ':' + name; return beanType.getName() + ':' + name;
} }

View File

@ -8,9 +8,7 @@ package org.hibernate.resource.beans.internal;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer;
import org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy;
import org.hibernate.resource.beans.container.spi.BeanContainer; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.container.spi.FallbackContainedBean; import org.hibernate.resource.beans.container.spi.FallbackContainedBean;
@ -23,7 +21,7 @@ import org.hibernate.service.spi.Stoppable;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class ManagedBeanRegistryImpl implements ManagedBeanRegistry, Stoppable { public class ManagedBeanRegistryImpl implements ManagedBeanRegistry, BeanContainer.LifecycleOptions, Stoppable {
private Map<String,ManagedBean<?>> registrations = new HashMap<>(); private Map<String,ManagedBean<?>> registrations = new HashMap<>();
private final BeanContainer beanContainer; private final BeanContainer beanContainer;
@ -37,6 +35,16 @@ public class ManagedBeanRegistryImpl implements ManagedBeanRegistry, Stoppable {
return beanContainer; return beanContainer;
} }
@Override
public boolean canUseCachedReferences() {
return true;
}
@Override
public boolean useJpaCompliantCreation() {
return true;
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T> ManagedBean<T> getBean(Class<T> beanClass) { public <T> ManagedBean<T> getBean(Class<T> beanClass) {
@ -52,7 +60,7 @@ public class ManagedBeanRegistryImpl implements ManagedBeanRegistry, Stoppable {
else { else {
final ContainedBean<T> containedBean = beanContainer.getBean( final ContainedBean<T> containedBean = beanContainer.getBean(
beanClass, beanClass,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );
@ -87,7 +95,7 @@ public class ManagedBeanRegistryImpl implements ManagedBeanRegistry, Stoppable {
final ContainedBean<T> containedBean = beanContainer.getBean( final ContainedBean<T> containedBean = beanContainer.getBean(
beanName, beanName,
beanContract, beanContract,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );
@ -104,11 +112,6 @@ public class ManagedBeanRegistryImpl implements ManagedBeanRegistry, Stoppable {
return bean; return bean;
} }
@SuppressWarnings("WeakerAccess")
protected void forEachBean(Consumer<ManagedBean<?>> consumer) {
registrations.values().forEach( consumer );
}
@Override @Override
public void stop() { public void stop() {
if ( beanContainer != null ) { if ( beanContainer != null ) {
@ -121,7 +124,7 @@ public class ManagedBeanRegistryImpl implements ManagedBeanRegistry, Stoppable {
private final Class<B> beanClass; private final Class<B> beanClass;
private final ContainedBean<B> containedBean; private final ContainedBean<B> containedBean;
public ContainedBeanManagedBeanAdapter(Class<B> beanClass, ContainedBean<B> containedBean) { private ContainedBeanManagedBeanAdapter(Class<B> beanClass, ContainedBean<B> containedBean) {
this.beanClass = beanClass; this.beanClass = beanClass;
this.containedBean = containedBean; this.containedBean = containedBean;
} }

View File

@ -16,8 +16,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.jpa.event.spi.JpaIntegrator; import org.hibernate.jpa.event.spi.JpaIntegrator;
import org.hibernate.resource.beans.container.internal.CdiBeanContainerBuilder; import org.hibernate.resource.beans.container.internal.CdiBeanContainerBuilder;
import org.hibernate.resource.beans.container.internal.CdiBeanContainerDelayedAccessImpl; import org.hibernate.resource.beans.container.internal.CdiBeanContainerDelayedAccessImpl;
import org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.BeanContainerImplementor;
import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer; import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.tool.schema.Action; import org.hibernate.tool.schema.Action;
@ -31,7 +30,17 @@ import static org.hamcrest.MatcherAssert.assertThat;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class DelayedMixedAccessTest { public class DelayedMixedAccessTest implements BeanContainer.LifecycleOptions {
@Override
public boolean canUseCachedReferences() {
return true;
}
@Override
public boolean useJpaCompliantCreation() {
return true;
}
@Test @Test
public void testDelayedMixedAccess() { public void testDelayedMixedAccess() {
try ( final SeContainer cdiContainer = Helper.createSeContainer() ) { try ( final SeContainer cdiContainer = Helper.createSeContainer() ) {
@ -45,7 +54,7 @@ public class DelayedMixedAccessTest {
.applySetting( AvailableSettings.DELAY_CDI_ACCESS, "true" ) .applySetting( AvailableSettings.DELAY_CDI_ACCESS, "true" )
.build(); .build();
final BeanContainerImplementor beanContainer = CdiBeanContainerBuilder.fromBeanManagerReference( final BeanContainer beanContainer = CdiBeanContainerBuilder.fromBeanManagerReference(
cdiContainer.getBeanManager(), cdiContainer.getBeanManager(),
ssr ssr
); );
@ -54,7 +63,7 @@ public class DelayedMixedAccessTest {
final ContainedBean<HostedBean> hostedBean = beanContainer.getBean( final ContainedBean<HostedBean> hostedBean = beanContainer.getBean(
HostedBean.class, HostedBean.class,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );
@ -65,7 +74,7 @@ public class DelayedMixedAccessTest {
final ContainedBean<NonHostedBean> nonHostedBean = beanContainer.getBean( final ContainedBean<NonHostedBean> nonHostedBean = beanContainer.getBean(
NonHostedBean.class, NonHostedBean.class,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );

View File

@ -13,7 +13,6 @@ import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl; import org.hibernate.resource.beans.container.internal.CdiBeanContainerExtendedAccessImpl;
import org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy;
import org.hibernate.resource.beans.container.spi.BeanContainer; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer; import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
@ -30,7 +29,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class ExtendedMixedAccessTest { public class ExtendedMixedAccessTest implements BeanContainer.LifecycleOptions {
@Test @Test
public void testExtendedMixedAccess() { public void testExtendedMixedAccess() {
final Helper.TestingExtendedBeanManager extendedBeanManager = Helper.createExtendedBeanManager(); final Helper.TestingExtendedBeanManager extendedBeanManager = Helper.createExtendedBeanManager();
@ -52,7 +51,7 @@ public class ExtendedMixedAccessTest {
final ContainedBean<HostedBean> hostedBean = beanContainer.getBean( final ContainedBean<HostedBean> hostedBean = beanContainer.getBean(
HostedBean.class, HostedBean.class,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );
@ -63,7 +62,7 @@ public class ExtendedMixedAccessTest {
final ContainedBean<NonHostedBean> nonHostedBean = beanContainer.getBean( final ContainedBean<NonHostedBean> nonHostedBean = beanContainer.getBean(
NonHostedBean.class, NonHostedBean.class,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );
@ -73,4 +72,14 @@ public class ExtendedMixedAccessTest {
extendedBeanManager.notifyListenerShuttingDown( beanManager ); extendedBeanManager.notifyListenerShuttingDown( beanManager );
} }
} }
@Override
public boolean canUseCachedReferences() {
return true;
}
@Override
public boolean useJpaCompliantCreation() {
return true;
}
} }

View File

@ -17,7 +17,7 @@ import org.hibernate.jpa.event.spi.JpaIntegrator;
import org.hibernate.resource.beans.container.internal.CdiBeanContainerBuilder; import org.hibernate.resource.beans.container.internal.CdiBeanContainerBuilder;
import org.hibernate.resource.beans.container.internal.CdiBeanContainerImmediateAccessImpl; import org.hibernate.resource.beans.container.internal.CdiBeanContainerImmediateAccessImpl;
import org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy; import org.hibernate.resource.beans.container.internal.JpaCompliantLifecycleStrategy;
import org.hibernate.resource.beans.container.spi.BeanContainerImplementor; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer; import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.tool.schema.Action; import org.hibernate.tool.schema.Action;
@ -33,7 +33,17 @@ import static org.hamcrest.MatcherAssert.assertThat;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class ImmediateMixedAccessTests { public class ImmediateMixedAccessTests implements BeanContainer.LifecycleOptions {
@Override
public boolean canUseCachedReferences() {
return true;
}
@Override
public boolean useJpaCompliantCreation() {
return true;
}
@Test @Test
public void testImmediateMixedAccess() { public void testImmediateMixedAccess() {
try ( final SeContainer cdiContainer = Helper.createSeContainer() ) { try ( final SeContainer cdiContainer = Helper.createSeContainer() ) {
@ -46,7 +56,7 @@ public class ImmediateMixedAccessTests {
.applySetting( AvailableSettings.CDI_BEAN_MANAGER, cdiContainer.getBeanManager() ) .applySetting( AvailableSettings.CDI_BEAN_MANAGER, cdiContainer.getBeanManager() )
.build(); .build();
final BeanContainerImplementor beanContainer = CdiBeanContainerBuilder.fromBeanManagerReference( final BeanContainer beanContainer = CdiBeanContainerBuilder.fromBeanManagerReference(
cdiContainer.getBeanManager(), cdiContainer.getBeanManager(),
ssr ssr
); );
@ -55,7 +65,7 @@ public class ImmediateMixedAccessTests {
final ContainedBean<HostedBean> hostedBean = beanContainer.getBean( final ContainedBean<HostedBean> hostedBean = beanContainer.getBean(
HostedBean.class, HostedBean.class,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );
@ -66,7 +76,7 @@ public class ImmediateMixedAccessTests {
final ContainedBean<NonHostedBean> nonHostedBean = beanContainer.getBean( final ContainedBean<NonHostedBean> nonHostedBean = beanContainer.getBean(
NonHostedBean.class, NonHostedBean.class,
JpaCompliantLifecycleStrategy.INSTANCE, this,
FallbackBeanInstanceProducer.INSTANCE FallbackBeanInstanceProducer.INSTANCE
); );

View File

@ -9,11 +9,9 @@ package org.hibernate.test.cdi.general.nonregistrymanaged;
import org.hibernate.boot.Metadata; import org.hibernate.boot.Metadata;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.integrator.spi.Integrator; import org.hibernate.integrator.spi.Integrator;
import org.hibernate.resource.beans.container.internal.ContainerManagedLifecycleStrategy;
import org.hibernate.resource.beans.container.spi.BeanContainer; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor; import org.hibernate.resource.beans.container.spi.ContainedBeanImplementor;
import org.hibernate.resource.beans.container.spi.ExtendedBeanManager; import org.hibernate.resource.beans.container.spi.ExtendedBeanManager;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.spi.BeanInstanceProducer; import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.service.spi.SessionFactoryServiceRegistry; import org.hibernate.service.spi.SessionFactoryServiceRegistry;
@ -28,7 +26,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
* *
* @author Yoann Rodiere * @author Yoann Rodiere
*/ */
public class NonRegistryManagedBeanConsumingIntegrator implements Integrator { public class NonRegistryManagedBeanConsumingIntegrator implements Integrator, BeanContainer.LifecycleOptions {
private final BeanInstanceProducer fallbackBeanInstanceProducer; private final BeanInstanceProducer fallbackBeanInstanceProducer;
@ -49,6 +47,16 @@ public class NonRegistryManagedBeanConsumingIntegrator implements Integrator {
this.fallbackBeanInstanceProducer = fallbackBeanInstanceProducer; this.fallbackBeanInstanceProducer = fallbackBeanInstanceProducer;
} }
@Override
public boolean canUseCachedReferences() {
return false;
}
@Override
public boolean useJpaCompliantCreation() {
return false;
}
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) { public void integrate(Metadata metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
@ -60,68 +68,68 @@ public class NonRegistryManagedBeanConsumingIntegrator implements Integrator {
applicationScopedBean1 = (ContainedBeanImplementor) beanContainer.getBean( applicationScopedBean1 = (ContainedBeanImplementor) beanContainer.getBean(
TheApplicationScopedBean.class, TheApplicationScopedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
applicationScopedBean2 = (ContainedBeanImplementor) beanContainer.getBean( applicationScopedBean2 = (ContainedBeanImplementor) beanContainer.getBean(
TheApplicationScopedBean.class, TheApplicationScopedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
dependentBean1 = (ContainedBeanImplementor) beanContainer.getBean( dependentBean1 = (ContainedBeanImplementor) beanContainer.getBean(
TheDependentBean.class, TheDependentBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
dependentBean2 = (ContainedBeanImplementor) beanContainer.getBean( dependentBean2 = (ContainedBeanImplementor) beanContainer.getBean(
TheDependentBean.class, TheDependentBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
reflectionInstantiatedBean1 = (ContainedBeanImplementor) beanContainer.getBean( reflectionInstantiatedBean1 = (ContainedBeanImplementor) beanContainer.getBean(
TheReflectionInstantiatedBean.class, TheReflectionInstantiatedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
reflectionInstantiatedBean2 = (ContainedBeanImplementor) beanContainer.getBean( reflectionInstantiatedBean2 = (ContainedBeanImplementor) beanContainer.getBean(
TheReflectionInstantiatedBean.class, TheReflectionInstantiatedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
namedApplicationScopedBean1 = (ContainedBeanImplementor) beanContainer.getBean( namedApplicationScopedBean1 = (ContainedBeanImplementor) beanContainer.getBean(
TheMainNamedApplicationScopedBeanImpl.NAME, TheMainNamedApplicationScopedBeanImpl.NAME,
TheNamedApplicationScopedBean.class, TheNamedApplicationScopedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
namedApplicationScopedBean2 = (ContainedBeanImplementor) beanContainer.getBean( namedApplicationScopedBean2 = (ContainedBeanImplementor) beanContainer.getBean(
TheMainNamedApplicationScopedBeanImpl.NAME, TheMainNamedApplicationScopedBeanImpl.NAME,
TheNamedApplicationScopedBean.class, TheNamedApplicationScopedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
namedDependentBean1 = (ContainedBeanImplementor) beanContainer.getBean( namedDependentBean1 = (ContainedBeanImplementor) beanContainer.getBean(
TheMainNamedDependentBeanImpl.NAME, TheMainNamedDependentBeanImpl.NAME,
TheNamedDependentBean.class, TheNamedDependentBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
namedDependentBean2 = (ContainedBeanImplementor) beanContainer.getBean( namedDependentBean2 = (ContainedBeanImplementor) beanContainer.getBean(
TheMainNamedDependentBeanImpl.NAME, TheMainNamedDependentBeanImpl.NAME,
TheNamedDependentBean.class, TheNamedDependentBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
namedReflectionInstantiatedBean1 = (ContainedBeanImplementor) beanContainer.getBean( namedReflectionInstantiatedBean1 = (ContainedBeanImplementor) beanContainer.getBean(
TheReflectionInstantiatedBean.class.getName(), TheReflectionInstantiatedBean.class.getName(),
TheReflectionInstantiatedBean.class, TheReflectionInstantiatedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
namedReflectionInstantiatedBean2 = (ContainedBeanImplementor) beanContainer.getBean( namedReflectionInstantiatedBean2 = (ContainedBeanImplementor) beanContainer.getBean(
TheReflectionInstantiatedBean.class.getName(), TheReflectionInstantiatedBean.class.getName(),
TheReflectionInstantiatedBean.class, TheReflectionInstantiatedBean.class,
ContainerManagedLifecycleStrategy.INSTANCE, this,
fallbackBeanInstanceProducer fallbackBeanInstanceProducer
); );
} }