Two Laptop Bag*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes a bean pass a reference of itself to some other beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "a bean pass a reference of itself to some other beans" Watch "a bean pass a reference of itself to some other beans" New topic
Author

a bean pass a reference of itself to some other beans

ruilin yang
Ranch Hand

Joined: Feb 25, 2001
Posts: 334
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

Joined: Feb 25, 2001
Posts: 334
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());
}
...

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: a bean pass a reference of itself to some other beans
 
Similar Threads
bean reference
Applet to Servlet Communication with RMI
Pass by value and Pass by reference
what design patterns are used in RMI,JMS,Corba,EJB, and JNDI?
where's the "sharpen your pencil" answer?