aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2022-02-04 14:11:46 +0000
committerMatthew Wild <mwild1@gmail.com>2022-02-04 14:11:46 +0000
commit4bdff5a4529443c19df04f16ee35939ef324f516 (patch)
tree5afea32ca250c285372ed73754c42ddeb78020a5 /core
parentfdfaff07e0a21e457e6c206c9e269f63efcac256 (diff)
downloadprosody-4bdff5a4529443c19df04f16ee35939ef324f516.tar.gz
prosody-4bdff5a4529443c19df04f16ee35939ef324f516.zip
modulemanager, moduleapi: Switch to new pluginloader interface
Diffstat (limited to 'core')
-rw-r--r--core/moduleapi.lua4
-rw-r--r--core/modulemanager.lua9
2 files changed, 9 insertions, 4 deletions
diff --git a/core/moduleapi.lua b/core/moduleapi.lua
index 24d99c69..071dabc2 100644
--- a/core/moduleapi.lua
+++ b/core/moduleapi.lua
@@ -10,7 +10,6 @@ local array = require "util.array";
local set = require "util.set";
local it = require "util.iterators";
local logger = require "util.logger";
-local pluginloader = require "util.pluginloader";
local timer = require "util.timer";
local resolve_relative_path = require"util.paths".resolve_relative_path;
local st = require "util.stanza";
@@ -129,7 +128,8 @@ function api:wrap_global(event, handler)
end
function api:require(lib)
- local f, n = pluginloader.load_code_ext(self.name, lib, "lib.lua", self.environment);
+ local modulemanager = require"core.modulemanager";
+ local f, n = modulemanager.loader:load_code_ext(self.name, lib, "lib.lua", self.environment);
if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message
return f();
end
diff --git a/core/modulemanager.lua b/core/modulemanager.lua
index 03dd60a6..436ee378 100644
--- a/core/modulemanager.lua
+++ b/core/modulemanager.lua
@@ -52,6 +52,9 @@ local _G = _G;
local _ENV = nil;
-- luacheck: std none
+local loader = pluginloader.init({
+});
+
local load_modules_for_host, load, unload, reload, get_module, get_items;
local get_modules, is_loaded, module_has_method, call_module_method;
@@ -184,7 +187,7 @@ local function do_load_module(host, module_name, state)
local pluginenv = setmetatable({ module = api_instance }, { __index = _G });
api_instance.environment = pluginenv;
- local mod, err = pluginloader.load_code(module_name, nil, pluginenv);
+ local mod, err = loader:load_code(module_name, nil, pluginenv);
if not mod then
log("error", "Unable to load module '%s': %s", module_name or "nil", err or "nil");
api_instance:set_status("error", "Failed to load (see log)");
@@ -271,7 +274,7 @@ local function do_reload_module(host, name)
local mod = get_module(host, name);
if not mod then return nil, "module-not-loaded"; end
- local _mod, err = pluginloader.load_code(name); -- checking for syntax errors
+ local _mod, err = loader:load_code(name); -- checking for syntax errors
if not _mod then
log("error", "Unable to load module '%s': %s", name or "nil", err or "nil");
return nil, err;
@@ -395,4 +398,6 @@ return {
is_loaded = is_loaded;
module_has_method = module_has_method;
call_module_method = call_module_method;
+
+ loader = loader;
};