RE: Get informed about invalidation of a session
Hi Warren, thanks for your answer. But I'm not sure how I could use this. The information that I need to access are stored in the session. How can I access a single instance of this session from the session store? Thanks, Sebastian -- View this message in context: http://www.nabble.com/Get-informed-about-invalidation-of-a-session-tp16447452p16466115.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Get informed about invalidation of a session
thats impossible If a session is invalidated you can't access the attributes anymore (or call getId() at least that is or will be solved in the coming servlet spec) johan On Thu, Apr 3, 2008 at 8:51 AM, BatiB80 [EMAIL PROTECTED] wrote: Hi Warren, thanks for your answer. But I'm not sure how I could use this. The information that I need to access are stored in the session. How can I access a single instance of this session from the session store? Thanks, Sebastian -- View this message in context: http://www.nabble.com/Get-informed-about-invalidation-of-a-session-tp16447452p16466115.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Get informed about invalidation of a session
I am extending HttpSessionStore and keeping track of my sessions there. I am able to get a hold of members of my Session while it is being invalidated. I am not quite sure what you mean by on the unBind() / onDestroy the actual session object does not exist anymore, the session seems to be available and I am able to access members of it as long as I store the Session in onBind(...). This is what I am doing: public class ScanManSessionStore extends HttpSessionStore { ... private MapString, Session sessions = new ConcurrentHashMap(); private MapString, Device devices = new ConcurrentHashMap(); protected void onBind(Request request, Session newSession) { sessions.put(newSession.getId(), newSession); } protected void onUnbind(String sessionId) { if(sessions.containsKey(sessionId)) { Device device = ((ScanManSession)sessions.get(sessionId)).getDevice(); if(device != null) { devices.remove(device.getDeviceId()); } sessions.remove(sessionId); } } ... } Please let me know if there is a problem doing it this way. Warren -Original Message- From: Robert Novotny [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 3:37 AM To: users@wicket.apache.org Subject: RE: Get informed about invalidation of a session This has been discussed multiple times and the only reasonable solution that I found (and just implemented) is to have a concurrent hashmap of session ids into session objects in the custom Application class. The reason is that on the unBind() / onDestroy the actual session object does not exist anymore - the only thing you have is the destroyed session ID. I needed to persist some user info on the logout. My solution goes like this: public class DavanoApplication extends org.apache.wicket.protocol.http.WebApplication { private MapString, User activeUsersMap = new ConcurrentHashMapString, User(); ... @Override public void sessionDestroyed(String sessionId) { User user = activeUsersMap.get(sessionId); if(user != null) { userDao.saveOrUpdate(user); userDao.updateLastLogin(user); activeUsersMap.remove(sessionId); } super.sessionDestroyed(sessionId); } } I am not sure whether this is correct solution, but it did help me. Robert BatiB80 wrote: Hi Warren, thanks for your answer. But I'm not sure how I could use this. The information that I need to access are stored in the session. How can I access a single instance of this session from the session store? Thanks, Sebastian -- View this message in context: http://www.nabble.com/Get-informed-about-invalidation-of-a-session -tp16447452p16467385.html Sent from the Wicket - User mailing list archive at Nabble.com. - 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]
Re: Get informed about invalidation of a session
when a session is invalidated you cant call get or set attribute anymore on it also holding on the sessions outside of request is not something you should do On Thu, Apr 3, 2008 at 5:51 PM, Warren [EMAIL PROTECTED] wrote: I am extending HttpSessionStore and keeping track of my sessions there. I am able to get a hold of members of my Session while it is being invalidated. I am not quite sure what you mean by on the unBind() / onDestroy the actual session object does not exist anymore, the session seems to be available and I am able to access members of it as long as I store the Session in onBind(...). This is what I am doing: public class ScanManSessionStore extends HttpSessionStore { ... private MapString, Session sessions = new ConcurrentHashMap(); private MapString, Device devices = new ConcurrentHashMap(); protected void onBind(Request request, Session newSession) { sessions.put(newSession.getId(), newSession); } protected void onUnbind(String sessionId) { if(sessions.containsKey(sessionId)) { Device device = ((ScanManSession)sessions.get(sessionId)).getDevice(); if(device != null) { devices.remove(device.getDeviceId()); } sessions.remove(sessionId); } } ... } Please let me know if there is a problem doing it this way. Warren -Original Message- From: Robert Novotny [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 3:37 AM To: users@wicket.apache.org Subject: RE: Get informed about invalidation of a session This has been discussed multiple times and the only reasonable solution that I found (and just implemented) is to have a concurrent hashmap of session ids into session objects in the custom Application class. The reason is that on the unBind() / onDestroy the actual session object does not exist anymore - the only thing you have is the destroyed session ID. I needed to persist some user info on the logout. My solution goes like this: public class DavanoApplication extends org.apache.wicket.protocol.http.WebApplication { private MapString, User activeUsersMap = new ConcurrentHashMapString, User(); ... @Override public void sessionDestroyed(String sessionId) { User user = activeUsersMap.get(sessionId); if(user != null) { userDao.saveOrUpdate(user); userDao.updateLastLogin(user); activeUsersMap.remove(sessionId); } super.sessionDestroyed(sessionId); } } I am not sure whether this is correct solution, but it did help me. Robert BatiB80 wrote: Hi Warren, thanks for your answer. But I'm not sure how I could use this. The information that I need to access are stored in the session. How can I access a single instance of this session from the session store? Thanks, Sebastian -- View this message in context: http://www.nabble.com/Get-informed-about-invalidation-of-a-session -tp16447452p16467385.html Sent from the Wicket - User mailing list archive at Nabble.com. - 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]
RE: Get informed about invalidation of a session
Can't I rely on HttpSessionStore#onBind(...) and HttpSessionStore#onUnbind(...) to manage a ConcurrentHashMap() of Sessions? I remove the session in onUnbind(). And doesn't invalidating and onUnbind() happen in the same request?. I have some special use cases that require one device to communicate with another, logging off all users at once and only allowing no more than 100 devices to be logged on at a time. -Original Message- From: Johan Compagner [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 12:52 PM To: users@wicket.apache.org Subject: Re: Get informed about invalidation of a session when a session is invalidated you cant call get or set attribute anymore on it also holding on the sessions outside of request is not something you should do On Thu, Apr 3, 2008 at 5:51 PM, Warren [EMAIL PROTECTED] wrote: I am extending HttpSessionStore and keeping track of my sessions there. I am able to get a hold of members of my Session while it is being invalidated. I am not quite sure what you mean by on the unBind() / onDestroy the actual session object does not exist anymore, the session seems to be available and I am able to access members of it as long as I store the Session in onBind(...). This is what I am doing: public class ScanManSessionStore extends HttpSessionStore { ... private MapString, Session sessions = new ConcurrentHashMap(); private MapString, Device devices = new ConcurrentHashMap(); protected void onBind(Request request, Session newSession) { sessions.put(newSession.getId(), newSession); } protected void onUnbind(String sessionId) { if(sessions.containsKey(sessionId)) { Device device = ((ScanManSession)sessions.get(sessionId)).getDevice(); if(device != null) { devices.remove(device.getDeviceId()); } sessions.remove(sessionId); } } ... } Please let me know if there is a problem doing it this way. Warren -Original Message- From: Robert Novotny [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 3:37 AM To: users@wicket.apache.org Subject: RE: Get informed about invalidation of a session This has been discussed multiple times and the only reasonable solution that I found (and just implemented) is to have a concurrent hashmap of session ids into session objects in the custom Application class. The reason is that on the unBind() / onDestroy the actual session object does not exist anymore - the only thing you have is the destroyed session ID. I needed to persist some user info on the logout. My solution goes like this: public class DavanoApplication extends org.apache.wicket.protocol.http.WebApplication { private MapString, User activeUsersMap = new ConcurrentHashMapString, User(); ... @Override public void sessionDestroyed(String sessionId) { User user = activeUsersMap.get(sessionId); if(user != null) { userDao.saveOrUpdate(user); userDao.updateLastLogin(user); activeUsersMap.remove(sessionId); } super.sessionDestroyed(sessionId); } } I am not sure whether this is correct solution, but it did help me. Robert BatiB80 wrote: Hi Warren, thanks for your answer. But I'm not sure how I could use this. The information that I need to access are stored in the session. How can I access a single instance of this session from the session store? Thanks, Sebastian -- View this message in context: http://www.nabble.com/Get-informed-about-invalidation-of-a-session -tp16447452p16467385.html Sent from the Wicket - User mailing list archive at Nabble.com. - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Get informed about invalidation of a session
that there only can be 100 can be checked by just having a counter And communication should just be pulled from a central data object you shouldn't push that in into the session objects (same for logging off) Ofcourse this can all work but you dont know what the container does and failover or loadbalanching is also out. invalidating can happen anytime. In a request and when there is no request (session time out) johan On Thu, Apr 3, 2008 at 10:49 PM, Warren [EMAIL PROTECTED] wrote: Can't I rely on HttpSessionStore#onBind(...) and HttpSessionStore#onUnbind(...) to manage a ConcurrentHashMap() of Sessions? I remove the session in onUnbind(). And doesn't invalidating and onUnbind() happen in the same request?. I have some special use cases that require one device to communicate with another, logging off all users at once and only allowing no more than 100 devices to be logged on at a time. -Original Message- From: Johan Compagner [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 12:52 PM To: users@wicket.apache.org Subject: Re: Get informed about invalidation of a session when a session is invalidated you cant call get or set attribute anymore on it also holding on the sessions outside of request is not something you should do On Thu, Apr 3, 2008 at 5:51 PM, Warren [EMAIL PROTECTED] wrote: I am extending HttpSessionStore and keeping track of my sessions there. I am able to get a hold of members of my Session while it is being invalidated. I am not quite sure what you mean by on the unBind() / onDestroy the actual session object does not exist anymore, the session seems to be available and I am able to access members of it as long as I store the Session in onBind(...). This is what I am doing: public class ScanManSessionStore extends HttpSessionStore { ... private MapString, Session sessions = new ConcurrentHashMap(); private MapString, Device devices = new ConcurrentHashMap(); protected void onBind(Request request, Session newSession) { sessions.put(newSession.getId(), newSession); } protected void onUnbind(String sessionId) { if(sessions.containsKey(sessionId)) { Device device = ((ScanManSession)sessions.get(sessionId)).getDevice(); if(device != null) { devices.remove(device.getDeviceId()); } sessions.remove(sessionId); } } ... } Please let me know if there is a problem doing it this way. Warren -Original Message- From: Robert Novotny [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 3:37 AM To: users@wicket.apache.org Subject: RE: Get informed about invalidation of a session This has been discussed multiple times and the only reasonable solution that I found (and just implemented) is to have a concurrent hashmap of session ids into session objects in the custom Application class. The reason is that on the unBind() / onDestroy the actual session object does not exist anymore - the only thing you have is the destroyed session ID. I needed to persist some user info on the logout. My solution goes like this: public class DavanoApplication extends org.apache.wicket.protocol.http.WebApplication { private MapString, User activeUsersMap = new ConcurrentHashMapString, User(); ... @Override public void sessionDestroyed(String sessionId) { User user = activeUsersMap.get(sessionId); if(user != null) { userDao.saveOrUpdate(user); userDao.updateLastLogin(user); activeUsersMap.remove(sessionId); } super.sessionDestroyed(sessionId); } } I am not sure whether this is correct solution, but it did help me. Robert BatiB80 wrote: Hi Warren, thanks for your answer. But I'm not sure how I could use this. The information that I need to access are stored in the session. How can I access a single instance of this session from the session store? Thanks, Sebastian -- View this message in context: http://www.nabble.com/Get-informed-about-invalidation-of-a-session -tp16447452p16467385.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
RE: Get informed about invalidation of a session
Just for my information, what would be some of the uses of AbstractHttpSessionStore#onBind(...) and AbstractHttpSessionStore#onUnbind(...)? It looks like they are there to manage sessions in some way. My use cases are a little more complicated, but you made some good points and I do need to rethink how I am doing things. Thanks, Warren -Original Message- From: Johan Compagner [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 1:56 PM To: users@wicket.apache.org Subject: Re: Get informed about invalidation of a session that there only can be 100 can be checked by just having a counter And communication should just be pulled from a central data object you shouldn't push that in into the session objects (same for logging off) Ofcourse this can all work but you dont know what the container does and failover or loadbalanching is also out. invalidating can happen anytime. In a request and when there is no request (session time out) johan On Thu, Apr 3, 2008 at 10:49 PM, Warren [EMAIL PROTECTED] wrote: Can't I rely on HttpSessionStore#onBind(...) and HttpSessionStore#onUnbind(...) to manage a ConcurrentHashMap() of Sessions? I remove the session in onUnbind(). And doesn't invalidating and onUnbind() happen in the same request?. I have some special use cases that require one device to communicate with another, logging off all users at once and only allowing no more than 100 devices to be logged on at a time. -Original Message- From: Johan Compagner [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 12:52 PM To: users@wicket.apache.org Subject: Re: Get informed about invalidation of a session when a session is invalidated you cant call get or set attribute anymore on it also holding on the sessions outside of request is not something you should do On Thu, Apr 3, 2008 at 5:51 PM, Warren [EMAIL PROTECTED] wrote: I am extending HttpSessionStore and keeping track of my sessions there. I am able to get a hold of members of my Session while it is being invalidated. I am not quite sure what you mean by on the unBind() / onDestroy the actual session object does not exist anymore, the session seems to be available and I am able to access members of it as long as I store the Session in onBind(...). This is what I am doing: public class ScanManSessionStore extends HttpSessionStore { ... private MapString, Session sessions = new ConcurrentHashMap(); private MapString, Device devices = new ConcurrentHashMap(); protected void onBind(Request request, Session newSession) { sessions.put(newSession.getId(), newSession); } protected void onUnbind(String sessionId) { if(sessions.containsKey(sessionId)) { Device device = ((ScanManSession)sessions.get(sessionId)).getDevice(); if(device != null) { devices.remove(device.getDeviceId()); } sessions.remove(sessionId); } } ... } Please let me know if there is a problem doing it this way. Warren -Original Message- From: Robert Novotny [mailto:[EMAIL PROTECTED] Sent: Thursday, April 03, 2008 3:37 AM To: users@wicket.apache.org Subject: RE: Get informed about invalidation of a session This has been discussed multiple times and the only reasonable solution that I found (and just implemented) is to have a concurrent hashmap of session ids into session objects in the custom Application class. The reason is that on the unBind() / onDestroy the actual session object does not exist anymore - the only thing you have is the destroyed session ID. I needed to persist some user info on the logout. My solution goes like this: public class DavanoApplication extends org.apache.wicket.protocol.http.WebApplication { private MapString, User activeUsersMap = new ConcurrentHashMapString, User(); ... @Override public void sessionDestroyed(String sessionId) { User user = activeUsersMap.get(sessionId); if(user != null) { userDao.saveOrUpdate(user); userDao.updateLastLogin(user); activeUsersMap.remove(sessionId); } super.sessionDestroyed(sessionId); } } I am not sure whether this is correct solution, but it did help me. Robert BatiB80 wrote: Hi Warren, thanks
RE: Get informed about invalidation of a session
I am doing kind of the same thing in HttpSessionStore#onUnbind(String sessionId), but I have to keep track of all the sessions. I have a use case that requires me to log off everyone at once. Hope this helps you. -Original Message- From: BatiB80 [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 02, 2008 10:11 AM To: users@wicket.apache.org Subject: Get informed about invalidation of a session Hi together, I want to store some user related information (something like last viewed articles) in the session instance for this user. During one session I simply store the information directly in the session. But when the session is being invaldidated I want to persist the information in the database. Therefore I need to get informed when a session is being invalidated. Does anybody know how I can reach this? Thanks in advance, Sebastian -- View this message in context: http://www.nabble.com/Get-informed-about-invalidation-of-a-session -tp16447452p16447452.html Sent from the Wicket - User mailing list archive at Nabble.com. - 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]