• Post Reply Bookmark Topic Watch Topic
  • New Topic

My understanding of EJB working.Kindly correct if iam wrong.

 
Sat Nar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
the below is my understanding of the whole EJB functionality.Correct me if iam wrong.

Initially to start with, we define home interface,remote interface and a bean class.

First , we have to get a reference to Home interface.During deployment,the server automatically generates a class which implements this home interface(Let this class be denoted by A).During JNDI lookup,the object to this class is returned.

CustomerHome cust = Context.lookup("Customer");

Customer remote = cust.create();

Like above,during deployment,the server generates a class which implements the remote interface(let this class be denoted by B).When the create method is called,an object to this class is created and its reference is returned.Also an instance to the bean class is created either by calling the beans constructor or by taking the instance from the pool.So the remote variable contains the reference to the class generated by the server.

Now when a method is called,

remote.<method_name>

the control goes to the stub which performs marshalling.The stub transfers the data through network and the skeleton unmarshalls the arguements and calls the method in the class B.This inturn calls the actual bean implementation method.

This is my overall understanding of the working of EJB.Kindly correct me if iam wrong.

Regards,
Sathya
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are right.When you do a JNDI lookup you get the home stub and after create in invoked you operate on the EJBObject stub which forwards the request to the server.
 
Sat Nar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pradip,
iam having a small doubt here.

When you do a JNDI lookup you get the home stub


My understanding is, during deployment,the container generates two classes which implements the home and remote interface.The JNDI lookup generates the reference to the container generated class which implements home interface.

Apart from this,the container also creates stubs and skeletons for home and remote interface.

So finally you have,

1.Home and remote interface
2.Container generated class which implements these two interfaces
3.Stubs and skeletons for home and interfaces.

So when you call create() method,the connection goes to the home stub which does marshalling and then to the Home skeleton which unmarshalls it and finally the skeleton calls the container generated class which implements the home interface.The reference to the container generated class which implements remote interface is returned.

When you call a remote method,the connection goes to the Remote stub which performs marshalling,then Remote skeleton which performs unmarshalling and the control goes to the container generated class which implements the remote interface.This class inturn calls the actual Bean method.

So my idea is both Home and Remote interfaces their own stub and skeleton.

This is my understanding.Kindly correct me if iam wrong.Awaiting your reply.

Regards,
Sathya
 
Sat Nar
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Kindly someone tell me whether my understanding is correct or wrong.Awaiting your replies.

Regards,
Sathya
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right both remote and home have their own stubs.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!