Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

And include that at the top of your spring xml file as follows:

Code Block
xml
xml
titletop 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
titlein the spring xml xml
<bean id="OrangeUnit" class="org.acme.OrangeUnitFactoryBean">
  <property name="context" ref="OpenEjbContext">
</bean>

...

Code Block
titleSomePojo.java
public class SomePojo {

    private EntityManager entityManager;

    public void setEntityManager(EntityManager entityManager) {
        this.entityManager = entityManager;
    }
    
    ...
}
Code Block
xml
xml
titlein 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
titlespring bean definitions combinedxml
<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>

...