Originally posted by Shanthi Priya: Hi, I am novice to EJB. I got confused with some naming conventions can anyone please clear these
Q) Is EJBObject and RemoteInterface object one and the same?? or Is EJBObject same as bean instance.??
This seems to be very silly but please clear this.
Thanks in advance!
EJBObject is a remote class (because extends the EJBObject interface, which in turn extends java.rmi.Remote) that is written by the container and that steps in the middle between the client and the bean instance. The bean functionalities are exposed to the client through the bean's component interface, which the EJBObject implements. To the client, the EJBObject (or better, the EJBObject stub) *is* the bean. A remote client get a reference (stub) to the EJBObject and invokes methods on the stub (which also implements the bean's component interface), thinking it's invoking methods directly on the bean instance. The reason is mainly that the bean instance mustn't be a '*remote* object, in other words a client shouldn't be able to invoke directly methods on it (because it could miss the Container services - which is what it's all about), but each business method invocation should pass through the EJBObject (which in the HF book is called the 'bean' bodyguard);
The bean developer (i.e. You), must write the bean class (ensuring that it implements all the methods defined in the component interface, but you should avoid, although technically possible from implementing the component interface), the home and the component interface; the container writes the EJBHome, EJBObject, EJBHome_stub, EJBObject_stub objects, which are the 'interface' the client sees and can work with.
There is then a difference between the bean instance (as a simple object) and the 'fully qualified bean', which is the bean instance once the container has assigned a context to it and invoked the ejbCreate() method (for session beans), or when simply a context has been assigned to it (in case of entity beans). An ordinary java object (let's say the bean class when only the constructor has been invoked), can't do all the things a bean can, but you will learn it along the way.
Marco Tedone<br />SCJP1.4,SCJP5,SCBCD,SCWCD
What is that? Is that a mongol hoarde? Can we fend them off with this tiny ad?