Can someone from JB (or not from JB :slightly_smil...
# announcements
c
Can someone from JB (or not from JB 🙂 ) suggest how can we embed kotlin script runner into an app? I want to be able to POST a script to my Spring Boot web application, have it autowired and run. Currently I have this functionality implemented using Groovy for groovy scripts, but I really want to replace it with Kotlin. Groovy is implemented like this (I'm omitting irrelevant parts):
Copy code
val outCapture = PrintWriter(request.outputForCapture, true)
val binding = Binding()
binding.setVariable("beanFactory", beanFactory)
binding.setVariable("out", outCapture)
val shell = GroovyShell(binding)
try {
	val parsedScript = shell.parse(request.script)
	parsedScript.binding = binding
	autowireBeanFactory.autowireBean(parsedScript)
	parsedScript.run()
} catch (exception: RuntimeException) {
	exception.printStackTrace(outCapture)
}
👍 1