Software /
code /
prosody
Comparison
core/moduleapi.lua @ 6779:6236668da30a
core.*: Remove use of module() function
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 21 Feb 2015 10:42:19 +0100 |
parent | 6659:0a494394cd3e |
child | 6791:e813e8cf6046 |
child | 7115:805d068d2fd5 |
comparison
equal
deleted
inserted
replaced
6778:4009ae66e0f0 | 6779:6236668da30a |
---|---|
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"; |
143 if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message | 142 if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message |
144 return f(); | 143 return f(); |
145 end | 144 end |
146 | 145 |
147 function api:depends(name) | 146 function api:depends(name) |
147 local modulemanager = require"core.modulemanager"; | |
148 if not self.dependencies then | 148 if not self.dependencies then |
149 self.dependencies = {}; | 149 self.dependencies = {}; |
150 self:hook("module-reloaded", function (event) | 150 self:hook("module-reloaded", function (event) |
151 if self.dependencies[event.module] and not self.reloading then | 151 if self.dependencies[event.module] and not self.reloading then |
152 self:log("info", "Auto-reloading due to reload of %s:%s", event.host, event.module); | 152 self:log("info", "Auto-reloading due to reload of %s:%s", event.host, event.module); |
324 end | 324 end |
325 end | 325 end |
326 end | 326 end |
327 | 327 |
328 function api:get_host_items(key) | 328 function api:get_host_items(key) |
329 local modulemanager = require"core.modulemanager"; | |
329 local result = modulemanager.get_items(key, self.host) or {}; | 330 local result = modulemanager.get_items(key, self.host) or {}; |
330 return result; | 331 return result; |
331 end | 332 end |
332 | 333 |
333 function api:handle_items(item_type, added_cb, removed_cb, existing) | 334 function api:handle_items(item_type, added_cb, removed_cb, existing) |
415 | 416 |
416 function api:measure_global_event(event_name, stat_name) | 417 function api:measure_global_event(event_name, stat_name) |
417 return self:measure_object_event(prosody.events.wrappers, event_name, stat_name); | 418 return self:measure_object_event(prosody.events.wrappers, event_name, stat_name); |
418 end | 419 end |
419 | 420 |
420 function api.init(mm) | |
421 modulemanager = mm; | |
422 return api; | |
423 end | |
424 | |
425 return api; | 421 return api; |