jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Posts on JCR and Jackrabbit
Date Mon, 24 Nov 2008 10:27:30 GMT
Hi,

On Mon, Nov 24, 2008 at 9:59 AM, Boni Gopalan (BioImagene)
<Boni.G@bioimagene.com> 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

Mime
View raw message