Johan Compagner wrote:
be aware that keeping references to http session attributes is not always a
good thing
especially in clustering or restarts of a server (with a nice shutdown, so
sessions are saved to disk, then you loose your map)
Great points, I guess there are no good way. Especially in clustered
environments... My solution was to clear the session dependent
properties on startup of the wicket application, but this would not
work in clustered environment.
johan
On Wed, Apr 16, 2008 at 8:45 PM, Nino Saturnino Martinez Vazquez Wael <
[EMAIL PROTECTED]> wrote:
heres what I ended up with, in application:
private HashMap<String, Session> sessionMap = new HashMap<String,
Session>();
@Override
protected ISessionStore newSessionStore() {
return new SecondLevelCacheSessionStore(this, new DiskPageStore()) {
@Override
protected void onBind(Request request, Session newSession) {
sessionMap.put(newSession.getId(), newSession);
super.onBind(request, newSession);
}
@Override
protected void onUnbind(String sessionId) {
ZeuzSession session = (ZeuzSession)
sessionMap.get(sessionId);
session.onBeforeDestroy();
sessionMap.remove(sessionId);
super.onUnbind(sessionId);
}
};
}
Nino Saturnino Martinez Vazquez Wael wrote:
Thanks for giving the pointer.:)
Warren wrote:
What is wrong with extending HttpSessionStore and overiding
AbstractHttpSessionStore#onBind(Request request, Session newSession)
and
AbstractHttpSessionStore#onUnbind(java.lang.String sessionId)? These
two
methods look like they are there to do exactly what you are talking
about.
Docs on onUnbind says:
"Template method that is called when the session is being detached
from the
store, which typically happens when the httpsession was invalidated."
It is also called when the session becomes expired. Add your sessions
to a
map in onBind and in onUnbind update your pojo and remove the session
from
the map. onUnbind gives you a sessionId. It looks like it was meant to
be
used to look up a session and do something with it.
-----Original Message-----
From: Nino Saturnino Martinez Vazquez Wael
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, April 16, 2008 2:20 AM
To: [email protected]
Subject: Re: Notification on session destroyed?
But I guess there are no easy way todo this one..:/
Nino Saturnino Martinez Vazquez Wael wrote:
I know(hopefully session object should be GC'ed at some time), it
really bothers me that it's such an hard thing todo, being aware
of
session state... So I just wanted an easy way.
jweekend wrote:
Using Object#finalize() for this type of thing is generally NOT
a
good idea;
it may get called much later than you would "expect", if at all.
Regards - Cemal
http://jWeekend.co.uk
Nino.Martinez wrote:
Thanks for the example..
I just think it feels very weird to go around wicket in order
to
achieve this, because the pojo I have are already attached to
the
wicket session(so I would have double overhead for this).
However it
could be the case that it's not simply possible from withing
wicket.
If not, it would be practical to have a method that you could
override on wicket session called onBeforeCreate and
onBeforeDestroy
or something along those lines. Could I use finalize for this?
sander v F wrote:
You could also use a HttpSessionListener for knowing when a
session is
destroyed. The problem is indeed that you can't get the attributes
when
the
session is invalidated, but you can get the sessionId. So
you could
use a
Map to register the session id with the Pojo you would like
to
update. So
when the session get's destroyed you can update the Pojo.
See
http://www.stardeveloper.com/articles/display.html?article=2001112
001&page=1for
an example with the HttpSessionListener.
2008/4/16, Nino Saturnino Martinez Vazquez Wael
<[EMAIL PROTECTED]>:
So what do you think?
Im not sure how common a case this is ?
regards Nino
Nino Saturnino Martinez Vazquez Wael wrote:
Hmm, that feels a bit hacky.. Then I'll need to
implement a way of
tracking sessions, and I saw something about keeping
references to
destroyed
sessions arent that great.
It might be me that's just way of context(not knowing
all of the
internals), but should something like this be easy todo
in wicket?
Like maybe have a onDestroy or onExpire(or both?) in
session class?
However I have no idea on how much overhead this would
bring to
applications
that does not use the feature.
regards Nino
Johan Compagner wrote:
attached to a session of the session that is just
invalided/expired?
That wont work. You cant get to a http sessions
attributes when
it is
invalidated.
To know which session id's are destroyed:
public void sessionDestroyed(String sessionId) of
WebApplication
johan
On Tue, Apr 15, 2008 at 9:07 AM, Nino Saturnino
Martinez Vazquez
Wael
<
[EMAIL PROTECTED]> wrote:
Hi
I've checked a little around, but could not find
anything
directly.
This
is what I want todo:
When a user either logs out or expire I want to
update a pojo
attached to
session.
So does anyone have an example on how todo this(if
possible)?
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
-Wicket for love
Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]