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

View File

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

View File

@ -18,11 +18,21 @@
******************************************************************************/
assert(Internal.run_with_activation_context(function() {
var _Internal = Internal.clone()
template CheckCommand "ido-check-command" {
execute = Internal.IdoCheck
execute = _Internal.IdoCheck
}
object CheckCommand "ido" {
object CheckCommand "ido" use (_Internal) {
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() {
template TimePeriod "legacy-timeperiod" {
update = Internal.LegacyTimePeriod
var _Internal = Internal.clone()
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() {
template CheckCommand "icinga-check-command" {
execute = Internal.IcingaCheck
var _Internal = Internal.clone()
template CheckCommand "icinga-check-command" use (_Internal) {
execute = _Internal.IcingaCheck
}
template CheckCommand "cluster-check-command" {
execute = Internal.ClusterCheck
template CheckCommand "cluster-check-command" use (_Internal) {
execute = _Internal.ClusterCheck
}
template CheckCommand "cluster-zone-check-command" {
execute = Internal.ClusterZoneCheck
template CheckCommand "cluster-zone-check-command" use (_Internal) {
execute = _Internal.ClusterZoneCheck
}
template CheckCommand "plugin-check-command" {
execute = Internal.PluginCheck
template CheckCommand "plugin-check-command" use (_Internal) {
execute = _Internal.PluginCheck
}
template CheckCommand "clr-check-command" {
execute = Internal.ClrCheck
template CheckCommand "clr-check-command" use (_Internal) {
execute = _Internal.ClrCheck
}
template NotificationCommand "plugin-notification-command" {
execute = Internal.PluginNotification
template NotificationCommand "plugin-notification-command" use (_Internal) {
execute = _Internal.PluginNotification
}
template EventCommand "plugin-event-command" {
execute = Internal.PluginEvent
template EventCommand "plugin-event-command" use (_Internal) {
execute = _Internal.PluginEvent
}
template CheckCommand "random-check-command" {
execute = Internal.RandomCheck
template CheckCommand "random-check-command" use (_Internal) {
execute = _Internal.RandomCheck
}
template CheckCommand "exception-check-command" {
execute = Internal.ExceptionCheck
template CheckCommand "exception-check-command" use (_Internal) {
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)
}