resource-ref at application scope in EJB 2.1 Project
Posted
by Mike Deck
on Stack Overflow
See other posts from Stack Overflow
or by Mike Deck
Published on 2010-05-20T16:41:43Z
Indexed on
2010/05/20
17:40 UTC
Read the original article
Hit count: 361
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">
<!-- 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>
<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?
© Stack Overflow or respective owner