Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a bean pass a reference of itself to some other beans

 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help:
1) How can a bean pass a reference of itself to some other beans?

2) Which of the following technology uses Proxy design pattern ?
RMI,JMS,Corba,EJB, and JNDI?
I know RMI using Proxy, therefore, EJB.
CORBA also ?
Thanks,
Ruilin
[This message has been edited by ruilin yang (edited November 01, 2001).]
 
ruilin yang
Ranch Hand
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is some inf for Passing an Enterprise Bean's Object Reference
Suppose that your enterprise bean needs to pass a reference to itself to another bean. You might want to pass the reference, for example, so that the second bean can call the first bean's methods. You can't pass the this reference because it points to the bean's instance, which is running in the EJB container. Only the container may directly invoke methods on the bean's instance. Clients access the instance indirectly by invoking methods on the object whose type is the bean's remote interface. It is the reference to this object (the bean's remote reference) that the first bean would pass to the second bean.
A session bean obtains its remote reference by calling the getEJBObject method of the SessionContext interface. An entity bean would call the getEJBObject method of the EntityContext interface. These interfaces provide beans with access to the instance contexts maintained by the EJB container. Typically, the bean saves the context in the setSessionContext method. The following code fragment shows how a session bean might use these methods.
public class WagonBean implements SessionBean {

SessionContext context;
...
public void setSessionContext(SessionContext sc) {
this.context = sc;
}
...
public void passItOn(Basket basket) {
...
basket.copyItems(context.getEJBObject());
}
...

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic