Grails

Must call addArtefact inside onChange event of plugin

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.2-M2
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

The latest version of the GWT plugin registers a new artifact type. Reloading is handled by a call to registerBeans() on the BeanBuilder, but this doesn't work at the moment.

Activity

Hide
Peter Ledbrook added a comment -

Test project that exhibits the problem. It's configured for Grails 1.2-SNAPSHOT. Unpack it, then:

  1. Run grails run-app
  2. Point the browser at http://localhost:8080/test-5057/
  3. Enter your name (or any text) in the text box
  4. Click on the Say hello button
  5. Edit grails-app/actionHandlers/org/example/HelloActionHandler.groovy
  6. Change the message
  7. Click on the Say hello button

The second time you click on the button, the browser should display the new message. However, it doesn't.

Note that the project installs the plugins into a sub-directory of the project, rather than in the home directory. You'll find the 0.5-SNAPSHOT version of the GWT plugin already there.

Show
Peter Ledbrook added a comment - Test project that exhibits the problem. It's configured for Grails 1.2-SNAPSHOT. Unpack it, then:
  1. Run grails run-app
  2. Point the browser at http://localhost:8080/test-5057/
  3. Enter your name (or any text) in the text box
  4. Click on the Say hello button
  5. Edit grails-app/actionHandlers/org/example/HelloActionHandler.groovy
  6. Change the message
  7. Click on the Say hello button
The second time you click on the button, the browser should display the new message. However, it doesn't. Note that the project installs the plugins into a sub-directory of the project, rather than in the home directory. You'll find the 0.5-SNAPSHOT version of the GWT plugin already there.
Hide
Graeme Rocher added a comment -

This simple test passes:

void testRegisterBeans() {
        def bb = new BeanBuilder()

        bb.beans {
           personA(AdvisedPerson) {
               name = "Bob"
           }
        }

        def appCtx = bb.createApplicationContext()

        assertEquals "Bob", appCtx.getBean("personA").name

        bb = new BeanBuilder()
        bb.beans {
            personA(AdvisedPerson) {
                name = "Fred"
            }
        }
        bb.registerBeans(appCtx)

        assertEquals "Fred", appCtx.getBean("personA").name
    }

Also the ServicesGrailsPlugin uses the same technique and it works fine for services. Could you provide a reproducible example?

Show
Graeme Rocher added a comment - This simple test passes:
void testRegisterBeans() {
        def bb = new BeanBuilder()

        bb.beans {
           personA(AdvisedPerson) {
               name = "Bob"
           }
        }

        def appCtx = bb.createApplicationContext()

        assertEquals "Bob", appCtx.getBean("personA").name

        bb = new BeanBuilder()
        bb.beans {
            personA(AdvisedPerson) {
                name = "Fred"
            }
        }
        bb.registerBeans(appCtx)

        assertEquals "Fred", appCtx.getBean("personA").name
    }
Also the ServicesGrailsPlugin uses the same technique and it works fine for services. Could you provide a reproducible example?
Hide
Peter Ledbrook added a comment -

Tracked down the problem. Within the onChange closure, I was calling application.getActionHandlerClass() to get hold of the appropriate GrailsClass instance. However, this seems to get the old version of the artifact.

I replaced that call with application.addArtefact(ActionHandlerArtefactHandler.TYPE, ...) and now the reloading works. So the question is this: should the call to addArtefact() be a requirement for reloading to work? If so, why?

Show
Peter Ledbrook added a comment - Tracked down the problem. Within the onChange closure, I was calling application.getActionHandlerClass() to get hold of the appropriate GrailsClass instance. However, this seems to get the old version of the artifact. I replaced that call with application.addArtefact(ActionHandlerArtefactHandler.TYPE, ...) and now the reloading works. So the question is this: should the call to addArtefact() be a requirement for reloading to work? If so, why?
Hide
Graeme Rocher added a comment -

Yes it is a requirement, nevertheless we can leave the issue open (reduced to minor / changed description) to make this automatic if possible

Show
Graeme Rocher added a comment - Yes it is a requirement, nevertheless we can leave the issue open (reduced to minor / changed description) to make this automatic if possible

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Last Reviewed: