From: Gunnar Beutner Date: Thu, 29 Aug 2013 17:05:06 +0000 (+0200) Subject: Fix order for startup events. X-Git-Tag: v0.0.3~649 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a3eed67774d6d3ec40fd14a140db9b72392a0f25;p=icinga2 Fix order for startup events. --- diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 406cbff4d..683d0fde5 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -73,12 +73,6 @@ void DynamicObject::Deserialize(const Dictionary::Ptr& update, int attributeType ObjectLock olock(this); InternalDeserialize(update, attributeTypes); } - - if (attributeTypes & Attribute_Config) - OnConfigLoaded(); - - if (attributeTypes & Attribute_State) - OnStateLoaded(); } void DynamicObject::InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h index 204e0c0e3..44531289d 100644 --- a/lib/base/dynamicobject.h +++ b/lib/base/dynamicobject.h @@ -82,6 +82,9 @@ public: virtual void Start(void); virtual void Stop(void); + virtual void OnConfigLoaded(void); + virtual void OnStateLoaded(void); + template static shared_ptr GetObject(const String& name) { @@ -102,9 +105,6 @@ protected: virtual void InternalSerialize(const Dictionary::Ptr& bag, int attributeTypes) const; virtual void InternalDeserialize(const Dictionary::Ptr& bag, int attributeTypes); - virtual void OnConfigLoaded(void); - virtual void OnStateLoaded(void); - private: String m_Name; String m_Type; diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index ebca955d9..94b7e4015 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -275,9 +275,17 @@ void ConfigItem::ActivateItems(void) objects.push_back(object); } + BOOST_FOREACH(const DynamicObject::Ptr& object, objects) { + object->OnConfigLoaded(); + } + /* restore the previous program state */ DynamicObject::RestoreObjects(Application::GetStatePath()); + BOOST_FOREACH(const DynamicObject::Ptr& object, objects) { + object->OnStateLoaded(); + } + BOOST_FOREACH(const DynamicObject::Ptr& object, objects) { Log(LogDebug, "config", "Activating object '" + object->GetName() + "' of type '" + object->GetType()->GetName() + "'"); object->Start();