简体   繁体   中英

Is the lookup attribute on @Resource a replacement for ibm-ejb-jar-bnd.xml?

I tried to search on the internet but couldn't find a definite answer for this:

Is using

@Resource(name="abc", lookup="myJndiName")
private Queue myQueue;

in a EJB 3.1 session bean equivalent to

@Resource(name="abc")
private Queue myQueue;

without the lookup but with the entry in ibm-ejb-jar-bnd.xml:

<session name="StatelessBean">
    <resource-env-ref name="abc" binding-name="myJndiName"/>
</session>

?

Ie if I'm using the lookup attribute, then I don't have to specify the resource-env-ref anymore?

Yes, the lookup attribute is functionally equivalent to specifying the value in ibm-ejb-jar-bnd.xml, but not quite a replacement. If a value is specified in ibm-ejb-jar-bnd.xml, it will override the value provided on the 'lookup' attribute. ibm-ejb-jar-bnd.xml is still useful in that it allows the binding to be changed without recompiling the application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM