Comparison

core/moduleapi.lua @ 6791:e813e8cf6046

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 20 Aug 2015 13:05:22 +0200
parent 6666:42fdc8dddf04
parent 6779:6236668da30a
child 7116:ecba5fee4867
comparison
equal deleted inserted replaced
6776:4412a2307c89 6791:e813e8cf6046
5 -- This project is MIT/X11 licensed. Please see the 5 -- This project is MIT/X11 licensed. Please see the
6 -- COPYING file in the source package for more information. 6 -- COPYING file in the source package for more information.
7 -- 7 --
8 8
9 local config = require "core.configmanager"; 9 local config = require "core.configmanager";
10 local modulemanager; -- This gets set from modulemanager
11 local array = require "util.array"; 10 local array = require "util.array";
12 local set = require "util.set"; 11 local set = require "util.set";
13 local it = require "util.iterators"; 12 local it = require "util.iterators";
14 local logger = require "util.logger"; 13 local logger = require "util.logger";
15 local pluginloader = require "util.pluginloader"; 14 local pluginloader = require "util.pluginloader";
145 if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message 144 if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message
146 return f(); 145 return f();
147 end 146 end
148 147
149 function api:depends(name) 148 function api:depends(name)
149 local modulemanager = require"core.modulemanager";
150 if not self.dependencies then 150 if not self.dependencies then
151 self.dependencies = {}; 151 self.dependencies = {};
152 self:hook("module-reloaded", function (event) 152 self:hook("module-reloaded", function (event)
153 if self.dependencies[event.module] and not self.reloading then 153 if self.dependencies[event.module] and not self.reloading then
154 self:log("info", "Auto-reloading due to reload of %s:%s", event.host, event.module); 154 self:log("info", "Auto-reloading due to reload of %s:%s", event.host, event.module);
326 end 326 end
327 end 327 end
328 end 328 end
329 329
330 function api:get_host_items(key) 330 function api:get_host_items(key)
331 local modulemanager = require"core.modulemanager";
331 local result = modulemanager.get_items(key, self.host) or {}; 332 local result = modulemanager.get_items(key, self.host) or {};
332 return result; 333 return result;
333 end 334 end
334 335
335 function api:handle_items(item_type, added_cb, removed_cb, existing) 336 function api:handle_items(item_type, added_cb, removed_cb, existing)
435 436
436 function api:measure_global_event(event_name, stat_name) 437 function api:measure_global_event(event_name, stat_name)
437 return self:measure_object_event(prosody.events.wrappers, event_name, stat_name); 438 return self:measure_object_event(prosody.events.wrappers, event_name, stat_name);
438 end 439 end
439 440
440 function api.init(mm)
441 modulemanager = mm;
442 return api;
443 end
444
445 return api; 441 return api;