How to create dynamic/transparent proxy in Kotlin?

Viewed 1807

In C#, we can use DynamicObject class for dynamic method invocation for example used to JsonRPC or so. In Python, using getattr and call does the same task. In general I need an object with no real methods that can be used as like containing methods. The name of the method and the arguments gets into a function and does the task. Using IoC we can do it uing Interception, but I need to know if is there another way (like dynamic in C#) without using interface and IoC.

For example, Zabbix API has many JSON-RPC methods like host.create trigger.get ... There is a Python wrapper that helps you call them so:

from zabbix_api import ZabbixAPI
zapi = ZabbixAPI(server="https://server/")
zapi.login("login", "password")
zapi.trigger.get({"expandExpression": "extend", "triggerids": range(0, 100)})

Actually there are no attributes like 'login' and 'trigger within ZabbixAPI class!

0 Answers
Related