webinos/Webinos-Platform — pull request #311 by aldafu (2012-11-20 14:56:02+00:00)
Title: Wp 573 dynamically register services

Add support for API modules that can register one or more RPC services
themself. Modules need to export a "Module" constructor which will be
instantiated by the PZP. "Module" instance are required to have a "init"
instance method. This method takes two parameters, a register function and
an unregister function which can be used by the module to register
instantiated RPC services.

This allows API implementations to decide on their own whether to register
a service or not, depending on platform or environment.

Short example for a module implementation:

var MyModule = function(rpcHandler, params) {
this.rpcHandler = rpcHandler;
this.params = params;
};

MyModule.prototype.init = function (register, unregister) {
// instantiate my RPC service, implemented in the same file
var service = new MyService(this.rpcHandler, this.params);
register(service);

// maybe at some later point in time
unregister(service);
};

exports.Module = MyModule;

Jira-issue: http://jira.webinos.org/browse/WP-573