老玉米:
嗯,看这是这样的,这是ejb3.0 specification里面的:
[阅读: 473] 2005-09-12 09:15:50
3.4.1 Obtaining a Session Bean’s Business Interface
A client can obtain a session bean’s business interface through dependency injection or lookup in the
JNDI namespace.
For example, the business interface Cart for the CartBean session bean may be obtained using
dependency injection as follows:
@EJB Cart cart;
The Cart business interface could also be looked up using JNDI as shown in the following code segment
using the lookup method provided by the EJBContext interface. In this example, a reference to
the client bean’s SessionContext object is obtained through dependency injection:
@Resource SessionContext ctx;
Cart cart = (Cart)ctx.lookup(“cart”);
In both cases, the syntax used in obtaining the reference to the Cart business interface is independent
of whether the business interface is local or remote. In the case of remote access, the actual location of a
referenced enterprise bean and EJB