开发者

resource-ref at application scope in EJB 2.1 Project

开发者 https://www.devze.com 2022-12-30 20:35 出处:网络
Is it possible to define resource references that are applicable to all EJBs in an application? Currently I have an ejb-jar.xml that looks something like this:

Is it possible to define resource references that are applicable to all EJBs in an application?

Currently I have an ejb-jar.xml that looks something like this:

<ejb-jar>
  <enterprise-beans>
    <session id="foo">
      <!-- s开发者_Go百科nip -->
      <resource-ref>
        <res-ref-name>jdbc/myDatasource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>
    </session>
    <session id="bar">
      <!-- snip -->
      <resource-ref>
        <res-ref-name>jdbc/myDatasource</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
      </resource-ref>
    </session>
  </enterprise-beans>
</ejb-jar>

You'll notice that both EJBs have the same resource-ref defined for both of them. Is there a way to factor this duplication out within a J2EE 1.4 application?

Ideally I should be able to define the jdbc/myDatasource resource once within the application and have anything running inside that container be able to access it by doing a JNDI lookup for "java:comp/env/jdbc/myDatasource". Is there any way to accomplish this?


No, it is not possible to factor resource-refs like this in J2EE 1.4. JavaEE 6 provides <resource-ref-name>java:module/jdbc/myDatasource</resource-ref-name> (and java:app and java:global) to share resource references at higher levels.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号