Some of my recent developments have driven further development of some neat utility classes to provide much needed functionality, not available elsewhere.
org.apache.river.impl.util.ConcurrentCollections has a number of static methods which provide multi read single write lock wrapper classes for Collection, List and Set. I've also got Reference wrappers for Collection, List, Set, Map and ConcurrentMap. The References allow the developer to select from weak, weak identity, soft, soft identity and strong References to be used for values and keys. These classes are fully functional and include unit tests, although I haven't committed them. These wrappers allow the developer to mix and match any existing collections classes and use them with various reference types. One of my favourites is to use a ConcurrentHashMap cache with Weak keys and Soft values. The weak keys ensure the map entrys are removed as soon as the key is no longer referenced, while the soft value ensures the cache is cleared under low memory conditions, even while the keys remain strongly referenced. This provides a better performance compromise, instead of the cache causing a big slowdown as the jvm runs low on memory, the memory is freed and more cpu is consumed instead, as a result the application slows but less so than if memory was starved. Using weak sets is also useful for object pooling. The use of references is completely abstracted, so these can be used in place of other Collections, Maps, Lists etc. The public api is very minimal and simple to use. Objects are removed automatically when they become eligible for garbage collection. The references themselves are not public classes and extend existing java Reference classes and override equals, hashCode and toString, according to their defined contracts. The reference types are chosen using an enum, so the various implementations don't need to clutter the public api. This enables you to print a weak List or Map as you would an ArrayList or HashMap and have objects contained within these collections behave as they would in standard java collections. Iterators, sub lists, Map.Entry Sets and all api features supported by the underlying Collection classes are fully implemented. These utilities seem like they belong in a Collection utilities library, which is why I havent committed them, however I don't have the time to manage a separate project either. Any ideas what to do with these classes? Cheers, Peter.