jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@gmail.com>
Subject Re: Synchronized methods in ItemManager
Date Fri, 14 Sep 2007 15:47:04 GMT
hi martijn,

On 9/14/07, Martijn Hendriks <martijnh@gx.nl> wrote:
> Hi all,
>
> The ItemManager has a small number of synchronized methods such as
> getItem(ItemId id), which is heavily used. I cannot figure out why these
> calls must be synchronized...can somebody give me an idea? Thanks!

the ItemManager maintains a cache of  NodeImpl/PropertyImpl instances.
#getItem(itemId) e.g. is synchronized in order to guarantee the cache
integrity. the following code fragment needs to be synchronized, otherwise
cache entries might get accidentally overwritten:

        // check cache
        ItemImpl item = retrieveItem(id);
        if (item == null) {
            ....
            // create instance of item
            item = createItemInstance(id);
        }

cheers
stefan

>
> Best wishes,
>
> Martijn
>
>
> --
>
> Martijn Hendriks
> <GX> creative online development B.V.
>
> t: 024 - 3888 261
> f: 024 - 3888 621
> e: martijnh@gx.nl
>
> Wijchenseweg 111
> 6538 SW Nijmegen
> http://www.gx.nl/
>

Mime
View raw message