Replace GetType()->GetName() calls with GetReflectionType()->GetName()

fixes #12438
This commit is contained in:
Gunnar Beutner 2016-08-15 14:39:33 +02:00
parent bc06ff18e5
commit ebaf239d3b
5 changed files with 16 additions and 12 deletions

View File

@ -384,7 +384,7 @@ void ConfigObject::Start(bool runtimeCreated)
void ConfigObject::Activate(bool runtimeCreated) void ConfigObject::Activate(bool runtimeCreated)
{ {
CONTEXT("Activating object '" + GetName() + "' of type '" + GetType()->GetName() + "'"); CONTEXT("Activating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
{ {
ObjectLock olock(this); ObjectLock olock(this);
@ -413,7 +413,7 @@ void ConfigObject::Stop(bool runtimeRemoved)
void ConfigObject::Deactivate(bool runtimeRemoved) void ConfigObject::Deactivate(bool runtimeRemoved)
{ {
CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetType()->GetName() + "'"); CONTEXT("Deactivating object '" + GetName() + "' of type '" + GetReflectionType()->GetName() + "'");
{ {
ObjectLock olock(this); ObjectLock olock(this);

View File

@ -23,6 +23,9 @@
#include "icinga/customvarobject.hpp" #include "icinga/customvarobject.hpp"
#include "icinga/service.hpp" #include "icinga/service.hpp"
#include "icinga/compatutility.hpp" #include "icinga/compatutility.hpp"
#include "icinga/checkcommand.hpp"
#include "icinga/eventcommand.hpp"
#include "icinga/notificationcommand.hpp"
#include "remote/endpoint.hpp" #include "remote/endpoint.hpp"
#include "base/configobject.hpp" #include "base/configobject.hpp"
#include "base/configtype.hpp" #include "base/configtype.hpp"
@ -288,7 +291,7 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object)
if (dbobj) if (dbobj)
return dbobj; return dbobj;
DbType::Ptr dbtype = DbType::GetByName(object->GetType()->GetName()); DbType::Ptr dbtype = DbType::GetByName(object->GetReflectionType()->GetName());
if (!dbtype) if (!dbtype)
return DbObject::Ptr(); return DbObject::Ptr();
@ -304,9 +307,9 @@ DbObject::Ptr DbObject::GetOrCreateByObject(const ConfigObject::Ptr& object)
name1 = service->GetHost()->GetName(); name1 = service->GetHost()->GetName();
name2 = service->GetShortName(); name2 = service->GetShortName();
} else { } else {
if (object->GetType() == ConfigType::GetByName("CheckCommand") || if (object->GetReflectionType() == CheckCommand::TypeInstance ||
object->GetType() == ConfigType::GetByName("EventCommand") || object->GetReflectionType() == EventCommand::TypeInstance ||
object->GetType() == ConfigType::GetByName("NotificationCommand")) { object->GetReflectionType() == NotificationCommand::TypeInstance) {
Command::Ptr command = dynamic_pointer_cast<Command>(object); Command::Ptr command = dynamic_pointer_cast<Command>(object);
name1 = CompatUtility::GetCommandName(command); name1 = CompatUtility::GetCommandName(command);
} }

View File

@ -20,6 +20,7 @@
#include "icinga/compatutility.hpp" #include "icinga/compatutility.hpp"
#include "icinga/checkcommand.hpp" #include "icinga/checkcommand.hpp"
#include "icinga/eventcommand.hpp" #include "icinga/eventcommand.hpp"
#include "icinga/notificationcommand.hpp"
#include "icinga/pluginutility.hpp" #include "icinga/pluginutility.hpp"
#include "icinga/service.hpp" #include "icinga/service.hpp"
#include "base/utility.hpp" #include "base/utility.hpp"
@ -62,11 +63,11 @@ String CompatUtility::GetCommandNamePrefix(const Command::Ptr command)
return Empty; return Empty;
String prefix; String prefix;
if (command->GetType() == ConfigType::GetByName("CheckCommand")) if (command->GetReflectionType() == CheckCommand::TypeInstance)
prefix = "check_"; prefix = "check_";
else if (command->GetType() == ConfigType::GetByName("NotificationCommand")) else if (command->GetReflectionType() == NotificationCommand::TypeInstance)
prefix = "notification_"; prefix = "notification_";
else if (command->GetType() == ConfigType::GetByName("EventCommand")) else if (command->GetReflectionType() == EventCommand::TypeInstance)
prefix = "event_"; prefix = "event_";
return prefix; return prefix;

View File

@ -291,7 +291,7 @@ void ApiListener::UpdateConfigObject(const ConfigObject::Ptr& object, const Mess
Dictionary::Ptr params = new Dictionary(); Dictionary::Ptr params = new Dictionary();
params->Set("name", object->GetName()); params->Set("name", object->GetName());
params->Set("type", object->GetType()->GetName()); params->Set("type", object->GetReflectionType()->GetName());
params->Set("version", object->GetVersion()); params->Set("version", object->GetVersion());
if (object->GetPackage() == "_api") { if (object->GetPackage() == "_api") {
@ -370,7 +370,7 @@ void ApiListener::DeleteConfigObject(const ConfigObject::Ptr& object, const Mess
Dictionary::Ptr params = new Dictionary(); Dictionary::Ptr params = new Dictionary();
params->Set("name", object->GetName()); params->Set("name", object->GetName());
params->Set("type", object->GetType()->GetName()); params->Set("type", object->GetReflectionType()->GetName());
params->Set("version", object->GetVersion()); params->Set("version", object->GetVersion());
message->Set("params", params); message->Set("params", params);

View File

@ -651,7 +651,7 @@ void ApiListener::PersistMessage(const Dictionary::Ptr& message, const ConfigObj
if (secobj) { if (secobj) {
Dictionary::Ptr secname = new Dictionary(); Dictionary::Ptr secname = new Dictionary();
secname->Set("type", secobj->GetType()->GetName()); secname->Set("type", secobj->GetReflectionType()->GetName());
secname->Set("name", secobj->GetName()); secname->Set("name", secobj->GetName());
pmessage->Set("secobj", secname); pmessage->Set("secobj", secname);
} }