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 Map<String, Session> sessions = new
> > ConcurrentHashMap();
> > > >        private Map<String, 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 Map<String, User> activeUsersMap = new
> > > > ConcurrentHashMap<String,
> > > > > 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]
> >
> >
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to