struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Pilgrim" <peter.pilg...@db.com>
Subject Re: Long term Session attributes [ was RE: Wizard Interface question ]
Date Thu, 07 Feb 2002 09:59:31 GMT


I made a mistake with the method names, perhaps this is much clearer

public interface SessionLeaseable {

     public void updateLastAccessTime();

     public long getLastAccessTime() ;
}


Clearly every `SessionLeasable' will call its `updateLastAccessTime()'
method to refresh the internal time value.
Here is an example of a bean that avoids the threading issue

public AcmeBean implements SessionLeaseable {
     String coffee;
     volatile long actime;
     public String getCoffee() {
          updateLastAccessTime();    // !
          return actime;
     }

     public void setCoffee( s ) {
          updateLastAccessTime();  // !
          this.coffee = x;
     }

     public synchronised void updateLastAccessTime()
     { actime = System.currentMillisecs(); }
     public synchronised long getLastAccessTime()
     { return actime; }
}


Moreover, if you follow the AXIOM, that

"every navigation invokes an ACTION that generates a VIEW
and I never navigate to VIEW directly"

then you can write logic to reactivate beans that have been timed-out,
or take appropriate countermeasure in your Struts Action.

--
Peter Pilgrim                 ++44 (0)207-545-9923

............................................ Swamped under electionic mails


---------------------------------------- Message History ----------------------------------------


From: duncan@sapio.co.uk (Duncan Harris) on 06/02/2002 12:43

Please respond to "Struts Users Mailing List" <struts-user@jakarta.apache.org>

To:   struts-user@jakarta.apache.org
cc:
Subject:  Re: Long term Session attributes [ was RE: Wizard Interface question ]


peter.pilgrim@db.com (Peter Pilgrim) wrote:

> Have a background thread or even better a java.util.Timer
> on each session object or per user.
> The sleeper or swiper continuous timer wakes up every
> 10 minutes or so iterates through the attributes in the session
> looking especially for Leasable object.  Remove any Leaseable
> object that has expired the maximum idle time.

Got to be a bit careful about threading issues here.
Code inside struts does:

  use getAttribute() to get form
  ...
  do some tests on attribute
  ...
  return form for processing

So if your sweeper does its delete after the getAttribute()
your JSP page may well be unhappy.

Duncan Harris
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hartford, Cheshire, U.K., Tel: 07968 060418
Looking for STRUTS contract work in the U.K.

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>






--

This e-mail may contain confidential and/or privileged information. If you are not the intended
recipient (or have received this e-mail in error) please notify the sender immediately and
destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material
in this e-mail is strictly forbidden.



--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message