Comparison

core/moduleapi.lua @ 12253:57d35fcde488

modulemanager, moduleapi: Switch to new pluginloader interface
author Matthew Wild <mwild1@gmail.com>
date Fri, 04 Feb 2022 14:11:46 +0000
parent 12095:c1d2bc6603ae
child 12479:4d36fbcdd210
comparison
equal deleted inserted replaced
12252:4bfe658415a0 12253:57d35fcde488
8 8
9 local array = require "util.array"; 9 local array = require "util.array";
10 local set = require "util.set"; 10 local set = require "util.set";
11 local it = require "util.iterators"; 11 local it = require "util.iterators";
12 local logger = require "util.logger"; 12 local logger = require "util.logger";
13 local pluginloader = require "util.pluginloader";
14 local timer = require "util.timer"; 13 local timer = require "util.timer";
15 local resolve_relative_path = require"util.paths".resolve_relative_path; 14 local resolve_relative_path = require"util.paths".resolve_relative_path;
16 local st = require "util.stanza"; 15 local st = require "util.stanza";
17 local cache = require "util.cache"; 16 local cache = require "util.cache";
18 local errors = require "util.error"; 17 local errors = require "util.error";
127 function api:wrap_global(event, handler) 126 function api:wrap_global(event, handler)
128 return self:hook_object_event(prosody.events, event, handler); 127 return self:hook_object_event(prosody.events, event, handler);
129 end 128 end
130 129
131 function api:require(lib) 130 function api:require(lib)
132 local f, n = pluginloader.load_code_ext(self.name, lib, "lib.lua", self.environment); 131 local modulemanager = require"core.modulemanager";
132 local f, n = modulemanager.loader:load_code_ext(self.name, lib, "lib.lua", self.environment);
133 if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message 133 if not f then error("Failed to load plugin library '"..lib.."', error: "..n); end -- FIXME better error message
134 return f(); 134 return f();
135 end 135 end
136 136
137 function api:depends(name) 137 function api:depends(name)