You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Maeder Thomas <th...@ecofin.ch> on 2007/09/19 15:51:31 UTC

WebSession shutdown

Hi folks,

In our WebSession subclass we manage some resources which need to be
cleaned up when the session goes away (because of timeout, etc). Is
there a recommended way to call a "shutdown()" method on our session
class? I have seen WebApplication.sessionDestroyed(String), but I'm not
sure how to get the wicket session from there (since we don't
necessarily have an active request at that time). Of course, I could
implement my own session store or something like that, but that approach
seems to be a bit hackish.

Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: WebSession shutdown

Posted by Eelco Hillenius <ee...@gmail.com>.
> The trouble is that the lifecycle of a Wicket WebSession object is not the same as the HTTPSession. When a session is temporary only, you never get a valueUnbound() callback. I'll have to move the resource manager initialization into the valueBound() method; inconvenient but not a problem per se.

Ah yeah, but temporary sessions are volatile anyway. You could
implement a custom request cycle that in onEndRequest checks whether
the session is temporary, and if so, let it call the cleanup method.

> My second objection is that this works, as you said, with the default implmentation of ISessionStore. I would introduce a dependency on the exact implementation of ISessionStore used, not any published API. That somehow fills me with sombre premonitions ;-)
> I still think it would be nice if org.apache.wicket.Session had a proper lifecycle (à la WebApplication.onDestroy()). Should I file a feature request or start a conversation on the dev list?

Sure, you can start a discussion on the dev list, and filing a JIRA
issue makes that it will be a more persistent discussion topic. Having
it here is fine too though.

I'm not sure whether depending on the Session object being put in the
HttpSession is bad for you though. If you are not using that, it
probably means you're working with a custom session store in which
case you could just make sure your cleanup callback gets called by
that, right?

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: WebSession shutdown

Posted by Maeder Thomas <th...@ecofin.ch>.
Thanks Eelco, but...

The trouble is that the lifecycle of a Wicket WebSession object is not the same as the HTTPSession. When a session is temporary only, you never get a valueUnbound() callback. I'll have to move the resource manager initialization into the valueBound() method; inconvenient but not a problem per se.
My second objection is that this works, as you said, with the default implmentation of ISessionStore. I would introduce a dependency on the exact implementation of ISessionStore used, not any published API. That somehow fills me with sombre premonitions ;-)
I still think it would be nice if org.apache.wicket.Session had a proper lifecycle (à la WebApplication.onDestroy()). Should I file a feature request or start a conversation on the dev list?

Thomas

> -----Original Message-----
> From: Eelco Hillenius [mailto:eelco.hillenius@gmail.com] 
> Sent: Donnerstag, 20. September 2007 02:39
> To: users@wicket.apache.org
> Subject: Re: WebSession shutdown
> 
> > In our WebSession subclass we manage some resources which 
> need to be 
> > cleaned up when the session goes away (because of timeout, etc). Is 
> > there a recommended way to call a "shutdown()" method on 
> our session 
> > class? I have seen WebApplication.sessionDestroyed(String), but I'm 
> > not sure how to get the wicket session from there (since we don't 
> > necessarily have an active request at that time). Of 
> course, I could 
> > implement my own session store or something like that, but that 
> > approach seems to be a bit hackish.
> 
> As long as you are putting the Wicket Session object in your 
> HttpSession (like the default session stores do) I think you 
> should be able to just let your session class inplement 
> HttpSessionBindingListener and react on valueUnbound. Can you 
> try that and let the list know whether that worked for you?
> 
> Eelco
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: WebSession shutdown

Posted by Eelco Hillenius <ee...@gmail.com>.
> In our WebSession subclass we manage some resources which need to be
> cleaned up when the session goes away (because of timeout, etc). Is
> there a recommended way to call a "shutdown()" method on our session
> class? I have seen WebApplication.sessionDestroyed(String), but I'm not
> sure how to get the wicket session from there (since we don't
> necessarily have an active request at that time). Of course, I could
> implement my own session store or something like that, but that approach
> seems to be a bit hackish.

As long as you are putting the Wicket Session object in your
HttpSession (like the default session stores do) I think you should be
able to just let your session class inplement
HttpSessionBindingListener and react on valueUnbound. Can you try that
and let the list know whether that worked for you?

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org