*/
private synchronized void register(Object newTxObject, int lockMode)
throws LockNotGrantedException, PersistenceBrokerException
{
Object objectToRegister = newTxObject;
IndirectionHandler handler = null;
// Proxies must be treated specially
handler = ProxyHelper.getIndirectionHandler(newTxObject);
/*
if the object is a Proxy there are two options:
1. The proxies real subject has already been materialized:
we take this real subject as the object to register and proceed
as if it were a ordinary object.
2. The real subject has not been materialized: Then there is nothing
to be registered now!
Of course we might just materialize the real subject to have something
to register. But this would make proxies useless for ODMG as proxies would
get materialized even if their real subjects were not used by the
client app.
Thus we register the current transaction as a Listener to the IndirectionHandler
of the Proxy.
Only when the IndirectionHandler performs the materialization of the real subject
at some later point in time it invokes callbacks on all it's listeners.
Using this callback we can defer the registering until it's really needed.
*/
if (handler != null)
{
if (handler.alreadyMaterialized())
{
objectToRegister = handler.getRealSubject();
}
else
{
registerToIndirectionHandler(handler);
registerUnmaterializedLocks(newTxObject);