more stuff
This commit is contained in:
10
src/main/kotlin/com/restapi/integ/Jobs.kt
Normal file
10
src/main/kotlin/com/restapi/integ/Jobs.kt
Normal 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
|
||||
}
|
||||
}
|
||||
43
src/main/kotlin/com/restapi/integ/Scripting.kt
Normal file
43
src/main/kotlin/com/restapi/integ/Scripting.kt
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user