• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

trouble understanding HF pg 99

 
sundar katluri
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am new to EJB
I was reading page 98-99 and i am confused
I would appreciate if you some body help me to come out of this confusion

I got following points before (I got them before I read HF)

1. An instance of enterprise bean are never shared between the clients
That means Enterprise beans are not multi threaded

2. stateless session bean instances are pooled
and container may/may not create statless bean instance for each client (that means they can be shared between the clients,same instance can be served from getting the pool)


3. statefull beans instance are created for each client (instances are not sharable
and will be activated or passivated if necessary)

4. Entity Bean instances are created one for each row in the db
and cannot be shared between the clients
that means Customer#420 instances will be retured to client1 and
and second instanceof customer#420 will created for client2


So I assume I understood 3 points correctly by reading HF book pg 98
but 4 th point is scary and completely opposite in HF?
HF says Entity beans may be shared (for exampe client 1 and client 2
can share Customer#420 instance ) and this is against point 1 mentioned
above. What am I understanding here? I am totally confused
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your understanding as well as HF's illustration are correct. The spec leaves it to the container to handle this (possibly during deploy-time customization). The container can choose to have two distinct bean instances, one for each client. This allows the transactions (initiated by the two clients) to run in parallel. The container synchronizes the instance state with the persistent store and vice versa at the beginning and end of each transaction.

On the other hand, the container may also choose to have only instance for all the invoking clients and serialize access to this instance. Therefore, while one client is using the instance in a transaction, the other client will wait.
[ February 16, 2005: Message edited by: Keerthi P ]
 
sundar katluri
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply
I did understood little bit now
Your understanding as well as HF's illustration are correct. The spec leaves it
to the container to handle this (possibly during deploy-time customization).
The container can choose to have two distinct bean instances,
one for each client. This allows the transactions (initiated by the two clients)
to run in parallel. The container synchronizes the instance state with the
persistent store and vice versa at the beginning and end of each transaction.

what i understood from the above lines are

1. since entity beans are also pooled and bean state will re-loaded
when a business method is called(with ejbActivate()/ejbLoad() mechanism)
with this in mind when the client1 and client2
request customer#420, an instance will be returned
from pool(or new instace will created)
and howz those instances are synchronized is left to the vendor depending on transactions

is my understanding right for point#1?
Also you said 'deploy-time customization' ,It will be greatfull to me if you expand this topic littlebit(or guide me where to look in this spec,sorry to trouble you)

but still i am confused about following line(s)

On the other hand, the container may also choose
to have only instance for all the invoking clients
and serialize access to this instance. Therefore,
while one client is using the instance in a transaction, the other client will wait

serialize access to one instance? this is clearly voilating entity bean life cycle right??(according to spec entity beans can be pooled that means mutiple customer#420 's will be avialble in the pool and as i mentioned in point 1.)
sorry to give you guys trouble but i really want to straighten up my concepts before leaving HF pg 99
please re-direct me correct page number in the spec atleast!!

thanks for your co-operation
 
sundar katluri
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
according to spec entity beans can be pooled that means mutiple customer#420 's will be avialble in the pool

small correction to above statement
When an entity bean is in the pool it has no identity ( I mean #420 is not associated with it)when the client1 and client2 issues find primarykey
customer#420 associated with client1 and client2
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By 'deploy-time customization', I meant vendor-specific customization that ejb spec does not mandate.
 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pg: 186 and 187 in the spec might help you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic