FileDocCategorySizeDatePackage
VersionedObject.javaAPI DocJBoss 4.2.13790Fri Jul 13 21:02:32 BST 2007org.jboss.aspects.versioned

VersionedObject

public class VersionedObject extends Object
Manages transactional versions of an object versioned object must be Serializable or Cloneable
author
Bill Burke
version
$Revision: 57186 $

Fields Summary
EDU.oswego.cs.dl.util.concurrent.FIFOSemaphore
lock
org.jboss.tm.TransactionLocal
txLocal
long
currentId
Object
currentObject
long
versionIdGenerator
Constructors Summary
public VersionedObject(Object obj)


     
   
      currentObject = obj;
   
Methods Summary
public java.lang.ObjectcreateVersion(javax.transaction.Transaction tx)

      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;
   
public java.lang.ObjectgetVersion(javax.transaction.Transaction tx)

      if (tx == null) return currentObject;
      return txLocal.get(tx);