Avatar billede tigertool Nybegynder
06. januar 2007 - 16:37 Der er 7 kommentarer og
2 løsninger

Hvad betyder: reentrant?

Hej,

I deployment descriptoren har jeg set der står:
<reentrant>false</reentrant>

Hvad betyder dette?
Avatar billede kalp Novice
06. januar 2007 - 16:40 #1
man skal vel se det i sammenhæng med resten, men ordets betydning
http://en.wikipedia.org/wiki/Reentrant
Avatar billede tigertool Nybegynder
06. januar 2007 - 16:41 #2
Ja - men ved du hvad den gør i deployment descriptoren?
Avatar billede kalp Novice
06. januar 2007 - 16:43 #3
der er en som får svar på det her. indlæg nr. 2
http://www.theserverside.com/discussions/thread.tss?thread_id=15929
Avatar billede arne_v Ekspert
06. januar 2007 - 22:18 #4
det er stort set bare en summary af EJB spec

version 2.1 spec sektion 10.5.12 siger:

An entity Bean Provider can specify that an entity bean is non-reentrant. If an instance of a non-reentrant
entity bean executes a client request in a given transaction context, and another request with the
same transaction context arrives for the same entity object, the container will throw an exception to the
second request. This rule allows the Bean Provider to program the entity bean as single-threaded,
non-reentrant code.
The functionality of entity beans with container-managed persistence may require loopbacks in the
same transaction context. An example of a loopback is when the client calls entity object A, A calls
entity object B, and B calls back A in the same transaction context. The entity bean’s method invoked
by the loopback shares the current execution context (which includes the transaction and security contexts)
with the Bean’s method invoked by the client.
If the entity bean is specified as non-reentrant in the deployment descriptor, the container must reject an
attempt to re-enter the instance via the entity bean’s component interface while the instance is executing
a business method. (This can happen, for example, if the instance has invoked another enterprise bean,
and the other enterprise bean tries to make a loopback call.) If the attempt is made to reenter the instance
through the remote interface, the container must throw the java.rmi.RemoteException to the
caller. If the attempt is made to reenter the instance through the local interface, the container must throw
the javax.ejb.EJBException to the caller. The container must allow the call if the Bean’s
deployment descriptor specifies that the entity bean is re-entrant.

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 illegal concurrent calls from clients.
Avatar billede arne_v Ekspert
06. januar 2007 - 22:22 #5
det er kun relevant for entity beans - ikke for session beans

i 99.99% af tilfælde bør du sætte den til false

hvis du sætter den til true, så skal du kode din entity bean derefter (og det er
ikke trivielt da brug af synchronized er forbudt i EJB's)
Avatar billede tigertool Nybegynder
20. januar 2007 - 02:12 #6
Ok. Smid svar, begge.
Avatar billede kalp Novice
20. januar 2007 - 02:15 #7
:)
Avatar billede arne_v Ekspert
20. januar 2007 - 02:15 #8
.
Avatar billede tigertool Nybegynder
20. januar 2007 - 02:22 #9
- og tak :)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester