Have CompoundEvent handle propagating setTargetOid() to its internal events and

clean things up for the callers.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4731 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-06-13 23:15:20 +00:00
parent 2fead8208c
commit 2fa6146d93
2 changed files with 19 additions and 25 deletions
@@ -115,25 +115,35 @@ public class CompoundEvent extends DEvent
_events.clear(); _events.clear();
} }
/** @Override // from DEvent
* We need to propagate our source oid to our constituent events.
*/
public void setSourceOid (int sourceOid) public void setSourceOid (int sourceOid)
{ {
super.setSourceOid(sourceOid); super.setSourceOid(sourceOid);
// we need to propagate our source oid to our constituent events
int ecount = _events.size(); int ecount = _events.size();
for (int i = 0; i < ecount; i++) { for (int i = 0; i < ecount; i++) {
_events.get(i).setSourceOid(sourceOid); _events.get(i).setSourceOid(sourceOid);
} }
} }
/** @Override // from DEvent
* Nothing to apply here. public void setTargetOid (int targetOid)
*/ {
super.setTargetOid(targetOid);
// we need to propagate our target oid to our constituent events
int ecount = _events.size();
for (int i = 0; i < ecount; i++) {
_events.get(i).setTargetOid(targetOid);
}
}
@Override // from DEvent
public boolean applyToObject (DObject target) public boolean applyToObject (DObject target)
throws ObjectAccessException throws ObjectAccessException
{ {
// nothing to apply here
return false; return false;
} }
@@ -303,25 +303,6 @@ public class PresentsDObjectMgr
// if this is a runnable, it's just an executable unit that should be invoked // if this is a runnable, it's just an executable unit that should be invoked
((Runnable)unit).run(); ((Runnable)unit).run();
} else if (unit instanceof CompoundEvent) {
CompoundEvent event = (CompoundEvent)unit;
// if this event is on a proxied object, forward it to the owning manager
ProxyReference proxy = _proxies.get(event.getTargetOid());
if (proxy != null) {
// rewrite the oid into the originating manager's id space
event.setTargetOid(proxy.origObjectId);
List<DEvent> events = event.getEvents();
for (int ii = 0, ll = events.size(); ii < ll; ii++) {
events.get(ii).setTargetOid(proxy.origObjectId);
}
// then pass it on to the originating manager to handle
proxy.origManager.postEvent(event);
} else {
processCompoundEvent(event);
}
} else { } else {
DEvent event = (DEvent)unit; DEvent event = (DEvent)unit;
@@ -333,6 +314,9 @@ public class PresentsDObjectMgr
// then pass it on to the originating manager to handle // then pass it on to the originating manager to handle
proxy.origManager.postEvent(event); proxy.origManager.postEvent(event);
} else if (event instanceof CompoundEvent) {
processCompoundEvent((CompoundEvent)event);
} else { } else {
processEvent(event); processEvent(event);
} }