Zorka source code interpretation: Beanshell and zorka interaction implementation, zorkabeanshell
1. beanshell basic knowledge
Call BeanShell from an application
Create a BeanShell interpreter (interpreter)
Run the eval () and source () commands to evaluate a string and run a script file.
You can use the set () method to input a variable reference to an object.
You can use the get () method to obtain the result of a variable again.
2. Register a java object in beanshell
Java code uses the interpreter of the beanshell library to pass variables to beanshell.
The put Method in ZorkaBshAgent. java calls the set Method of Interpreter to register SpyLib, ZorkaLib, TracerLib, ZabbixLib, NagiosLib, and SyslogLib instances in beanshell.
3. Load beanshell in java and execute beanshell
The eval () and source () commands of interpreter can be used in beanshell scripts to evaluate a string and run a script file.
ZorkaBshAgent. java executes the bsh script loading operation. In the loadScript method, execute the source (path) and eval () of interpreter to execute the script.