• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creation & linking of instances

 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case of all of the bean types: SLSB, SFSB and Entity Beans - For the three objects below:
1. the bean instance
2. the EJBContext (or any of it's subclasses) instance
3. the EJBObject instance

Q1. When the above three objects would be instantiated?
Q2. When and how the EJBContext instance would be linked to the bean instance?
Q3. When and how the EJBObject instance would be linked to the bean instance?


Let me write down what I have understood:

For SLSB:
Answer to Q1:
- Bean instance is created at the time when the container decides to add a new bean instance on the bean pool.
- SessionContext instance is created at the time when the container decides to add a new bean instance on the bean pool, following the creation of the bean instance.
- EJBObject instance is created at the time when the client calls the create method.

Answer to Q2:
- At the time when the container decides to add a new bean instance on the bean pool, following the instantiation of the bean instance and the SessionContext instance.
- Container calls the setSessionContext for this linking.

Answer to Q3:
- At the time when the client calls one of the business methods.
- Not sure how the container does this linking.


For SFSB:
Answer to Q1:
- Bean instance is created at the time when the client calls the create method.
- SessionContext instance is created at the time when the client calls the create method, following the creation of the bean instance.
- EJBObject instance is created at the time when the client calls the create method, following the creation of the bean instance and the SessionContext instance.

Answer to Q2:
- At the time when the client calls the create method, following the instantiation of the bean instance and the SessionContext instance.
- Container calls the setSessionContext for this linking.

Answer to Q3:
- At the time when the client calls the create method, following (1)instantiating the bean instance and the SessionContext instance and the EJBObject instance and (2) linking the SessionContext instance to the bean instance.
- Not sure how the container does this linking.



For Entity Beans:
Answer to Q1:
- Bean instance is created at the time when the container decides to add a new bean instance on the bean pool.
- EntityContext instance is created at the time when the container decides to add a new bean instance on the bean pool, following the creation of the bean instance.
- EJBObject instance is created at the time when the client calls the create method.

Answer to Q2:
- At the time wen the container decides to add a new bean instance on the bean pool, following the instantiation of the bean instance and the EntityContext instance.
- Container calls the setEntityContext for this linking.

Answer to Q3:
- At the time when the client calls the create method.
- Not sure how the container does this linking.


Please correct me wherever I am wrong above and add if I have missed anything above.
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any inputs from anybody on this one?
 
Balaji Anand
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I agree with your answers except for the entity bean

The entity bean /entityContext creation is at the will of the container. EJBObject can be created when the client calls Create or does a search(single entity).

In the case after Create... the bean might go back to the pool after the transaction completes. In the case of finders... the bean just stays in the pool. and the EJBObject is not linked to the entityBean. The linking happens only when a first business method is initiated(a transaction begins).

Then the linking between the EJBObject and the entityBean basically depends on what Commit option you choose. (ie it can retain the link or reestablish it everytime) Which are

A. Bean stays in sync.
B. Bean is connected but not in sync.
C. Bean returns to the pool(passivated).

Hope this helps
[ February 14, 2006: Message edited by: Srividhya Anand ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic