Re: [IMP] synchronization on session object in Cocoon

2005-05-23 Thread Joerg Heinicke
On 16.05.2005 06:39, Ralph Goers wrote: Yes, there was considerable discussion about this. Yes, the version in svn is wrong. I was hoping it would get fixed after our discussion, but that hasn't happened, so I'll try to commit something tonight (it is still Sunday night here in California).

Re: [IMP] synchronization on session object in Cocoon

2005-05-16 Thread Ralph Goers
Please update from svn and review the changes. Ralhp Jochen Kuhnle wrote: Am I not getting it, or is the implementation broken (see below)? /** The map to assure 1:1-mapping of server sessions and Cocoon session wrappers */ private static final Map sessions = Collections.synchronizedMap(new

Re: [IMP] synchronization on session object in Cocoon

2005-05-15 Thread Jochen Kuhnle
Am I not getting it, or is the implementation broken (see below)? /** The map to assure 1:1-mapping of server sessions and Cocoon session wrappers */ private static final Map sessions = Collections.synchronizedMap(new WeakHashMap()); public Session getSession(boolean create) {

Re: [IMP] synchronization on session object in Cocoon

2005-05-15 Thread Ralph Goers
Yes, there was considerable discussion about this. Yes, the version in svn is wrong. I was hoping it would get fixed after our discussion, but that hasn't happened, so I'll try to commit something tonight (it is still Sunday night here in California). Ralph Jochen Kuhnle wrote: Am I not

RE: [IMP] synchronization on session object in Cocoon

2005-05-13 Thread Nathaniel Alfred
: Donnerstag, 12. Mai 2005 18:27 To: dev@cocoon.apache.org Subject: Re: [IMP] synchronization on session object in Cocoon In addition, I really don't like the implementation that was checked in. Frankly, this is a case where I would look into leveraging backport-util-concurrent (http

Re: [IMP] synchronization on session object in Cocoon

2005-05-13 Thread Ralph Goers
Fine. Leave the WeakHashmap the way it is. But synchronizing on the servlet session is a -1 for me. That could have unknown consequences since the object is owned by the container, not Cocoon. See my other post. Sorry - my ISP has had severe email problems the last few days and so I have

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Sylvain Wallez
Nathaniel Alfred wrote: -Original Message- From: Sylvain Wallez [mailto:[EMAIL PROTECTED] Sent: Mittwoch, 11. Mai 2005 18:04 To: dev@cocoon.apache.org Subject: Re: [IMP] synchronization on session object in Cocoon Joerg Heinicke wrote: Sylvain Wallez sylvain at apache.org writes

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Ralph Goers
It suddenly dawned on me that the code below is synchronizing on the session, not a local object. Duh! Still, this seems like a very, very bad idea to me, as I'm not sure how that would impact the servlet container. public Session getSession(boolean create) { // we must assure a 1:1-mapping

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Ralph Goers
I ran through this thread and made some observations: 1. There can only be one Cocoon Session per HttpSession. Creation of this must be thread safe. 2. The code propsed will not work: public Session getSession(boolean create) { // we must assure a 1:1-mapping of server session to cocoon

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Joerg Heinicke
Ralph Goers Ralph.Goers at dslextreme.com writes: serverSession is a local variable. Synchronizing it accomplishes nothing since every caller gets their own copy. Sytnchronizing on a member of the HttpRequest object also accomplishes nothing. Huh? Why shall synchronization not work? It is

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Joerg Heinicke
Sylvain Wallez sylvain at apache.org writes: This approach has the problem of entering a synchronized block each time getSession is called. Although this may not that be much a problem in this particular case because it's unlikely that many parallel requests exist for a single request, we

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Joerg Heinicke
Sylvain Wallez sylvain at apache.org writes: Or more simply we could store the wrapper in the session itself using an attribute. That way it would be guaranteed to be created only once. Yes, that's another possibility I also had in mind. But on the one hand this smells a bit

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Sylvain Wallez
Joerg Heinicke wrote: Sylvain Wallez sylvain at apache.org writes: Or more simply we could store the wrapper in the session itself using an attribute. That way it would be guaranteed to be created only once. Yes, that's another possibility I also had in mind. But on the one

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Joerg Heinicke
Sylvain Wallez sylvain at apache.org writes: This solution looks really cool and elegant. Unfortunately HttpSessionActivationListener is Servlet Spec 2.3. In Cocoon 2.1. we are still on 2.2 and I guess (and suggest) we will stay with that. So only the WeakHashMap solution remains. 2.2,

RE: Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Nathaniel Alfred
-Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Joerg Heinicke Sent: Donnerstag, 12. Mai 2005 11:16 To: dev@cocoon.apache.org Subject: Re: [IMP] synchronization on session object in Cocoon I have an implementation with map in HttpRequest and without double-checked

Re: Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Joerg Heinicke
Nathaniel Alfred Alfred.Nathaniel at swx.com writes: I think there is a memory leak in http://svn.apache.org/viewcvs?rev=169806view=rev. There is a strong reference session.wrappedSession from value to key in // create new wrapper session = new

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Ralph Goers
In addition, I really don't like the implementation that was checked in. Frankly, this is a case where I would look into leveraging backport-util-concurrent (http://www.mathcs.emory.edu/dcl/util/backport-util-concurrent/) if that code can be made to work in JDK 1.3. What I would look to do

Re: [IMP] synchronization on session object in Cocoon

2005-05-12 Thread Ralph Goers
In addition, I really don't like the implementation that was checked in. Frankly, this is a case where I would look into leveraging backport-util-concurrent (http://www.mathcs.emory.edu/dcl/util/backport-util-concurrent/) if that code can be made to work in JDK 1.3. What I would look to do

RE: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Nathaniel Alfred
-Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Joerg Heinicke Sent: Dienstag, 10. Mai 2005 18:56 To: dev@cocoon.apache.org Subject: [IMP] synchronization on session object in Cocoon As you can see on every request a new wrapper is instantiated which is really

Re: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Sylvain Wallez
Joerg Heinicke wrote: Hello, I think I have found a more general problem with synchronization in Cocoon. I tried to solve my problem with synchronization in flow script with an intermediate object. This object handles the synchronized instantiation of my component. Unfortunately I found out that

Re: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Joerg Heinicke
Nathaniel Alfred Alfred.Nathaniel at swx.com writes: As you can see on every request a new wrapper is instantiated which is really bad. It is not possible to synchronize on Cocoon session objects. What we probably need is a Map mapping the server sessions to the wrapper objects.

RE: Re: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Nathaniel Alfred
-Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Joerg Heinicke Sent: Mittwoch, 11. Mai 2005 13:50 To: dev@cocoon.apache.org Subject: Re: [IMP] synchronization on session object in Cocoon ... But the String pool comes to the rescue. This should work for all

Re: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Joerg Heinicke
Sylvain Wallez sylvain at apache.org writes: I think I have found a more general problem with synchronization in Cocoon. I tried to solve my problem with synchronization in flow script with an intermediate object. This object handles the synchronized instantiation of my component.

Re: Re: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Joerg Heinicke
Nathaniel Alfred Alfred.Nathaniel at swx.com writes: AFAIKS is the purpose of the existing synchronized(session) bits to protect the consistency of the session object in case it is shared between parallel executing requests. Yes. IIUC you need a lock object to really synchronize parallel

RE: Re: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Nathaniel Alfred
-Original Message- From: news [mailto:[EMAIL PROTECTED] Behalf Of Joerg Heinicke Sent: Mittwoch, 11. Mai 2005 17:22 To: dev@cocoon.apache.org Subject: Re: [IMP] synchronization on session object in Cocoon I have implemented the session attribute solution. Would be nice if you can

Re: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Sylvain Wallez
Joerg Heinicke wrote: Sylvain Wallez sylvain at apache.org writes: I think I have found a more general problem with synchronization in Cocoon. I tried to solve my problem with synchronization in flow script with an intermediate object. This object handles the synchronized instantiation of my

RE: [IMP] synchronization on session object in Cocoon

2005-05-11 Thread Nathaniel Alfred
-Original Message- From: Sylvain Wallez [mailto:[EMAIL PROTECTED] Sent: Mittwoch, 11. Mai 2005 18:04 To: dev@cocoon.apache.org Subject: Re: [IMP] synchronization on session object in Cocoon Joerg Heinicke wrote: Sylvain Wallez sylvain at apache.org writes: Or more simply we could

[IMP] synchronization on session object in Cocoon

2005-05-10 Thread Joerg Heinicke
Hello, I think I have found a more general problem with synchronization in Cocoon. I tried to solve my problem with synchronization in flow script with an intermediate object. This object handles the synchronized instantiation of my component. Unfortunately I found out that synchronized (session)