• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB 2.0 marking bean "re-entrant"

 
Vladas Razas
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Anybody knows how to mark bean or bean method "re-entrant" and what does that mean. Is there such thing in EJB 2.0?
Vladas
 
Sergiu Truta
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside the ejb-jar.xml file you can set the element <reentrant/> either to True or to False.
This element dictates whether the bean can call itself through another bean. For example bean A is reentrant if it calls bean B and B calls back bean A. This is a special case of multithreading because there is really only one path of execution that loops back on itself. If you set this element to True the container will allow two threads to run inside bean A at once. For more info you could look at Mastering EJB 2nd edition found at www.theserverside.com or at www.middleware-company.com
Sergiu.
 
Vishwa Kumba
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Re-entrant property is valid in EJB2.0, specified as a property of the entity in the DD(true/false). If a client calls an entity bean A, and if entity bean A calls entity bean B and if entity bean B calls the entity bean A, then this is called a loopback or reentrance.By default, such code results in a RemoteException for remote interfaces and EJBException for local interfaces.
client-->entity bean A-->entity bean B-->entity bean A
"Reentrance is when a thread of control tries to reenter the bean instance again". By default, entity beans are non-reentrant. But you can make them re-entrant in the DD, which is discouraged by the spec.
I have enclosed the foll. from RMH book. Hope this helps!

When a business method is invoked on a bean instance, it cannot tell the difference between a remote application client and a bean client.The problem with the re-entrant code is that the EJB Object, which intercepts and delegates the method invocations on the bean instance cannot differentiate between re-entrant code and multithread-access with the same transanctional context. If you permit reentrance, you also permit multi-threaded access, which can lead to data corruption.

Re-entrant property is applicable only to entity beans. It is not applicable to message beans as they do not respond to RMI calls, as session beans/entity beans.
Refer spec : 10.5.11, page:189 and p:457.
I do not know why this property is not applicable to Session beans.
Can somebody explain please...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!