Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concept of stub and Skeleton in EJB 2.X

As per my knowledge, in the EJB 2.x, the client uses the home interface to ask for a reference to the component interface and calls Enterprise java bean’s business method using that reference. But the concept of stub and skeleton are not clear to me.

Is the reference to the component interface acts as a stub? Then which one act as a skeleton?

Please clarify.

like image 452
Bacteria Avatar asked Feb 15 '23 18:02

Bacteria


2 Answers

Stub and skeleton are actually RMI concepts, EJB is just reusing them. As such, they are only needed when you are using remote interfaces.

  • Stub is used by the client to invoke methods on the remote EJB -- it is basically a proxy object that implements the remote interface. It is responsible for serializing the invocation into a byte stream and sending it to the server hosting the EJB.
  • Skeleton is running on the server side -- it receives the remote calls from the stub over the network, deserializes the invocation and and delegates it to the EJB.

See also: Java RMI : What is the role of the stub-skeleton that are generated by the rmic compiler

Nowadays, stubs and skeletons are typically generated at runtime (or the same function is just handled via reflection), so you do not need to worry about them (see also Do I need RMI stubs to access EJBs from my java client? - this is specific to Glassfish, but the general principles usually apply also to other containers).

like image 142
Neeme Praks Avatar answered Feb 17 '23 07:02

Neeme Praks


Skeletons have been obsolete since 1998. Don't worry about them.

like image 20
user207421 Avatar answered Feb 17 '23 06:02

user207421