| Prev | Next | J2EETM Developer's Guide
Session Beans |
this reference because the session bean is not a remote object. Instead, your bean must pass an object reference for the instance. It gets the reference to itself by calling the getEJBObject method of the SessionContext interface. This interface provides a session bean with access to the instance context maintained by the EJB container. Typically, the bean saves the context in the setSessionContext method. The following code fragment shows how you might use these methods.
public class WagonEJB implements SessionBean {
SessionContext context;
. . .
public void setSessionContext(SessionContext sc) {
this.context = sc;
}
. . .
public void passItOn(Basket basket) {
. . .
basket.copyItems(context.getEJBObject());
}
. . .