myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <simon.kitch...@chello.at>
Subject Re: Locking a webapp against parallel using
Date Thu, 01 Jan 1970 00:00:00 GMT
---- ULA UVULA <ula.uvula@gmx.de> schrieb:
> I have written a jsf application which is maintaining a java data structure (bean). (BTW:
I never have written any jsp pages, I direct
> starting with jsf).
> 
> Is there any way to inform the users that another user is already manipulating this structure?
> 
> Workflow: 
> a user can add/delete/edit/copy items into the data structure. After the work is finished,
the user can
> "activate/save" his settings. During this time span, I want to lock the page for other
users or at least I want to
> inform the second user, that another user is already active.
> The goal is to have consistency and not "last write wins".
> 
> Can you also consider: what happens, if the first user is closing the web-browser without
doing a "logoff" on the page?

It's not an easy problem to solve AFAIK.

The Java Persistence API (Hibernate, Toplink etc) provides "pessimistic locking", where a
version column exists on each table. When data is read, this version# is also read. When data
is written, if the version# has changed then the write fails. This provides "first write wins"
type functionality rather than "last write wins". However it's still probably not what you
want.

I don't know of any other standard mechanism for doing what you want.  You're talking about
"logically locking" an object over a number of requests (a conversation).

I would think the best thing to do is to have a separate "lock table", containing columns
  object-name
  object-key
  lock-expiry-time
  owner
and inserting a row whenever someone starts editing a specific object. On write, remove the
row. Forbid starting an edit if there already exists a lock entry with lock-expiry-time >
now. 

Sounds fairly complicated though. It would indeed be nice if there was some standard solution
to this. Maybe such a thing would belong in Myfaces Orchestra, as it really is conversation-related,
but there is no such feature yet.

Regards,

Simon

Mime
View raw message