lock.acquire();
Object version = null;
long versionId;
try
{
version = new MarshalledValue(currentObject).get();
if (version instanceof Advised)
{
// REVISIT: Currently share the InstanceAdvisor between versions
Advised versionAdvised = (Advised)version;
Advised currentAdvised = (Advised)currentObject;
versionAdvised._setInstanceAdvisor(currentAdvised._getInstanceAdvisor());
}
versionId = ++versionIdGenerator;
}
finally
{
lock.release();
}
tx.registerSynchronization(new VersionSynchronization(tx, versionId, version));
txLocal.set(tx, version);
return version;