Software /
code /
prosody
Comparison
core/modulemanager.lua @ 3598:48ebea937260
modulemanager: Return an error when loading a module on a non-existent host, don't create the host. Removes dependecy on componentmanager.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Wed, 10 Nov 2010 20:14:33 +0500 |
parent | 3596:bbeba9f2acf8 |
child | 3608:ae0f83feaff4 |
comparison
equal
deleted
inserted
replaced
3597:8090880f0e18 | 3598:48ebea937260 |
---|---|
89 -- | 89 -- |
90 | 90 |
91 function load(host, module_name, config) | 91 function load(host, module_name, config) |
92 if not (host and module_name) then | 92 if not (host and module_name) then |
93 return nil, "insufficient-parameters"; | 93 return nil, "insufficient-parameters"; |
94 elseif not hosts[host] then | |
95 return nil, "unknown-host"; | |
94 end | 96 end |
95 | 97 |
96 if not modulemap[host] then | 98 if not modulemap[host] then |
97 modulemap[host] = {}; | 99 modulemap[host] = {}; |
98 end | 100 end |
116 | 118 |
117 local pluginenv = setmetatable({ module = api_instance }, { __index = _G }); | 119 local pluginenv = setmetatable({ module = api_instance }, { __index = _G }); |
118 api_instance.environment = pluginenv; | 120 api_instance.environment = pluginenv; |
119 | 121 |
120 setfenv(mod, pluginenv); | 122 setfenv(mod, pluginenv); |
121 if not hosts[host] then | |
122 local create_component = _G.require "core.componentmanager".create_component; | |
123 hosts[host] = create_component(host); | |
124 log("debug", "Created new component: %s", host); | |
125 end | |
126 hosts[host].modules = modulemap[host]; | 123 hosts[host].modules = modulemap[host]; |
127 modulemap[host][module_name] = pluginenv; | 124 modulemap[host][module_name] = pluginenv; |
128 | 125 |
129 local success, err = pcall(mod); | 126 local success, err = pcall(mod); |
130 if success then | 127 if success then |