From f3c03599537de81204a39e889d1ff5aa4e74f49a Mon Sep 17 00:00:00 2001 From: Jamie Doornbos Date: Mon, 28 Feb 2011 19:30:34 +0000 Subject: [PATCH] Allow users of the PersistingUnit to set the desired result from the invoke method rather than having to also override handleSuccess. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@6508 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../threerings/presents/util/PersistingUnit.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/com/threerings/presents/util/PersistingUnit.java b/src/main/java/com/threerings/presents/util/PersistingUnit.java index 505145bbf..9a68663bb 100644 --- a/src/main/java/com/threerings/presents/util/PersistingUnit.java +++ b/src/main/java/com/threerings/presents/util/PersistingUnit.java @@ -79,6 +79,8 @@ public abstract class PersistingUnit extends Invoker.Unit { if (_listener instanceof InvocationService.ConfirmListener) { reportRequestProcessed(); + } else if (_listener instanceof InvocationService.ResultListener && _resultSet) { + reportRequestProcessed(_result); } } @@ -148,7 +150,19 @@ public abstract class PersistingUnit extends Invoker.Unit return this + " failed."; } + /** + * If the service listener is a ResultListener and this method is called, then the given + * result will be passed along to the listener on success. + */ + protected void setResult (Object result) + { + _resultSet = true; + _result = result; + } + protected InvocationService.InvocationListener _listener; protected Exception _error; protected Object[] _args; + protected boolean _resultSet; + protected Object _result; }