Mercurial > prosody-hg
comparison core/componentmanager.lua @ 3597:8090880f0e18
hostmanager, componentmanager: hostmanager now handles component initialization at server start, not componentmanager.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Wed, 10 Nov 2010 19:57:35 +0500 |
| parents | d94aacb2771a |
| children | a977d8be6277 |
comparison
equal
deleted
inserted
replaced
| 3596:bbeba9f2acf8 | 3597:8090880f0e18 |
|---|---|
| 30 local function default_component_handler(origin, stanza) | 30 local function default_component_handler(origin, stanza) |
| 31 log("warn", "Stanza being handled by default component; bouncing error for: %s", stanza:top_tag()); | 31 log("warn", "Stanza being handled by default component; bouncing error for: %s", stanza:top_tag()); |
| 32 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then | 32 if stanza.attr.type ~= "error" and stanza.attr.type ~= "result" then |
| 33 origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); | 33 origin.send(st.error_reply(stanza, "wait", "service-unavailable", "Component unavailable")); |
| 34 end | 34 end |
| 35 end | |
| 36 | |
| 37 function load_enabled_components(config) | |
| 38 local defined_hosts = config or configmanager.getconfig(); | |
| 39 | |
| 40 for host, host_config in pairs(defined_hosts) do | |
| 41 if host ~= "*" and ((host_config.core.enabled == nil or host_config.core.enabled) and type(host_config.core.component_module) == "string") then | |
| 42 hosts[host] = create_component(host); | |
| 43 components[host] = default_component_handler; | |
| 44 local ok, err = modulemanager.load(host, host_config.core.component_module); | |
| 45 if not ok then | |
| 46 log("error", "Error loading %s component %s: %s", tostring(host_config.core.component_module), tostring(host), tostring(err)); | |
| 47 else | |
| 48 fire_event("component-activated", host, host_config); | |
| 49 log("debug", "Activated %s component: %s", host_config.core.component_module, host); | |
| 50 end | |
| 51 end | |
| 52 end | |
| 53 end | |
| 54 | |
| 55 if prosody and prosody.events then | |
| 56 prosody.events.add_handler("server-starting", load_enabled_components); | |
| 57 end | 35 end |
| 58 | 36 |
| 59 function create_component(host, component, events) | 37 function create_component(host, component, events) |
| 60 -- TODO check for host well-formedness | 38 -- TODO check for host well-formedness |
| 61 return { type = "component", host = host, s2sout = {}, | 39 return { type = "component", host = host, s2sout = {}, |
