简体   繁体   中英

How does grails handle dynamic class reloading

grails如何处理动态类重载?

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:

  1. 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.
  2. 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.

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