org.hibernate.resource.beans.container.spi.BeanContainer Java Examples
The following examples show how to use
org.hibernate.resource.beans.container.spi.BeanContainer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByNameWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( "some name", NoDefinitionInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(0, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(1, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertEquals("some name", instance.getName()); assertNull(instance.getApplicationContext()); }
Example #2
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByTypeWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( NoDefinitionInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(1, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(0, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertNull(instance.getApplicationContext()); }
Example #3
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByNameWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( "some name", NoDefinitionInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(0, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(1, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertEquals("some name", instance.getName()); assertNull(instance.getApplicationContext()); }
Example #4
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByTypeWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( NoDefinitionInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(1, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(0, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertNull(instance.getApplicationContext()); }
Example #5
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByNameWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( "some name", NoDefinitionInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(0, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(1, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertEquals("some name", instance.getName()); assertNull(instance.getApplicationContext()); }
Example #6
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCanRetrieveBeanByNameWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<MultiplePrototypesInSpringContextTestBean> bean = beanContainer.getBean( "multiple-1", MultiplePrototypesInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); MultiplePrototypesInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals("multiple-1", instance.getName()); assertSame(applicationContext, instance.getApplicationContext()); }
Example #7
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testCanRetrieveBeanByTypeWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<SinglePrototypeInSpringContextTestBean> bean = beanContainer.getBean( SinglePrototypeInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); SinglePrototypeInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertSame(applicationContext, instance.getApplicationContext()); }
Example #8
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByTypeWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( NoDefinitionInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(1, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(0, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertNull(instance.getApplicationContext()); }
Example #9
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByNameWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( "some name", NoDefinitionInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(0, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(1, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertEquals("some name", instance.getName()); assertNull(instance.getApplicationContext()); }
Example #10
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCanRetrieveFallbackBeanByTypeWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); NoDefinitionInSpringContextTestBeanInstanceProducer fallbackProducer = new NoDefinitionInSpringContextTestBeanInstanceProducer(); ContainedBean<NoDefinitionInSpringContextTestBean> bean = beanContainer.getBean( NoDefinitionInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, fallbackProducer ); assertEquals(1, fallbackProducer.currentUnnamedInstantiationCount()); assertEquals(0, fallbackProducer.currentNamedInstantiationCount()); assertNotNull(bean); NoDefinitionInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals(BeanSource.FALLBACK, instance.getSource()); assertNull(instance.getApplicationContext()); }
Example #11
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testCanRetrieveBeanByNameWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<MultiplePrototypesInSpringContextTestBean> bean = beanContainer.getBean( "multiple-1", MultiplePrototypesInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); MultiplePrototypesInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals("multiple-1", instance.getName()); assertSame(applicationContext, instance.getApplicationContext()); }
Example #12
Source File: JpaCompliantLifecycleStrategy.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <B> ContainedBeanImplementor<B> createBean( String beanName, Class<B> beanClass, BeanInstanceProducer fallbackProducer, BeanContainer beanContainer) { return new NamedBeanImpl<>( beanName, beanClass, fallbackProducer, ( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager() ); }
Example #13
Source File: ManagedBeanRegistryInitiator.java From lams with GNU General Public License v2.0 | 5 votes |
private BeanContainer interpretExplicitBeanContainer( Object explicitSetting, ClassLoaderService classLoaderService, ServiceRegistryImplementor serviceRegistry) { if ( explicitSetting == null ) { return null; } if ( explicitSetting instanceof BeanContainer ) { return (BeanContainer) explicitSetting; } // otherwise we ultimately need to resolve this to a class final Class containerClass; if ( explicitSetting instanceof Class ) { containerClass = (Class) explicitSetting; } else { final String name = explicitSetting.toString(); // try the StrategySelector service final Class selected = serviceRegistry.getService( StrategySelector.class ) .selectStrategyImplementor( BeanContainer.class, name ); if ( selected != null ) { containerClass = selected; } else { containerClass = classLoaderService.classForName( name ); } } try { return (BeanContainer) containerClass.newInstance(); } catch (Exception e) { throw new InstantiationException( "Unable to instantiate specified BeanContainer : " + containerClass.getName(), containerClass, e ); } }
Example #14
Source File: ManagedBeanRegistryInitiator.java From lams with GNU General Public License v2.0 | 5 votes |
private BeanContainer resoveBeanContainer(Map configurationValues, ServiceRegistryImplementor serviceRegistry) { final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); final ConfigurationService cfgSvc = serviceRegistry.getService( ConfigurationService.class ); // was a specific container explicitly specified? final Object explicitBeanContainer = configurationValues.get( AvailableSettings.BEAN_CONTAINER ); if ( explicitBeanContainer != null ) { return interpretExplicitBeanContainer( explicitBeanContainer, classLoaderService, serviceRegistry ); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // simplified CDI support final boolean isCdiAvailable = isCdiAvailable( classLoaderService ); final Object beanManagerRef = cfgSvc.getSettings().get( AvailableSettings.CDI_BEAN_MANAGER ); if ( beanManagerRef != null ) { if ( !isCdiAvailable ) { BeansMessageLogger.BEANS_LOGGER.beanManagerButCdiNotAvailable( beanManagerRef ); } return CdiBeanContainerBuilder.fromBeanManagerReference( beanManagerRef, serviceRegistry ); } else { if ( isCdiAvailable ) { BeansMessageLogger.BEANS_LOGGER.noBeanManagerButCdiAvailable(); } } return null; }
Example #15
Source File: ContainerManagedLifecycleStrategy.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <B> ContainedBeanImplementor<B> createBean( Class<B> beanClass, BeanInstanceProducer fallbackProducer, BeanContainer beanContainer) { return new BeanImpl<>( beanClass, fallbackProducer, ( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager() ); }
Example #16
Source File: ContainerManagedLifecycleStrategy.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <B> ContainedBeanImplementor<B> createBean( String beanName, Class<B> beanClass, BeanInstanceProducer fallbackProducer, BeanContainer beanContainer) { return new NamedBeanImpl<>( beanName, beanClass, fallbackProducer, ( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager() ); }
Example #17
Source File: JpaCompliantLifecycleStrategy.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public <B> ContainedBeanImplementor<B> createBean( Class<B> beanClass, BeanInstanceProducer fallbackProducer, BeanContainer beanContainer) { return new BeanImpl<>( beanClass, fallbackProducer, ( (CdiBasedBeanContainer) beanContainer ).getUsableBeanManager() ); }
Example #18
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testCanRetrieveBeanByNameWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<MultiplePrototypesInSpringContextTestBean> bean = beanContainer.getBean( "multiple-1", MultiplePrototypesInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); MultiplePrototypesInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals("multiple-1", instance.getName()); assertSame(applicationContext, instance.getApplicationContext()); ContainedBean<MultiplePrototypesInSpringContextTestBean> bean2 = beanContainer.getBean( "multiple-1", MultiplePrototypesInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean2); MultiplePrototypesInSpringContextTestBean instance2 = bean2.getBeanInstance(); assertNotNull(instance2); // Due to the lifecycle options, and because the bean has the "prototype" scope, we should not return the same instance assertNotSame(instance, instance2); }
Example #19
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testCanRetrieveBeanByTypeWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<SinglePrototypeInSpringContextTestBean> bean = beanContainer.getBean( SinglePrototypeInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); SinglePrototypeInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals("single", instance.getName()); assertSame(applicationContext, instance.getApplicationContext()); ContainedBean<SinglePrototypeInSpringContextTestBean> bean2 = beanContainer.getBean( SinglePrototypeInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean2); SinglePrototypeInSpringContextTestBean instance2 = bean2.getBeanInstance(); assertNotNull(instance2); // Due to the lifecycle options, and because the bean has the "prototype" scope, we should not return the same instance assertNotSame(instance, instance2); }
Example #20
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testCanRetrieveBeanByNameWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<MultiplePrototypesInSpringContextTestBean> bean = beanContainer.getBean( "multiple-1", MultiplePrototypesInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); MultiplePrototypesInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals("multiple-1", instance.getName()); assertSame(applicationContext, instance.getApplicationContext()); ContainedBean<MultiplePrototypesInSpringContextTestBean> bean2 = beanContainer.getBean( "multiple-1", MultiplePrototypesInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean2); MultiplePrototypesInSpringContextTestBean instance2 = bean2.getBeanInstance(); assertNotNull(instance2); // Due to the lifecycle options, and because the bean has the "prototype" scope, we should not return the same instance assertNotSame(instance, instance2); }
Example #21
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testCanRetrieveBeanByTypeWithNativeOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<SinglePrototypeInSpringContextTestBean> bean = beanContainer.getBean( SinglePrototypeInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); SinglePrototypeInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertEquals("single", instance.getName()); assertSame(applicationContext, instance.getApplicationContext()); ContainedBean<SinglePrototypeInSpringContextTestBean> bean2 = beanContainer.getBean( SinglePrototypeInSpringContextTestBean.class, NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean2); SinglePrototypeInSpringContextTestBean instance2 = bean2.getBeanInstance(); assertNotNull(instance2); // Due to the lifecycle options, and because the bean has the "prototype" scope, we should not return the same instance assertNotSame(instance, instance2); }
Example #22
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testCanRetrieveBeanByTypeWithJpaCompliantOptions() { BeanContainer beanContainer = getBeanContainer(); assertNotNull(beanContainer); ContainedBean<SinglePrototypeInSpringContextTestBean> bean = beanContainer.getBean( SinglePrototypeInSpringContextTestBean.class, JpaLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE ); assertNotNull(bean); SinglePrototypeInSpringContextTestBean instance = bean.getBeanInstance(); assertNotNull(instance); assertSame(applicationContext, instance.getApplicationContext()); }
Example #23
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From java-technology-stack with MIT License | 4 votes |
private BeanContainer getBeanContainer() { return getManagedBeanRegistry().getBeanContainer(); }
Example #24
Source File: BeansMessageLogger.java From lams with GNU General Public License v2.0 | 4 votes |
@LogMessage( level = INFO ) @Message( id = 10005004, value = "Stopping BeanContainer : %s" ) void stoppingBeanContainer(BeanContainer beanContainer);
Example #25
Source File: ManagedBeanRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
public ManagedBeanRegistryImpl(BeanContainer beanContainer) { this.beanContainer = beanContainer; }
Example #26
Source File: ManagedBeanRegistryImpl.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public BeanContainer getBeanContainer() { return beanContainer; }
Example #27
Source File: HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests.java From spring-analysis-note with MIT License | 4 votes |
private BeanContainer getBeanContainer() { return getManagedBeanRegistry().getBeanContainer(); }
Example #28
Source File: ManagedBeanRegistry.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Get a reference to the underlying BeanContainer. May return {@code null} * indicating that no back-end container has been configured */ BeanContainer getBeanContainer();