You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim Menard <ji...@io.com> on 2004/02/13 13:38:31 UTC

Synchronization and end-of-life notification

The quick question: is there any way for my visit instances to know 
when they are discarded? Now I'll explain why I think I need that. 
Perhaps someone can suggest a better way to solve my problem.

I need to synchronize information between all users. I can't just keep 
something in a global; I need to invalidate some in-memory database 
objects for each visit. As a concrete example, if one user adds a 
photograph to an album, all the other instances of that album in all 
other visits need to be marked as invalid so they will re-load their 
list of photos.

[I'm using Cayenne for O/R mapping, which actually introduces exactly 
this kind of synchronization in 1.1a-pre2. The problem is, I found 
another bug that prevents me from adopting this pre-alpha release. The 
bug has since been fixed, but I need a separate strategy in case I 
still can't adopt the latest release.]

So: I'm thinking about using Observer/Observable and registering each 
visit with a global synchronizer object which in turn observes a few 
select database objects. When the database object changes in a 
significant way (say, a photo is added to an album), the object 
notifies the synchronizer. It, in turn, notifies each visit.

There's' the rub: when a visit is no longer valid, I want to remove it 
from the list of visits the synchronizer notifies. So, my original 
question again: is there any way for my visit instances to know when 
they are discarded?

Thank you for your help.

Jim
-- 
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
[On the Apple supercomputer at Virginia Tech] "Besides if an AI 
manifests
itself it'd be less likely to destroy the world and more likely to tell 
you
that your white socks do not match your purple tie." -- Epistax on 
Slashdot


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Synchronization and end-of-life notification

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Feb 13, 2004, at 8:34 AM, Jim Menard wrote:
> On Feb 13, 2004, at 8:23 AM, Programozás wrote:
>
>> I think that the Visit is "discarded" when the session is invalidated
>> (because of timeout or programmatically).
>> Try to use a HttpSessionListener.
>
> Thanks. Let's see...I'd need to register my synchronizer class in the 
> web.xml deployment descriptor. Then the synchronizer would receive the 
> sessionCreated() and sessionDestroyed() events.
>
> Now I'm trying to figure out how to get the visit from each session. I 
> can't yet see how.

The visit hangs off the engine, which can be gotten from (see 
ApplicationServlet) this key:

         _attributeName = "org.apache.tapestry.engine:" + 
config.getServletName();

Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Synchronization and end-of-life notification

Posted by Jim Menard <ji...@io.com>.
On Feb 13, 2004, at 8:23 AM, Programozás wrote:

> I think that the Visit is "discarded" when the session is invalidated
> (because of timeout or programmatically).
> Try to use a HttpSessionListener.

Thanks. Let's see...I'd need to register my synchronizer class in the 
web.xml deployment descriptor. Then the synchronizer would receive the 
sessionCreated() and sessionDestroyed() events.

Now I'm trying to figure out how to get the visit from each session. I 
can't yet see how.

Jim
-- 
Jim Menard, jimm@io.com, http://www.io.com/~jimm/
"Any sufficiently advanced technology is indistinguishable from a Perl
script." -- Programming Perl, 2nd edition


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: Synchronization and end-of-life notification

Posted by Programozás <pr...@hotmail.com>.
I think that the Visit is "discarded" when the session is invalidated
(because of timeout or programmatically).
Try to use a HttpSessionListener.

Norbi

----- Original Message ----- 
From: "Jim Menard" <ji...@io.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, February 13, 2004 1:38 PM
Subject: Synchronization and end-of-life notification


> The quick question: is there any way for my visit instances to know
> when they are discarded? Now I'll explain why I think I need that.
> Perhaps someone can suggest a better way to solve my problem.
>
> I need to synchronize information between all users. I can't just keep
> something in a global; I need to invalidate some in-memory database
> objects for each visit. As a concrete example, if one user adds a
> photograph to an album, all the other instances of that album in all
> other visits need to be marked as invalid so they will re-load their
> list of photos.
>
> [I'm using Cayenne for O/R mapping, which actually introduces exactly
> this kind of synchronization in 1.1a-pre2. The problem is, I found
> another bug that prevents me from adopting this pre-alpha release. The
> bug has since been fixed, but I need a separate strategy in case I
> still can't adopt the latest release.]
>
> So: I'm thinking about using Observer/Observable and registering each
> visit with a global synchronizer object which in turn observes a few
> select database objects. When the database object changes in a
> significant way (say, a photo is added to an album), the object
> notifies the synchronizer. It, in turn, notifies each visit.
>
> There's' the rub: when a visit is no longer valid, I want to remove it
> from the list of visits the synchronizer notifies. So, my original
> question again: is there any way for my visit instances to know when
> they are discarded?
>
> Thank you for your help.
>
> Jim
> -- 
> Jim Menard, jimm@io.com, http://www.io.com/~jimm/
> [On the Apple supercomputer at Virginia Tech] "Besides if an AI
> manifests
> itself it'd be less likely to destroy the world and more likely to tell
> you
> that your white socks do not match your purple tie." -- Epistax on
> Slashdot
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org