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

LocalSynchronizationManager

public class LocalSynchronizationManager extends Object implements SynchronizationManager
author
Bill Burke
version
$Revision: 57186 $

Fields Summary
protected static Logger
log
protected org.jboss.tm.TransactionLocal
txSynch
protected Object
tableLock
protected Hashtable
objectTable
protected Hashtable
stateTable
protected DistributedVersionManager
versionManager
Constructors Summary
public LocalSynchronizationManager(DistributedVersionManager versionManager)


     
   
      this.versionManager = versionManager;
   
Methods Summary
protected voidacquireRemoteLocks(org.jboss.util.id.GUID globalTxId, java.util.List guids)

      // HOOKS FOR DISTRIBUTION
   
public voidcreateObjects(java.util.List newObjects)

      log.trace("in create Objects");
      for (int i = 0; i < newObjects.size(); i++)
      {
         DistributedState state = (DistributedState)newObjects.get(i);
         synchronized (tableLock)
         {
            objectTable.put(state.getGUID(), new WeakReference(state.getObject()));
            stateTable.put(state.getGUID(), state);
         }
      }
      sendNewObjects(newObjects);
   
public java.lang.ObjectgetObject(org.jboss.util.id.GUID guid)

      synchronized (tableLock)
      {
         WeakReference ref = (WeakReference)objectTable.get(guid);
         if (ref != null)
         {
            return ref.get();
         }
         return null;
      }
   
public DistributedStategetState(org.jboss.util.id.GUID guid)

      synchronized (tableLock)
      {
         return (DistributedState)stateTable.get(guid);
      }
   
public voidnoTxUpdate(DistributedUpdate update)

      // HOOKS FOR DISTRIBUTION
   
public voidputObject(org.jboss.util.id.GUID guid, java.lang.Object obj)

      synchronized (tableLock)
      {
         objectTable.put(guid, new WeakReference(obj));
      }
   
public voidputState(org.jboss.util.id.GUID guid, java.lang.Object obj)

      synchronized (tableLock)
      {
         stateTable.put(guid, obj);
      }
   
public voidregisterUpdate(javax.transaction.Transaction tx, DistributedState state)

      if (tx == null) return;
      GUID guid = state.getGUID();
      DistributedStateSynchronization synch = (DistributedStateSynchronization)txSynch.get(tx);
      if (synch == null)
      {
         synch = new DistributedStateSynchronization(tx);
         txSynch.set(tx, synch);
         tx.registerSynchronization(synch);
         synch.updates().put(guid, state);
         return;
      }
      if (synch.updates().containsKey(guid)) return;
      synch.updates().put(guid, state);
   
protected voidreleaseHeldLocks(java.util.List locks)

      log.trace("releaseHeldLocks");
      for (int i = 0; i < locks.size(); i++)
      {
         try
         {
            DistributedState state = (DistributedState)locks.get(i);
            state.releaseWriteLock();
         }
         catch (Exception ignored)
         {
            // ignore exception because we want to release everything no matter what
         }
      }
      log.trace("end releaseHeldLocks");
   
protected voidsendClusterUpdatesAndRelease(org.jboss.util.id.GUID globalTxId, java.util.List clusterUpdates)

      // HOOKS FOR DISTRIBUTION
   
public voidsendNewObjects(java.util.List newObjects)

      // NOT YET IMPLEMENTED