简体   繁体   中英

Does spring support invoke dynamic for groovy-backed beans?

Is it possible to configure Groovy beans declared with lang namespace or manually with GroovyScriptFactory in such a way, that they use invoke dynamic support?

<lang:groovy id="messenger" script-source="classpath:Messenger.groovy"> 

I have not found any reliable documentation on this case.

And, does a GroovyClassLoader provided with groovy-all:indy maven artifact uses this feature, or it can be used only with groovy compiler?

In order to activate the invoke-dynamic support, you have to :

  1. Use groovy-indy.jar
  2. Set the system property groovy.target.indy to true or the CompilerConfiguration.DEFAULT.getOptimizationOptions().put("indy", true)

This will enable this function for all invocations of the groovy compiler (and Spring will use this option). I don't think there is a way to configure this option through the ScriptEngine , for only a subset of scripts.

If you use directly a GroovyClassLoader, you can provide this option through the CompilerConfiguration.optimizationOptions.indy property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM