petstore的代码里。
package com.sun.j2ee.blueprints.petstore.tools.populate;
class CustomerPopulator
里面有这样一行code
InitialContext context = new InitialContext();
customerHome = (CustomerLocalHome) context.lookup("java:comp/env/ejb/Customer");
==============================
相关文件web.xml里有
<ejb-local-ref>
<ejb-ref-name>ejb/Customer</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.sun.j2ee.blueprints.customer.ejb.CustomerLocalHome</local-home>
<local>com.sun.j2ee.blueprints.customer.ejb.CustomerLocal</local>
<ejb-link>CustomerEJB</ejb-link>
</ejb-local-ref>
===============================
ejb-jar.xml里有
<entity>
<display-name>CustomerEB</display-name>
<ejb-name>CustomerEJB</ejb-name>
================================
请问程序里的lookup是找到了web.xml里的EJB/Customer再转而找到EJB-jar.xml里的CustomerEJB吗?
如果这样的话,我看到有的书上说web.xml里的<ejb-ref>设定的不是jndi名字而是参考名。那么如果在比如j2ee ri的辅助DD文件sun-ejb=jar.xml里有
<ejb>
<ejb-name>CustomerEJB</ejb-name>
<jndi-name>ejb/petstore/customer/Customer</jndi-name>
为什么lookup方法找的不是EJB/petstore/customer/Customer这个jndi名字,而是EJB-ref名字。换句话说这个EJB-ref设定的名字跟jndi名字到底什么区别呢?
现在越看越糊涂了。请高人指点一下。谢谢