I am looking for a refreshable groovy classloader,I want to let groovy file change on fly,I know
GroovyScriptEngine
do the thing,but if I have AClass.groovy
and BClass.groovy
, and I write in AClass
:
Class pageClass = ClassUtils.forName("BClass", this.getClass().getClassLoader());
and auto reloading BClass is not work when BClass.groovy
is not work.
I think the best solution is need a refreshable ClassLoader,but I can not find the exisiting implemention.
And I am not using spri开发者_运维知识库ng-groovy and grails,I want a independent implemention.
Thanks
Not exactly what you want I'm sure but if you want to do something ONLY with Groovy (no Spring or Grails) that allows you to change stuff and not have to restart your application, you might look at doing some initial work with Groovlets -> http://groovy.codehaus.org/Groovlets
This is only for servlet container work and probably won't be extremely useful as your application gets large but it would allow you to initially change things frequently and simply refresh with a call to the Groovlet.
If you did consider using Spring, scripted beans are 'refreshable' and you can implement that yourself using Java's dynamic language support but I'd suggest simply letting Spring do it for you.
精彩评论