Originally posted by Vince Hon:
Hi, Marc
As u said the loopback "all within a single thread of control". Why allow reentrancy can allow multithreaded (and multiclient) ?
thx !
My line preceding it says:
...the Entity Bean can't tell the difference between an application client (physical user) and an EJB client (possible loopback).
I really should have said that the
container can't tell the difference, but my point is still valid. The container can't distinguish one from the other, so it must let them both in if you want to allow reentrancy.
Pages 189-190 of the spec say:
Re-entrant entity beans must be programmed and used with caution. First, the Bean Provider must code the entity bean with the anticipation of a loopback call. Second, since the container cannot, in general, tell a loopback from a concurrent call from a different client, the client programmer must be careful to avoid code that could lead to a concurrent call in the same transaction context.
Concurrent calls in the same transaction context targeted at the same entity object are illegal and may lead to unpredictable results. Since the container cannot, in general, distinguish between an illegal concurrent call and a legal loopback, application programmers are encouraged to avoid using loopbacks. Entity beans that do not need callbacks should be marked as non-reentrant in the deployment descriptor, allowing the container to detect and prevent concurrent calls from clients.
I hope this answers your question, Vince.