Java Code Examples for org.hibernate.resource.beans.container.spi.ContainedBean#getBeanInstance()
The following examples show how to use
org.hibernate.resource.beans.container.spi.ContainedBean#getBeanInstance() .
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 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
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); }