Software / code / prosody
Comparison
core/modulemanager.lua @ 1360:857034905016
modulemanager: Changed to use util.pluginloader
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Sun, 14 Jun 2009 21:03:59 +0500 |
| parent | 1346:e34f9455b779 |
| child | 1361:4e56889c33e1 |
comparison
equal
deleted
inserted
replaced
| 1359:015d624a2a71 | 1360:857034905016 |
|---|---|
| 16 local eventmanager = require "core.eventmanager"; | 16 local eventmanager = require "core.eventmanager"; |
| 17 local config = require "core.configmanager"; | 17 local config = require "core.configmanager"; |
| 18 local multitable_new = require "util.multitable".new; | 18 local multitable_new = require "util.multitable".new; |
| 19 local register_actions = require "core.actions".register; | 19 local register_actions = require "core.actions".register; |
| 20 local st = require "util.stanza"; | 20 local st = require "util.stanza"; |
| 21 local pluginloader = require "util.pluginloader"; | |
| 21 | 22 |
| 22 local hosts = hosts; | 23 local hosts = hosts; |
| 23 local prosody = prosody; | 24 local prosody = prosody; |
| 24 | 25 |
| 25 local loadfile, pcall = loadfile, pcall; | 26 local loadfile, pcall = loadfile, pcall; |
| 111 elseif modulemap["*"][module_name] then | 112 elseif modulemap["*"][module_name] then |
| 112 return nil, "global-module-already-loaded"; | 113 return nil, "global-module-already-loaded"; |
| 113 end | 114 end |
| 114 | 115 |
| 115 | 116 |
| 116 local mod, err = loadfile(get_module_filename(module_name)); | 117 local mod, err = pluginloader.load_code(module_name); |
| 117 if not mod then | 118 if not mod then |
| 118 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); | 119 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); |
| 119 return nil, err; | 120 return nil, err; |
| 120 end | 121 end |
| 121 | 122 |
| 185 | 186 |
| 186 function reload(host, name, ...) | 187 function reload(host, name, ...) |
| 187 local mod = get_module(host, name); | 188 local mod = get_module(host, name); |
| 188 if not mod then return nil, "module-not-loaded"; end | 189 if not mod then return nil, "module-not-loaded"; end |
| 189 | 190 |
| 190 local _mod, err = loadfile(get_module_filename(name)); -- checking for syntax errors | 191 local _mod, err = pluginloader.load_code(name); -- checking for syntax errors |
| 191 if not _mod then | 192 if not _mod then |
| 192 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); | 193 log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil"); |
| 193 return nil, err; | 194 return nil, err; |
| 194 end | 195 end |
| 195 | 196 |