-------- Forwarded Message -------- From: simon <[EMAIL PROTECTED]> To: MyFaces Development <[email protected]> Subject: Re: [orchestra] class Conversation and ThreadLocals Date: Sat, 11 Aug 2007 14:52:04 +0200
On Sat, 2007-08-11 at 13:28 +0200, Mario Ivankovits wrote: > Hi! > > Class Conversation uses a thread-local variable to store the "current > > conversation". Thread-locals are pretty tricky to manage in a container > > environment; they need to be cleared at the end of each request as the > > same thread will be reused by the container. > > > > Would storing this value in request scope be acceptable instead? > > > No, this is not possible. > <snip/> > To make this work, we use Spring AOP (see > org.apache.myfaces.orchestra.conversation.CurrentConversationAdvice) > this advice triggers for every method (public methods) call to the > conversation scoped bean - in other words: It is a proxy which > transparently wraps your bean and just maintains the thread-local. > (Have a look at SpringConversationScope.getBean:137 to see what happens > when a new bean is going to be created) > > As you can see, in the finally block we set it to the previous value - > which is null for the topmost call. Ah yes, now I see. Thanks for the explanation. I've added some comments to the code. Sorry if they are too verbose; as I misunderstood this initially I thought it worth a few lines of explanation. Regards, Simon
