[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Composite Map key and weak reference
adrian@jboss.org
do-not-reply at jboss.com
Tue May 20 11:08:16 EDT 2008
I don't really understand.
If the class references the annotations then all you need to do is make sure
you have something like:
| WeakHashMap<Class<?>, WeakValueHashMap<List<Annotation>, Whatever>>
|
You then need to do a double lookup
Pseudo code (need to check nulls):
| Whatever w = map.get(clazz).get(annotations);
|
This will basically remove the reference when either the initial class or the
"Whatever" instance is GCed.
It don't think it really matters if you have hard refernces on the Annotations classes
in the List since that will also be true while the original Class/ClassLoader or
Whatever holds references?
Of course if you really want to be safe, you could try to create a
WeakCompositeKeyHashMap
which removes the entry when any of the elements in the composite key
gets GCed.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152054#4152054
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152054
More information about the jboss-dev-forums
mailing list