Modified DSet support such that additions, updates and removals are

applied immediately on the authoritative copy of the object (the one on
the server). We already do this for all other object modifications (except
OidList which is kind of special anyway), but we should be wary of
potential wickosity.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2302 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-03-10 18:29:54 +00:00
parent 152344f223
commit ef525ebad9
7 changed files with 126 additions and 28 deletions
@@ -1,5 +1,5 @@
//
// $Id: EntryUpdatedEvent.java,v 1.9 2002/12/20 23:29:04 mdb Exp $
// $Id: EntryUpdatedEvent.java,v 1.10 2003/03/10 18:29:54 mdb Exp $
package com.threerings.presents.dobj;
@@ -27,9 +27,20 @@ public class EntryUpdatedEvent extends NamedEvent
* @param entry the entry to update.
*/
public EntryUpdatedEvent (int targetOid, String name, DSet.Entry entry)
{
this(targetOid, name, entry, null);
}
/**
* Used when the distributed object already updated the entry before
* generating the event.
*/
public EntryUpdatedEvent (int targetOid, String name, DSet.Entry entry,
DSet.Entry oldEntry)
{
super(targetOid, name);
_entry = entry;
_oldEntry = oldEntry;
}
/**
@@ -62,19 +73,20 @@ public class EntryUpdatedEvent extends NamedEvent
public boolean applyToObject (DObject target)
throws ObjectAccessException
{
DSet set = (DSet)target.getAttribute(_name);
if (_oldEntry == null) {
DSet set = (DSet)target.getAttribute(_name);
// fetch the previous value for interested callers
_oldEntry = set.get(_entry.getKey());
// fetch the previous value for interested callers
_oldEntry = set.get(_entry.getKey());
// update the entry
if (!set.update(_entry)) {
// complain if we didn't update anything
Log.warning("No matching entry to update [entry=" + this +
", set=" + set + "].");
return false;
// update the entry
if (!set.update(_entry)) {
// complain if we didn't update anything
Log.warning("No matching entry to update [entry=" + this +
", set=" + set + "].");
return false;
}
}
return true;
}