commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andy Malakov" <a...@transdecisions.com>
Subject [collections] new feature request: org.apache.commons.collections.map.ReferenceMap (WeakIdentityHashMap)
Date Wed, 28 Jan 2004 19:14:46 GMT
Hello All,

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


Mime
View raw message