Methods Summary |
---|
public org.jboss.aop.InstanceAdvised | buildObject(SynchronizationManager manager, DistributedVersionManager versionManager)
log.trace("building a Map");
this.versionManager = versionManager;
this.synchManager = manager;
log.trace("DistributedMaptState: classname: " + classname);
Class clazz = Thread.currentThread().getContextClassLoader().loadClass(classname);
base = (Map)clazz.newInstance();
Iterator it = updates.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = (Map.Entry)it.next();
Object val = entry.getValue();
if (val instanceof VersionReference)
{
VersionReference ref = (VersionReference)val;
val = manager.getObject(ref.getGUID());
if (val == null)
{
DistributedState fieldVal = manager.getState(ref.getGUID());
val = fieldVal.buildObject(manager, versionManager);
ref.set((InstanceAdvised)val);
}
}
base.put(entry.getKey(), val);
}
proxy = versionManager.addMapVersioning(base, this);
return proxy;
|
public void | checkOptimisticLock(javax.transaction.Transaction tx)
// NOTE THIS CODE ASSUMES THAT A WRITELOCK HAS BEEN ACQUIRED!!!!
Long version = (Long)txVersion.get(tx);
if (version.longValue() <= versionId)
throw new OptimisticLockFailure("optimistic lock failure for list");
|
public void | clear()
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(true);
state.clear();
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public boolean | containsKey(java.lang.Object o)
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.containsKey(o);
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public boolean | containsValue(java.lang.Object o)
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.containsKey(o);
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
protected java.util.HashMap | createMapUpdates(java.util.Map state)
HashMap mapUpdates = new HashMap();
Iterator it = state.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = (Map.Entry)it.next();
Object obj = entry.getValue();
if (versionManager.isVersioned(obj))
{
mapUpdates.put(entry.getKey(), new VersionReference(VersionManager.getGUID((InstanceAdvised)obj)));
}
else
{
mapUpdates.put(entry.getKey(), obj);
}
}
return mapUpdates;
|
public DistributedUpdate | createTxUpdate(javax.transaction.Transaction tx)
Map state = (Map)txState.get(tx);
long newId = ((Long)txVersion.get(tx)).longValue();
DistributedMapUpdate update = new DistributedMapUpdate(guid, createMapUpdates(state), newId);
return update;
|
public java.util.Set | entrySet()
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.entrySet();
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public boolean | equals(java.lang.Object o)
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.equals(o);
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public java.lang.Object | get(java.lang.Object o)
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.get(o);
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
protected java.util.Map | getCurrentState(boolean forUpdate)
Transaction tx = tm.getTransaction();
if (tx == null)
{
if (forUpdate) versionId++;
return base;
}
Map state = (Map)txState.get(tx);
if (state == null && forUpdate)
{
state = (Map)base.getClass().newInstance();
state.putAll(base);
txState.set(tx, state);
long newId = versionId + 1;
synchManager.registerUpdate(tx, this);
txVersion.set(tx, new Long(newId));
return state;
}
return base;
|
public java.util.HashMap | getMethodMap()
return ClassProxyFactory.getMethodMap(base.getClass().getName());
|
public org.jboss.aop.InstanceAdvised | getObject() return proxy;
|
public int | hashCode()
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.hashCode();
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public boolean | isEmpty()
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.isEmpty();
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public java.util.Set | keySet()
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.keySet();
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public void | mergeState(javax.transaction.Transaction tx)
// NOTE THIS CODE ASSUMES THAT A WRITELOCK HAS BEEN ACQUIRED!!!!
Map current = (Map)txState.get(tx);
base = current;
Long version = (Long)txVersion.get(tx);
versionId = version.longValue();
|
public void | mergeState(DistributedUpdate update)
DistributedMapUpdate mapUpdate = (DistributedMapUpdate)update;
this.versionId = mapUpdate.versionId;
base.clear();
Iterator it = mapUpdate.mapUpdates.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = (Map.Entry)it.next();
Object val = entry.getValue();
if (val instanceof VersionReference)
{
VersionReference ref = (VersionReference)val;
val = synchManager.getObject(ref.getGUID());
ref.set((InstanceAdvised)val);
}
base.put(entry.getKey(), val);
}
updates = mapUpdate.mapUpdates;
|
public java.lang.Object | put(java.lang.Object key, java.lang.Object val)
try
{
lock.readLock().acquire();
try
{
val = versionManager.makeVersioned(val);
Map state = getCurrentState(true);
return state.put(key, val);
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public void | putAll(java.util.Map c)
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(true);
Iterator it = state.entrySet().iterator();
while (it.hasNext())
{
Map.Entry entry = (Map.Entry)it.next();
Object val = versionManager.makeVersioned(entry.getValue());
state.put(entry.getKey(), val);
}
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public void | readExternal(java.io.ObjectInput in)
super.readExternal(in);
versionId = in.readLong();
this.updates = (HashMap)in.readObject();
this.classname = (String)in.readObject();
try
{
InitialContext ctx = new InitialContext();
this.tm = (TransactionManager)ctx.lookup("java:/TransactionManager");
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
this.txState = new TransactionLocal();
this.txVersion = new TransactionLocal();
this.methodMap = mapMethodMap;
|
public java.lang.Object | remove(java.lang.Object key)
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(true);
return state.remove(key);
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public int | size()
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.size();
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public java.util.Collection | values()
try
{
lock.readLock().acquire();
try
{
Map state = getCurrentState(false);
return state.values();
}
finally
{
lock.readLock().release();
}
}
catch (Exception ex)
{
throw new RuntimeException(ex);
}
|
public void | writeExternal(java.io.ObjectOutput out)
super.writeExternal(out);
out.writeLong(versionId);
out.writeObject(updates);
out.writeObject(classname);
|