How does grails handle dynamic class reloading
How does开发者_高级运维 grails handle dynamic class reloading ?
I did a little digging around, now this may not be perfect and will not include all the little details, however at a broad level I think this is what goes on:
- A thread is run say every X seconds, this thread detects if there have been any changes to Grails artifacts (domain,service,controller), custom artifacts can be included.
If an artifact has been changed, then this bit of code is run which I think does the magic:
GroovyClassLoader gcl = new GroovyClassLoader(application.getClassLoader()); initialisePlugin(gcl.parseClass(DefaultGroovyMethods.getText(conn.getInputStream())));
I got this by looking around DefaultGrailsPlugin which is part of grails core.
Everything in Grails is treated as a plugin even the service,domain,controllers and so on.
With a custom ClassLoader. Probably to vague a question and requires too in-depth of an answer for a site like SO. Might be better suited for the Grails mailing list.
精彩评论