BeanContainer SPI,
delegating to a Spring ConfigurableListableBeanFactory.
Auto-configured by LocalSessionFactoryBean#setBeanFactory,
programmatically supported via LocalSessionFactoryBuilder#setBeanContainer,
and manually configurable through a "hibernate.resource.beans.container" entry
in JPA properties, e.g.:
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
...
<property name="jpaPropertyMap">
<map>
<entry key="hibernate.resource.beans.container">
<bean class="org.springframework.orm.hibernate5.SpringBeanContainer"/>
</entry>
</map>
</property>
</bean>
Or in Java-based JPA configuration:
LocalContainerEntityManagerFactoryBean emfb = ... emfb.getJpaPropertyMap().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory));Please note that Spring's
LocalSessionFactoryBean is an immediate alternative
to org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean for
common JPA purposes: The Hibernate SessionFactory will natively expose the JPA
EntityManagerFactory interface as well, and Hibernate BeanContainer
integration will be registered out of the box.
LocalSessionFactoryBean#setBeanFactory, LocalSessionFactoryBuilder#setBeanContainer, org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean#setJpaPropertyMap , org.hibernate.cfg.AvailableSettings#BEAN_CONTAINER
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final ConfigurableListableBeanFactory | |
| private static final Log |
| Access | Constructor and Description |
|---|---|
| public | SpringBeanContainer(ConfigurableListableBeanFactory
the Spring bean factory to delegate to beanFactory)Instantiate a new SpringBeanContainer for the given bean factory. |
| Modifier and Type | Method and Description |
|---|---|
| private SpringBeanContainer. | createBean(Class<?> beanType, BeanContainer.
|
| private SpringBeanContainer. | createBean(String name, Class<?> beanType, BeanContainer.
|
| public <B> ContainedBean | getBean(Class<B> beanType, BeanContainer.
Implements org. |
| public <B> ContainedBean | getBean(String name, Class<B> beanType, BeanContainer.
Implements org. |
| public void |
| beanCache | back to summary |
|---|---|
| private final Map<Object, SpringBeanContainer. | |
| beanFactory | back to summary |
|---|---|
| private final ConfigurableListableBeanFactory beanFactory | |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| SpringBeanContainer | back to summary |
|---|---|
| public SpringBeanContainer(ConfigurableListableBeanFactory beanFactory) Instantiate a new SpringBeanContainer for the given bean factory.
| |
| createBean | back to summary |
|---|---|
| private SpringBeanContainer. | |
| createBean | back to summary |
|---|---|
| private SpringBeanContainer. | |
| getBean | back to summary |
|---|---|
| public <B> ContainedBean Implements org.
| |
| getBean | back to summary |
|---|---|
| public <B> ContainedBean Implements org.
| |
| stop | back to summary |
|---|---|
| public void stop() Implements org. Doc from org. Stop phase notification
| |
| Modifier and Type | Field and Description |
|---|---|
| private final B | |
| private Consumer |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public B | getBeanInstance()
Implements org. |
| beanInstance | back to summary |
|---|---|
| private final B beanInstance | |
| destructionCallback | back to summary |
|---|---|
| private Consumer<B> destructionCallback
| |
| SpringContainedBean | back to summary |
|---|---|
| public SpringContainedBean(B beanInstance) | |
| SpringContainedBean | back to summary |
|---|---|
| public SpringContainedBean(B beanInstance, Consumer<B> destructionCallback) | |
| destroyIfNecessary | back to summary |
|---|---|
| public void destroyIfNecessary() | |
| getBeanInstance | back to summary |
|---|---|
| public B getBeanInstance() Implements org. Doc from org. Get the bean instance producer associated with this container-backed bean
| |