if (implicitLocking)
{
Iterator i = cld.getCollectionDescriptors().iterator();
while (i.hasNext())
{
CollectionDescriptor cds = (CollectionDescriptor) i.next();
Object col = cds.getPersistentField().get(sourceObject);
if (col != null)
{
CollectionProxy proxy = ProxyHelper.getCollectionProxy(col);
if (proxy != null)
{
if (!proxy.isLoaded())
{
if (log.isDebugEnabled()) log.debug("adding self as listener to collection proxy");
proxy.addListener(this);
registeredCollectionProxies.add(proxy);
continue;
}
}
Iterator colIterator = BrokerHelper.getCollectionIterator(col);
Object item = null;
try
{
while (colIterator.hasNext())
{
item = colIterator.next();
RuntimeObject rt = new RuntimeObject(item, this);
if (rt.isProxy())
{
IndirectionHandler handler = ProxyHelper.getIndirectionHandler(item);
if (!handler.alreadyMaterialized())
{
handler.addListener(this);
continue;
}
else
{
// @todo consider registering to hear when this is
// derefernced instead of just loading here -bmc
item = handler.getRealSubject();
}
}
lockAndRegister(rt, lockMode, true);
}
}
catch (LockNotGrantedException e)
{
String eol = SystemUtils.LINE_SEPARATOR;
log.error("Lock not granted, while lock collection references[" +
eol + "current reference descriptor:" +
eol + cds.toXML() +
eol + "object to lock: " + item +
eol + "main object class: " + sourceObject.getClass().getName() +
eol + "]", e);
throw e;
}