mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-31 01:24:19 +02:00
Auto-load components when component config objects are created.
This commit is contained in:
parent
a368030a80
commit
a49876a1ae
@ -14,16 +14,15 @@ IcingaApplication::IcingaApplication(void)
|
|||||||
|
|
||||||
int IcingaApplication::Main(const vector<string>& args)
|
int IcingaApplication::Main(const vector<string>& args)
|
||||||
{
|
{
|
||||||
|
GetConfigHive()->OnObjectCreated.bind(bind_weak(&IcingaApplication::ConfigObjectCreatedHandler, shared_from_this()));
|
||||||
|
GetConfigHive()->OnObjectRemoved.bind(bind_weak(&IcingaApplication::ConfigObjectRemovedHandler, shared_from_this()));
|
||||||
|
|
||||||
ConfigObject::RefType fileComponentConfig = new_object<ConfigObject>();
|
ConfigObject::RefType fileComponentConfig = new_object<ConfigObject>();
|
||||||
fileComponentConfig->SetName("configfilecomponent");
|
fileComponentConfig->SetName("configfilecomponent");
|
||||||
fileComponentConfig->SetType("component");
|
fileComponentConfig->SetType("component");
|
||||||
fileComponentConfig->SetProperty("filename", "icinga.conf");
|
fileComponentConfig->SetProperty("filename", "icinga.conf");
|
||||||
GetConfigHive()->AddObject(fileComponentConfig);
|
GetConfigHive()->AddObject(fileComponentConfig);
|
||||||
|
|
||||||
LoadComponent("configfilecomponent");
|
|
||||||
|
|
||||||
LoadComponent("configrpccomponent");
|
|
||||||
|
|
||||||
RunEventLoop();
|
RunEventLoop();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -34,4 +33,22 @@ ConnectionManager::RefType IcingaApplication::GetConnectionManager(void)
|
|||||||
return m_ConnectionManager;
|
return m_ConnectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int IcingaApplication::ConfigObjectCreatedHandler(ConfigHiveEventArgs::RefType ea)
|
||||||
|
{
|
||||||
|
if (ea->ConfigObject->GetType() == "component") {
|
||||||
|
LoadComponent(ea->ConfigObject->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IcingaApplication::ConfigObjectRemovedHandler(ConfigHiveEventArgs::RefType ea)
|
||||||
|
{
|
||||||
|
if (ea->ConfigObject->GetType() == "component") {
|
||||||
|
UnloadComponent(ea->ConfigObject->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
SET_START_CLASS(icinga::IcingaApplication);
|
SET_START_CLASS(icinga::IcingaApplication);
|
||||||
|
@ -9,6 +9,9 @@ class IcingaApplication : public Application
|
|||||||
private:
|
private:
|
||||||
ConnectionManager::RefType m_ConnectionManager;
|
ConnectionManager::RefType m_ConnectionManager;
|
||||||
|
|
||||||
|
int ConfigObjectCreatedHandler(ConfigHiveEventArgs::RefType ea);
|
||||||
|
int ConfigObjectRemovedHandler(ConfigHiveEventArgs::RefType ea);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef shared_ptr<IcingaApplication> RefType;
|
typedef shared_ptr<IcingaApplication> RefType;
|
||||||
typedef weak_ptr<IcingaApplication> WeakRefType;
|
typedef weak_ptr<IcingaApplication> WeakRefType;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user