Register deprecated methods in the 'Deprecated' namespace

refs #12408
This commit is contained in:
Gunnar Beutner 2016-08-12 13:42:22 +02:00
parent 419500e55e
commit 24431b3dab
5 changed files with 89 additions and 30 deletions

View File

@ -80,8 +80,8 @@ private:
void RegisterFunction(void) { \ void RegisterFunction(void) { \
Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), false); \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), false); \
ScriptGlobal::Set(#ns "." #name, sf); \ ScriptGlobal::Set(#ns "." #name, sf); \
Function::Ptr dsf = new icinga::Function("__" #name " (deprecated)", WrapFunction(callback), false, true); \ Function::Ptr dsf = new icinga::Function("Deprecated#" #name " (deprecated)", WrapFunction(callback), false, true); \
ScriptGlobal::Set("System.__" #name, dsf); \ ScriptGlobal::Set("Deprecated.__" #name, dsf); \
} \ } \
INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \
} } } } } }
@ -91,8 +91,8 @@ private:
void RegisterFunction(void) { \ void RegisterFunction(void) { \
Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), false); \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), false); \
ScriptGlobal::Set(#ns "." #name, sf); \ ScriptGlobal::Set(#ns "." #name, sf); \
Function::Ptr dsf = new icinga::Function(#name " (deprecated)", WrapFunction(callback), false, true); \ Function::Ptr dsf = new icinga::Function("Deprecated#" #name " (deprecated)", WrapFunction(callback), false, true); \
ScriptGlobal::Set(#name, dsf); \ ScriptGlobal::Set("Deprecated." #name, dsf); \
} \ } \
INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \
} } } } } }
@ -111,8 +111,8 @@ private:
void RegisterFunction(void) { \ void RegisterFunction(void) { \
Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), true); \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), true); \
ScriptGlobal::Set(#ns "." #name, sf); \ ScriptGlobal::Set(#ns "." #name, sf); \
Function::Ptr dsf = new icinga::Function("__" #name " (deprecated)", WrapFunction(callback), true, true); \ Function::Ptr dsf = new icinga::Function("Deprecated#__" #name " (deprecated)", WrapFunction(callback), true, true); \
ScriptGlobal::Set("System.__" #name, dsf); \ ScriptGlobal::Set("Deprecated.__" #name, dsf); \
} \ } \
INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \
} } } } } }
@ -122,8 +122,8 @@ private:
void RegisterFunction(void) { \ void RegisterFunction(void) { \
Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), true); \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), true); \
ScriptGlobal::Set(#ns "." #name, sf); \ ScriptGlobal::Set(#ns "." #name, sf); \
Function::Ptr dsf = new icinga::Function(#name " (deprecated)", WrapFunction(callback), true, true); \ Function::Ptr dsf = new icinga::Function("Deprecated#" #name " (deprecated)", WrapFunction(callback), true, true); \
ScriptGlobal::Set(#name, dsf); \ ScriptGlobal::Set("Deprecated." #name, dsf); \
} \ } \
INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \
} } } } } }

View File

@ -112,6 +112,7 @@ Array::Ptr ScriptFrame::GetImports(void)
if (!m_Imports) { if (!m_Imports) {
m_Imports = new Array(); m_Imports = new Array();
m_Imports->Add(ScriptGlobal::Get("System")); m_Imports->Add(ScriptGlobal::Get("System"));
m_Imports->Add(ScriptGlobal::Get("Deprecated"));
} }
return m_Imports; return m_Imports;

View File

@ -18,11 +18,21 @@
******************************************************************************/ ******************************************************************************/
assert(Internal.run_with_activation_context(function() { assert(Internal.run_with_activation_context(function() {
var _Internal = Internal.clone()
template CheckCommand "ido-check-command" { template CheckCommand "ido-check-command" {
execute = Internal.IdoCheck execute = _Internal.IdoCheck
} }
object CheckCommand "ido" { object CheckCommand "ido" use (_Internal) {
import "ido-check-command" import "ido-check-command"
} }
})) }))
var methods = [
"IdoCheck"
]
for (method in methods) {
Internal.remove(method)
}

View File

@ -18,7 +18,17 @@
******************************************************************************/ ******************************************************************************/
assert(Internal.run_with_activation_context(function() { assert(Internal.run_with_activation_context(function() {
template TimePeriod "legacy-timeperiod" { var _Internal = Internal.clone()
update = Internal.LegacyTimePeriod
template TimePeriod "legacy-timeperiod" use (_Internal) {
update = _Internal.LegacyTimePeriod
} }
})) }))
var methods = [
"LegacyTimePeriod"
]
for (method in methods) {
Internal.remove(method)
}

View File

@ -18,39 +18,77 @@
******************************************************************************/ ******************************************************************************/
assert(Internal.run_with_activation_context(function() { assert(Internal.run_with_activation_context(function() {
template CheckCommand "icinga-check-command" { var _Internal = Internal.clone()
execute = Internal.IcingaCheck
template CheckCommand "icinga-check-command" use (_Internal) {
execute = _Internal.IcingaCheck
} }
template CheckCommand "cluster-check-command" { template CheckCommand "cluster-check-command" use (_Internal) {
execute = Internal.ClusterCheck execute = _Internal.ClusterCheck
} }
template CheckCommand "cluster-zone-check-command" { template CheckCommand "cluster-zone-check-command" use (_Internal) {
execute = Internal.ClusterZoneCheck execute = _Internal.ClusterZoneCheck
} }
template CheckCommand "plugin-check-command" { template CheckCommand "plugin-check-command" use (_Internal) {
execute = Internal.PluginCheck execute = _Internal.PluginCheck
} }
template CheckCommand "clr-check-command" { template CheckCommand "clr-check-command" use (_Internal) {
execute = Internal.ClrCheck execute = _Internal.ClrCheck
} }
template NotificationCommand "plugin-notification-command" { template NotificationCommand "plugin-notification-command" use (_Internal) {
execute = Internal.PluginNotification execute = _Internal.PluginNotification
} }
template EventCommand "plugin-event-command" { template EventCommand "plugin-event-command" use (_Internal) {
execute = Internal.PluginEvent execute = _Internal.PluginEvent
} }
template CheckCommand "random-check-command" { template CheckCommand "random-check-command" use (_Internal) {
execute = Internal.RandomCheck execute = _Internal.RandomCheck
} }
template CheckCommand "exception-check-command" { template CheckCommand "exception-check-command" use (_Internal) {
execute = Internal.ExceptionCheck execute = _Internal.ExceptionCheck
}
template CheckCommand "null-check-command" use (_Internal) {
execute = _Internal.NullCheck
}
template EventCommand "null-event-command" use (_Internal) {
execute = _Internal.NullEvent
}
template TimePeriod "empty-timeperiod" use (_Internal) {
execute = _Internal.EmptyTimePeriod
}
template TimePeriod "even-minutes-timeperiod" use (_Internal) {
execute = _Internal.EvenMinutesTimePeriod
} }
})) }))
var methods = [
"IcingaCheck",
"ClusterCheck",
"ClusterZoneCheck",
"PluginCheck",
"ClrCheck",
"PluginNotification",
"PluginEvent",
"RandomCheck",
"ExceptionCheck",
"NullCheck",
"NullEvent",
"EmptyTimePeriod",
"EvenMinutesTimePeriod"
]
for (method in methods) {
Internal.remove(method)
}