Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1214

Support reloading of classes through GCL

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-JSR-5
    • groovy-jdk
    • None

    Description

      In order for Grails to support reloading of classes without causing problems with cached instances in application and session scope I need Groovy to support a loadClass method that reloads a class if it has been changed.

      Ideally it needs to interact with the GroovyResourceLoader to load resources as Urls if possibly.

      Something like

      gcl.loadClass(final String name, boolean lookupScriptFiles, boolean preferClassOverScript, boolean resolve, boolean reload)

      would be ok.. otherwise maybe a different method

      gcl.reloadClassIfNecessary(String name) maybe ?
      gcl.reloadClass(String name, boolean force) // for forced reload or false to return current if no changes?

      I've attached the test case I used to test this out originally in Grails. It is not Grails specific so you should be able to drop it into groovy and just change the package names

      Attachments

        1. ClassReloadingTests.java
          2 kB
          Graeme Rocher
        2. TestReload.groovy
          0.1 kB
          Graeme Rocher

        Activity

          People

            blackdrag Jochen Theodorou
            graemerocher Graeme Rocher
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: