Java Ejb 3.0 Interview Questions and Answers for Experienced - 2

Question: 6

What is Passivation and Activation in EJB?

When we are dealing with stateful session beans we need to store the client conversation of the bean so that it can be available in client’s next request.

But when we talk about server it has limited resources.

If the conservation of the bean is large then the server can run out of resources.

If the conservation of the bean is large then the server can run out of resources. So, in order to preserve resources.

EJB server swaps this conversational data in memory to hard disk is called as “Passivation”.

Now when the clients comes back the conversational data is again swapped from the hard disk to the bean.

This process is called as “Activation”. The container informs the bean that its about to passivate or activate using the “ejbPassivate()” and “ejbActivate()” methods.

Question: 7

Can you explain the concept of local interfaces?

JAVA client calls the local stub.

Stub Marshal’s the values in to some other form which the network understands and sends it to the skeleton.

Skeleton then de-marshals it back to a form which is suitable for JAVA.

EJB object then does object creation, connection pooling, transaction etc.

Once EJB object calls the bean and the bean completes its functionalities.

So you can easily guess from the above step that its lot of work. But this has been improved in EJB 2.0 using Local objects.

Local objects implement local interface rather than using remote interface. Just to have a comparison below are the steps how the local object works.

JAVA client calls the local object.

Local object does connection pooling, transactions and security.

It then passes calls the beans and when bean completes its work it returns the data to the Local object who then passes the same to the end client.

Question: 8

How does the server decide which beans to passivate and activate?

Most servers use the (LRU) Last Recently Used Time as a strategy. Which mean passivate the beans which have been called recently.

Related Questions