Updated Branches: refs/heads/develop a9cd1ea95 -> 03cf3a2e3
FIX - FLEX-33881 Add option to not store AbstractInvoker last call result updated asdoc not tested with mustella Project: http://git-wip-us.apache.org/repos/asf/flex-sdk/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-sdk/commit/03cf3a2e Tree: http://git-wip-us.apache.org/repos/asf/flex-sdk/tree/03cf3a2e Diff: http://git-wip-us.apache.org/repos/asf/flex-sdk/diff/03cf3a2e Branch: refs/heads/develop Commit: 03cf3a2e3c74cb6181f0ffa6e2a667fe8c907c2b Parents: a9cd1ea Author: mamsellem <[email protected]> Authored: Fri Nov 15 03:19:23 2013 +0100 Committer: mamsellem <[email protected]> Committed: Fri Nov 15 03:19:23 2013 +0100 ---------------------------------------------------------------------- .../projects/rpc/src/mx/rpc/AbstractInvoker.as | 43 ++++++++++++++++++++ .../projects/rpc/src/mx/rpc/AbstractService.as | 33 +++++++++++++++ .../rpc/src/mx/rpc/remoting/RemoteObject.as | 1 + .../src/mx/rpc/remoting/mxml/RemoteObject.as | 1 + .../projects/rpc/src/mx/rpc/soap/WebService.as | 2 + .../rpc/src/mx/rpc/soap/mxml/WebService.as | 1 + 6 files changed, 81 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/03cf3a2e/frameworks/projects/rpc/src/mx/rpc/AbstractInvoker.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/rpc/src/mx/rpc/AbstractInvoker.as b/frameworks/projects/rpc/src/mx/rpc/AbstractInvoker.as index ffc4f5b..5ffcfdf 100644 --- a/frameworks/projects/rpc/src/mx/rpc/AbstractInvoker.as +++ b/frameworks/projects/rpc/src/mx/rpc/AbstractInvoker.as @@ -91,6 +91,45 @@ public class AbstractInvoker extends EventDispatcher // //------------------------------------------------------------------------- + private var _keepLastResult:Boolean = true; + private var _keepLastResultSet: Boolean = false; + + /** Flag indicating whether the operation should keep its last call result for later access. + * <p> If set to true, the last call result will be accessible through <code>lastResult</code> bindable property. </p> + * <p> If set to false, the last call result will be cleared after the call, + * and must be processed in the operation's result handler. + * This will allow the result object to be garbage collected, + * which is especially useful if the operation is only called a few times and returns a large result. </p> + * <p>If not set, will use the <code>keepLastResult</code> value of its owning Service, if any, or the default value.</p> + * @see #lastResult + * @see mx.rpc.AbstractService#keepLastResult + * @default true + * + * @playerversion Flash 10 + * @playerversion AIR 3 + * @productversion Flex 4.11 + */ + public function get keepLastResult():Boolean + { + return _keepLastResult; + } + + public function set keepLastResult(value:Boolean):void + { + _keepLastResult = value; + _keepLastResultSet = true; + } + + /** @private + * sets keepLastResult if not set locally, typically by container Service or RemoteObject + * @param value + */ + mx_internal function setKeepLastResultIfNotSet( value: Boolean):void + { + if (!_keepLastResultSet) + _keepLastResult = value; + } + [Bindable("resultForBinding")] /** @@ -324,6 +363,10 @@ public class AbstractInvoker extends EventDispatcher var resultEvent:ResultEvent = ResultEvent.createEvent(_result, token, event.message); resultEvent.headers = _responseHeaders; dispatchRpcEvent(resultEvent); + // we are done with the result, clear if not kept, for GC + if (!_keepLastResult){ + _result = null; + } } //no else, we assume process would have dispatched the faults if necessary } http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/03cf3a2e/frameworks/projects/rpc/src/mx/rpc/AbstractService.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/rpc/src/mx/rpc/AbstractService.as b/frameworks/projects/rpc/src/mx/rpc/AbstractService.as index 34b4e6b..95599fa 100644 --- a/frameworks/projects/rpc/src/mx/rpc/AbstractService.as +++ b/frameworks/projects/rpc/src/mx/rpc/AbstractService.as @@ -278,6 +278,7 @@ public dynamic class AbstractService extends Proxy implements IEventDispatcher if (!op.name) op.name = i; op.asyncRequest = asyncRequest; + op.setKeepLastResultIfNotSet( _keepLastResult); } _operations = ops; dispatchEvent(new flash.events.Event("operationsChange")); @@ -313,6 +314,38 @@ public dynamic class AbstractService extends Proxy implements IEventDispatcher asyncRequest.requestTimeout = value; } } + + //---------------------------------- + // keepLastResult + //---------------------------------- + protected var _keepLastResult: Boolean = true ; + + + [Inspectable(defaultValue="true", category="General")] + + /** Flag indicating whether the service's operations should keep their last call result for later access. + * <p>Setting this flag at the service level will set <code>keepLastResult</code> for each operation, unless explicitly set in the operation.</p> + * <p> If set to true or not set, each operation's last call result will be accessible through its <code>lastResult</code> bindable property. </p> + * <p> If set to false, each operation's last call result will be cleared after the call, + * and must be processed in the operation's result handler. + * This will allow the result object to be garbage collected, + * which is especially useful if the operation is only called a few times and returns a large result. </p> + * @see mx.rpc.AbstractInvoker#keepLastResult + * @default true + * + * @playerversion Flash 10 + * @playerversion AIR 3 + * @productversion Flex 4.11 + */ + public function get keepLastResult():Boolean + { + return _keepLastResult; + } + + public function set keepLastResult(value:Boolean):void + { + _keepLastResult = value; + } //------------------------------------------------------------------------- // http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/03cf3a2e/frameworks/projects/rpc/src/mx/rpc/remoting/RemoteObject.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/rpc/src/mx/rpc/remoting/RemoteObject.as b/frameworks/projects/rpc/src/mx/rpc/remoting/RemoteObject.as index e583ec5..4475267 100644 --- a/frameworks/projects/rpc/src/mx/rpc/remoting/RemoteObject.as +++ b/frameworks/projects/rpc/src/mx/rpc/remoting/RemoteObject.as @@ -331,6 +331,7 @@ public dynamic class RemoteObject extends AbstractService op = new Operation(this, name); _operations[name] = op; op.asyncRequest = asyncRequest; + op.setKeepLastResultIfNotSet(_keepLastResult); } return op; } http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/03cf3a2e/frameworks/projects/rpc/src/mx/rpc/remoting/mxml/RemoteObject.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/rpc/src/mx/rpc/remoting/mxml/RemoteObject.as b/frameworks/projects/rpc/src/mx/rpc/remoting/mxml/RemoteObject.as index d867ed5..073a433 100644 --- a/frameworks/projects/rpc/src/mx/rpc/remoting/mxml/RemoteObject.as +++ b/frameworks/projects/rpc/src/mx/rpc/remoting/mxml/RemoteObject.as @@ -208,6 +208,7 @@ public dynamic class RemoteObject extends mx.rpc.remoting.RemoteObject implement op = new Operation(this, name); _operations[name] = op; op.asyncRequest = asyncRequest; + op.setKeepLastResultIfNotSet(_keepLastResult); } return op; } http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/03cf3a2e/frameworks/projects/rpc/src/mx/rpc/soap/WebService.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/rpc/src/mx/rpc/soap/WebService.as b/frameworks/projects/rpc/src/mx/rpc/soap/WebService.as index 1f8d231..a95e639 100644 --- a/frameworks/projects/rpc/src/mx/rpc/soap/WebService.as +++ b/frameworks/projects/rpc/src/mx/rpc/soap/WebService.as @@ -198,6 +198,7 @@ public dynamic class WebService extends AbstractWebService op = new Operation(this, name); _operations[name] = op; op.asyncRequest = asyncRequest; + op.setKeepLastResultIfNotSet(_keepLastResult); initializeOperation(op as Operation); } return op; @@ -370,6 +371,7 @@ public dynamic class WebService extends AbstractWebService { var httpService:HTTPService = new HTTPService(); httpService.asyncRequest = asyncRequest; + httpService.setKeepLastResultIfNotSet(_keepLastResult); if (destination) httpService.destination = destination; httpService.useProxy = useProxy; http://git-wip-us.apache.org/repos/asf/flex-sdk/blob/03cf3a2e/frameworks/projects/rpc/src/mx/rpc/soap/mxml/WebService.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/rpc/src/mx/rpc/soap/mxml/WebService.as b/frameworks/projects/rpc/src/mx/rpc/soap/mxml/WebService.as index 75db8c5..4f77030 100644 --- a/frameworks/projects/rpc/src/mx/rpc/soap/mxml/WebService.as +++ b/frameworks/projects/rpc/src/mx/rpc/soap/mxml/WebService.as @@ -327,6 +327,7 @@ public dynamic class WebService extends mx.rpc.soap.WebService implements IMXMLS op = new Operation(this, name); _operations[name] = op; op.asyncRequest = asyncRequest; + op.setKeepLastResultIfNotSet(_keepLastResult); initializeOperation(op as Operation); } return op;
