...
And include that at the top of your spring xml file as follows:
Code Block |
---|
| xml | xml |
---|
title | top of spring xml |
---|
| xml |
---|
|
<bean id="OpenEjbContext" class="org.acme.OpenEjbFactoryBean">
<property name="jndiEnvironment">
<props>
<prop key="myDs">new://Resource?type=DataSource</prop>
<prop key="myDs.JdbcDriver">com.mysql.jdbc.Driver</prop>
<prop key="myDs.JdbcUrl">jdbc:mysql://localhost/midastest?createDatabaseIfNotExist=true</prop>
<prop key="myDs.UserName">root</prop>
<prop key="myDs.Password"></prop>
</props>
</property>
</bean>
|
...
The factory bean would then be declared in your spring xml file as follows:
Code Block |
xml |
---|
| xml |
---|
title | in the spring xml |
---|
| xml |
---|
|
<bean id="OrangeUnit" class="org.acme.OrangeUnitFactoryBean">
<property name="context" ref="OpenEjbContext">
</bean>
|
...
Code Block |
---|
|
public class SomePojo {
private EntityManager entityManager;
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
...
}
|
Code Block |
---|
| xml | xml |
---|
title | in the spring xml |
---|
| xml |
---|
|
<bean id="SomePojo" class="org.acme.SomePojo">
<property name="entityManager" ref="OrangeUnit">
</bean>
|
Here's what all three declarations would look like together in your spring xml:
Code Block |
---|
| xml | xml |
---|
title | spring bean definitions combined |
---|
| xml |
---|
|
<bean id="OpenEjbContext" class="org.acme.OpenEjbFactoryBean">
<property name="jndiEnvironment">
<props>
<prop key="myDs">new://Resource?type=DataSource</prop>
<prop key="myDs.JdbcDriver">com.mysql.jdbc.Driver</prop>
<prop key="myDs.JdbcUrl">jdbc:mysql://localhost/midastest?createDatabaseIfNotExist=true</prop>
<prop key="myDs.UserName">root</prop>
<prop key="myDs.Password"></prop>
</props>
</property>
</bean>
<bean id="OrangeUnit" class="org.acme.OrangeUnitFactoryBean">
<property name="context" ref="OpenEjbContext">
</bean>
<bean id="SomePojo" class="org.acme.SomePojo">
<property name="entityManager" ref="OrangeUnit">
</bean>
|