Question

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.

Was it helpful?

Solution

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).

OTHER TIPS

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

Well stub and skeleton are just there when you are using Remote interfaces. Stub is an object implementing Remote interface (implemented usually by code generation) and skeleton is implemented inside the container and invokes method on the EJB (inside the container).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top