Version1 /
Container(redirected from VersionCurrent.Container) commonHost module defines a method that creates an A container that has one or more accessors is a Composite Accessor, which is a type of Swarmlet. Cape CodeCape Code is not setting Cape Code does not call commonHost.instantiate() or instantiateAndInitialize(), instead Cape Code instantiates an Accessor. In the end, the problem comes down to the fact that in Cape Code, we don't have a composite accessor that we can set as the container.
try { _instance = ((Invocable)_engine).invokeFunction( "evaluateCode", getName(), scriptValue); _exports = ((Map)_instance).get("exports"); } catch (Throwable throwable) { throw new IllegalActionException(this, throwable, "Failed to evaluate script."); }
function evaluateCode(accessorName, code) { var bindings = { 'clearInterval': clearInterval, 'clearTimeout': clearTimeout, 'error': error, 'getParameter': getParameter, 'httpRequest': httpRequest, 'input': input, 'output': output, 'parameter': parameter, 'readURL': readURL, 'require': require, 'send': send, 'setDefault': setDefault, 'setInterval': setInterval, 'setParameter': setParameter, 'setTimeout': setTimeout, 'superSend': superSend }; return new commonHost.Accessor(accessorName, code, getAccessorCode, bindings); } Compare that with accessors/hosts/common/commonHost.js instantiate(): Accessor.prototype.instantiate = function(instanceName, accessorClass) { if (!this.getAccessorCode) { throw('instantiate() is not supported by this swarmlet host.'); } // For functions that accessor ports, etc., we want the default implementation // when instantiating the contained accessor. var insideBindings = { 'clearInterval': this.clearInterval, 'clearTimeout': this.clearTimeout, 'error': this.error, 'httpRequest': this.httpRequest, 'readURL': this.readURL, 'require': this.require, 'setInterval': this.setInterval, 'setTimeout': this.setTimeout, }; instanceName = this.accessorName + '.' + instanceName; var containedInstance = instantiateAccessor( instanceName, accessorClass, this.getAccessorCode, insideBindings); containedInstance.container = this; this.containedAccessors.push(containedInstance); return containedInstance; }; It could be seen as a shortcoming that we can't get to the container and that an actor cannot force the container to call wrapup(). However, if we want Cape Code to support non-composite accessors, we probably need it to be this way. Probably we want to modify Cape Code so that there is class that can instantiate and invoke a Composite Accessor that contains only pure accessors. See Also |