Class ObjectAccessEventHandler.LazyCollectionEventHandler

  extended by org.hydrateframework.event.ObjectAccessEventHandler.LazyLoadAccessEventHandler
      extended by org.hydrateframework.event.ObjectAccessEventHandler.LazyCollectionEventHandler
All Implemented Interfaces:
Enclosing interface:

public abstract static class ObjectAccessEventHandler.LazyCollectionEventHandler
extends ObjectAccessEventHandler.LazyLoadAccessEventHandler

Nested Class Summary
Nested classes/interfaces inherited from interface org.hydrateframework.event.ObjectAccessEventHandler
ObjectAccessEventHandler.EmptyAccessEventHandler, ObjectAccessEventHandler.LazyCollectionEventHandler, ObjectAccessEventHandler.LazyLoadAccessEventHandler, ObjectAccessEventHandler.WaitForPopulationEventHandler
Field Summary
protected static java.util.Map<HydrateObject,java.util.Map<java.lang.String,java.util.Collection>> m_collections
protected  java.lang.String m_dsName
protected  java.lang.String[] m_forAttributes
Fields inherited from class org.hydrateframework.event.ObjectAccessEventHandler.LazyLoadAccessEventHandler
Constructor Summary
protected ObjectAccessEventHandler.LazyCollectionEventHandler(java.lang.String dsName, java.lang.String[] forAttributes)
Method Summary
protected static java.util.Collection getCollection(HydrateObject obj, java.lang.String attr, java.lang.Class collClass)
 java.util.Collection getWeakCollection(HydrateObject obj, java.lang.String attr, java.lang.Class collClass)
          This method is needed to resolve the obscure, but tricky relationship between autoload references and lazy loading.
Methods inherited from class org.hydrateframework.event.ObjectAccessEventHandler.LazyLoadAccessEventHandler
attributeNotLoaded, collectionNotLoaded
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


protected java.lang.String m_dsName


protected java.lang.String[] m_forAttributes


protected static java.util.Map<HydrateObject,java.util.Map<java.lang.String,java.util.Collection>> m_collections
Constructor Detail


protected ObjectAccessEventHandler.LazyCollectionEventHandler(java.lang.String dsName,
                                                              java.lang.String[] forAttributes)
Method Detail


public java.util.Collection getWeakCollection(HydrateObject obj,
                                              java.lang.String attr,
                                              java.lang.Class collClass)
Description copied from interface: ObjectAccessEventHandler
This method is needed to resolve the obscure, but tricky relationship between autoload references and lazy loading. Our problem is that on loading objects we often implicitly fix up back references to unloaded collections. However, this gets in the way of the lazy loading of collections because either the collection will try and load when the back reference is created, or it will block subsequent implicit loading of the full collection afterwards. The solution is to permit weakly referenced collections that are not part of the class until explicity created but can keep track of these back references in the meantime. This method requests the creation (or resolution) of such a weakly referenced collection. These collections should always disappear as soon as the object they belong to is eligible for garbage collection

Specified by:
getWeakCollection in interface ObjectAccessEventHandler
getWeakCollection in class ObjectAccessEventHandler.LazyLoadAccessEventHandler
obj - the hydrate object that needs a collection. Don't even start thinking about getting this to work with non-Hydrate objects.
attr - the name of the attribute (must be the static reference from the interface)
collClass - the class of the collection that would be created if there is none available.
this method should return null if it doesn't implement collectionNotLoaded i.e. doesn't concern itself with lazy loading of collections. If it does, it must return a collection that 'belongs' to the given object. In other words, subsequent calls to this method must return the same collection, but that collection must be eligible for garbage collection when the object reference goes out of scope.


protected static java.util.Collection getCollection(HydrateObject obj,
                                                    java.lang.String attr,
                                                    java.lang.Class collClass)

Copyright © 2000 The Hydrate Project. All Rights Reserved.