Versions Compared

Key

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

...

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

Code Block
xmlxml
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:

xml
Code Block
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
xmlxml
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
xmlxml
titlespring 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>
Info
titleSome more useful info.

Here is a bunch of links suggested by a user. If anybody has time to go through them and write a doc, that would be great. These links explain how to make available spring components to openejb http://twasink.net/blog/archives/2007/01/using_spring_wi.htmlImage Removedhttp://static.springframework.org/spring/docs/2.5.x/api/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.htmlImage Removedhttp://wiki.netbeans.org/MavenSpringEJBsOnGlassfishImage Removed