Of course, you'll have to deal with sessions that don't properly log out.
My experience is that the SessionListener is not always reliable and, in any
event it you probably don't want to leave this lock on for any reasonable
session timeout period.  You might consider creating a timer that you use to
clear the lock a given number of seconds after the user sets it or after a
given number of seconds of inactivity by the user.  All this will likely
require you to maintain the session id of the locking user so that you can
test that the user is still around.  And if they start a task, lock the
resource, and go for lunch, well -- such is the horror of maintaining a long
transaction in a stateless environment.  We shouldn't ought-a do it; but
sometimes we have to.

Good luck, Mark

[EMAIL PROTECTED] | www.mizar.com


-----Original Message-----
From: Mark Millman [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 29, 2007 2:42 PM
To: 'MyFaces Discussion'
Subject: RE: Locking a webapp against parallel using

You might create an Application Scoped bean with a lock property.  Setting
and releasing that lock will have to by synchronized.

For example, create a class as follows:

public class LockSet {
  private boolean locked = false;
  public LockSet() {
  }
  public synchronized void  setLocked(boolean locked){
    this.locked = locked;
  }
  public boolean isLocked(){
    return locked;
  }
}

And reference it in your faces-config.xml file as

  <managed-bean>
    <managed-bean-name>LockSet</managed-bean-name>
    <managed-bean-class>com.myco.myapp.appbeans.LockSet</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
</managed-bean>


[EMAIL PROTECTED]


-----Original Message-----
From: ULA UVULA [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 29, 2007 2:03 PM
To: [email protected]
Subject: Locking a webapp against parallel using

Hi, I'm a newbie.
Can somebody can give me a hint?

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?

Thanks
Uvula


-- 
This mailbox is not official and not checked regular. It's only
a workaround to have access through the web.

Please also reply to [EMAIL PROTECTED]
Uwe Langjahr / HP Service Consulting & Integration



Psssst! Schon vom neuen GMX MultiMessenger gehört?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger

Reply via email to