You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Zarar Siddiqi <za...@gmail.com> on 2006/10/08 05:32:04 UTC

Writing a custom session store by implementing ISessionStore

Hello,

My problems with WebSessionStore have been well documented:

1. http://tinyurl.com/jf2o3
2. http://tinyurl.com/ejjte

Basically HttpContext is set to null somewhere along the way inside
IBatis.  So since there is no solution in sight to this problem, I
though of writing a simpler session storage facility which does not
rely on HttpContext but instead stores the sessions in static space.

Luckily, the IBatis source code is written nicely enough to isolate
session storage so it can be pluggable.  I came across the
ISessionStore interface which I'd like to implement by extending
AbstractSessionStore.  So my new class StaticSessionStore extends
ISessionStore and is ready to be used.

The question is how do I make IBatis use StaticSessionStore instead of
WebSessionStore without building IBatis from the source code?

Thanks.
Zarar Siddiqi

Re: Writing a custom session store by implementing ISessionStore

Posted by Zarar Siddiqi <za...@gmail.com>.
Thank you both for your replies.  I'll try CallContextSessionStore
first and see how it goes.  If it doesn't do the job, then I'll go
with the patch.

I noticed the following code in SessionStoreFactory.GetSessionStore():

   if (System.Web.HttpContext.Current == null) {
      return new CallContextSessionStore(sqlMapperId);
   } else {
      return new WebSessionStore(sqlMapperId);
   }

This tells me that the ONLY way one can use CallContextSessionStore is
by manually setting the HttpContext to null when initializing IBatis
(I'm assuming right before the call to Configure or
ConfigureAndWatch).  Is this true or is there a better solution?  I'm
just not too sure about the side effects of setting HttpContext to
null.

Thanks,
Zarar Siddiqi


On 10/8/06, Gilles Bayon <ib...@gmail.com> wrote:
> Currently, there's no way to specify a custom session store.
> You don't have to impelment a new one; is already exist, see
> CallContextSessionStore.cs.
>
> You must not use an other ISessionStore than WebSessionStore as you
> may suffer lost of session.
>
> --
> Cheers,
> Gilles
>
> <a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>
>

Re: Writing a custom session store by implementing ISessionStore

Posted by Gilles Bayon <ib...@gmail.com>.
Currently, there's no way to specify a custom session store.
You don't have to impelment a new one; is already exist, see
CallContextSessionStore.cs.

You must not use an other ISessionStore than WebSessionStore as you
may suffer lost of session.

-- 
Cheers,
Gilles

<a href="http://www.amazon.com/gp/registry/6JCP7AORB0LE">Wish List</a>