commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Colebourne" <scolebou...@btopenworld.com>
Subject Re: [collections] new feature request: org.apache.commons.collections.map.ReferenceMap (WeakIdentityHashMap)
Date Wed, 28 Jan 2004 20:18:23 GMT
The ideal solution IMO would be for ReferenceMap to extend the new
AbstractHashedMap class. I wanted to do this but ran out of time before 3.0.
If this was done, the identity part becomes natural in the same way as the
IdentityMap works.

The alternative solution is to just tweak ReferenceMap as you are
suggesting. I reckon the best thing to do is to open a bugzilla ticket and
attach your code, so we can see.

Whatever, it seems like a good addition.

Stephen


----- Original Message -----
From: "Andy Malakov" <andy@transdecisions.com>
> I would like to ask your opinion on providing WeakIdentityHashMap features
to ReferenceMap.
>
>
> Object cache is often implemented using ReferenceMap (WeakHashMap). This
class delegates decision on when to de-cache an objects on
> Java GC.
>
> In many systems Java objects that represent database instances use
database identity: methods Object.equals(Object) and
> Object.hashCode() are redefined to use database identity (identity defined
in terms of object table + object primary keys).
>
> When traditional java.util.Map is used to implement database caches
different instances of the same database objects present a
> problem: instances override each other. Class  java.util.IdentityHashMap
(Apache Collections 3.0: IdentityMap) can be used to solve
> this problem - this approach uses System.identityHashCode() to obtain
reference hashCode and Java comparison operator to compare
> keys (and values).
>
> What I need is functionality of IdentityMap combined with
WeakReference-based keys.
>
> Is it possible to extend ReferenceMap with an ability to use reference
identity instead of object identity? I can send you my
> prototype if you are interested (it adds about ten lines of code to
ReferenceMap).
>
>
>
> Here are some links to Sun's bug parade pages that describe similar
feature request for Java's java.util.WeakHashMap:
>
> http://developer.java.sun.com/developer/bugParade/bugs/4809420.html
> http://developer.java.sun.com/developer/bugParade/bugs/4500542.html
>
> P.S. There is a need for this feature in Apache DB-OJB project.
>
> All the Best,
> Andy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message