Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
private class RemoteService{ protected static var _remoteService:Service = new RemoteService(); protected var _destination:String; protected var _remoteObject:RemoteObject; public function RemoteService(destination:String) { this._destination = destination; this._remoteObject = new RemoteObject(); this._remoteObject.destination = destination; } public static function getInstance():RemoteService { return _remoteService; } public function getOperation(operationName:String, onResult:Function, onError:Function) : Operation { var operation:Operation = _remoteObject.getOperation(operationName) as Operation; operation.addEventListener(ResultEvent.RESULT, onResult); operation.addEventListener(FaultEvent.FAULT, onError); return operation; } }
public class TestProxy{ public static const NAME:String = "TestProxy"; protected var _remoteService:RemoteService; public function TestProxy(){ super(NAME); _remoteService = RemoteService.getInstance(); } public function testOperation():void { var operation:Operation = _remoteService.getOperation("testOperationName", onTestResult, onTestFault); operation.send(); } ...
Ok, so the Multiton Service approach seems good enough.Thank you Cliff.
Well, is a matter of reusability and configuration. With this approach I avoid having to configure RemoteObject destination, timeout, etc. in each proxy. That is what a service/delegator offers.