org.hydrateframework.event
Class ObjectAccessEventHandler.LazyCollectionEventHandler
java.lang.Object
org.hydrateframework.event.ObjectAccessEventHandler.LazyLoadAccessEventHandler
org.hydrateframework.event.ObjectAccessEventHandler.LazyCollectionEventHandler
- All Implemented Interfaces:
- ObjectAccessEventHandler
- Enclosing interface:
- ObjectAccessEventHandler
public abstract static class ObjectAccessEventHandler.LazyCollectionEventHandler
- extends ObjectAccessEventHandler.LazyLoadAccessEventHandler
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_dsName
protected java.lang.String m_dsName
m_forAttributes
protected java.lang.String[] m_forAttributes
m_collections
protected static java.util.Map<HydrateObject,java.util.Map<java.lang.String,java.util.Collection>> m_collections
ObjectAccessEventHandler.LazyCollectionEventHandler
protected ObjectAccessEventHandler.LazyCollectionEventHandler(java.lang.String dsName,
java.lang.String[] forAttributes)
getWeakCollection
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
- Overrides:
getWeakCollection
in class ObjectAccessEventHandler.LazyLoadAccessEventHandler
- Parameters:
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.
- Returns:
- 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.
getCollection
protected static java.util.Collection getCollection(HydrateObject obj,
java.lang.String attr,
java.lang.Class collClass)
Copyright © 2000 The Hydrate Project. All Rights Reserved.