[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Composite Map key and weak reference

jason.greene@jboss.com do-not-reply at jboss.com
Tue May 20 10:15:00 EDT 2008


So I take it the annotation refs point to annotations on the class ref?
I could see a couple of options:
* You could use a WeakIdentityHM using a Class ref as the key, and a nested normal HM using a key which has an array of weak annotation refs. This would then be wrapped in a delegate which emulates the composite key behavior.
  | 
  | * Use a normal map, of any kind, and extend WeakReference to have an additional strong reference field, that points to your composite key class. Use this special reference for both the Class ref and all of the annotation refs. These are then registered in a ref queue, which is processed to remove gc'd entries periodically when accessing the map (by using the key reference). For this to work the key must do an identity check before comparing its contents (since the contents are gone during cleanup). If the map is concurrent you could do this cleanup in a separate thread.
  | 
 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152028#4152028

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152028



More information about the jboss-dev-forums mailing list