more stuff

This commit is contained in:
gowthaman.b
2023-11-11 11:38:58 +05:30
parent 1e3d9aa1f1
commit dc0a59fcf2
11 changed files with 335 additions and 109 deletions

View File

@@ -0,0 +1,10 @@
package com.restapi.integ
object Jobs {
fun runJobs(){
//wake up every minute
//see jobs that are to be run and run them
//not very accurate so use for simple jobs,
// sometimes they might fail and will not be attempted to re-run
}
}

View File

@@ -0,0 +1,43 @@
package com.restapi.integ
import javax.script.Invocable
import javax.script.ScriptEngineManager
object Scripting {
const val a = "1"
@JvmStatic
fun main(args: Array<String>) {
k()
}
fun k(){
val engine = ScriptEngineManager().getEngineByExtension("kts")!!
val res1 = engine.eval("""
fun fn(x: Int) = x + 2
val obj = object {
fun fn1(x: Int) = x + 3
}
obj""".trimIndent())
println(res1)
val invocator = engine as? Invocable
println(invocator)
try {
println(invocator!!.invokeFunction("fn1", 3))
} catch (e: NoSuchMethodException) {
println(e)
}
val res2 = invocator!!.invokeFunction("fn", 3)
println(res2)
val res3 = invocator.invokeMethod(res1, "fn1", 3)
println(res3)
}
}