Jukka : thanks for taking time to look through my code. RepositoryUtil.logout(...) takes in parameter 'String sessionId' , not 'String userName'. SessionID is an UUID generated and mapped into SessionWrapper. In my testcases (The code is hosted on google code) the multi session parallel existence and logout (With same user id or different ) is tested. RepositoryUtil, as such will evolve as I build through the application. Currently, each call to login() will return a unique SessionWrapper and as per implementation the application can either call logout() to release the resources or the resource releasing will happen when VM invokes finalize() on the SessionWrapper. I will not call the finalize() strategy robust but that is what I have now :-)
I introduced SessionWrapper exactly to keep and manage different Sessions per thread (Planning to expand the example to a Blogging app.) Thanks Boni -----Original Message----- From: Jukka Zitting [mailto:[EMAIL PROTECTED] Sent: 24 November 2008 15:58 To: [email protected] Subject: Re: Posts on JCR and Jackrabbit Hi, On Mon, Nov 24, 2008 at 9:59 AM, Boni Gopalan (BioImagene) <[EMAIL PROTECTED]> wrote: > http://whiteboardjunkie.wordpress.com/ > > I am writing a series of posts on using JCR in enterprise applications. Nice! > I started writing yesterday. As of now most of the posts are > rudimentary in nature. Please point out mistakes and areas of > improvement. I looked at your "Managing JCR Sessions" post and I'm a bit confused about what you're trying to do. Why is SessionWrapper session = RepositoryUtil.login(username, password); try { ... } finally { RepositoryUtil.logout(username); } better than Session session = repository.login(username, password); try { ... } finally { session.logout(); } ? Also, consider two threads doing the following: SessionWrapper session = RepositoryUtil.login(username, password); session.getRootNode(); RepositoryUtil.logout(username); The following interleaving will break the code: A: SessionWrapper sessionA = RepositoryUtil.login(username, password); B: SessionWrapper sessionB = RepositoryUtil.login(username, password); B: sessionB.getRootNode(); B: RepositoryUtil.logout(username); A: sessionA.getRootNode(); A: RepositoryUtil.logout(username); This wouldn't be a problem if you used normal Repository.login() and Session.logout(). BR, Jukka Zitting
