Quantcast

Grails 3 Plugins and watchedResources

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Grails 3 Plugins and watchedResources

Ken Siprell
Can someone verify that watchedResources is working correctly in a Grails 3 plugin? I'm not having any luck. I've searched grails-core and checked the grails3-plugins, but I didn't find anything helpful.

Here's my definition: https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31.

When I edit and save a watched file it's recompiled, but the onChange method is not called.

Thanks,
Ken

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/16a8ba2f-2485-4789-b36c-aa235bdbbad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Grails 3 Plugins and watchedResources

budjb
Reviving this one. I'm having a similar problem where watched resources are not triggering a plugin's onchange method. I know that Grails is reloading the object because there's logging when the artefact handler fires, but I'm never seeing the onchange work. Before I start posting code, I just want to know, is the onChange functionality with hot loading actually working? I'm using Grails 3.1.4.

On Sunday, March 22, 2015 at 12:40:05 PM UTC-5, Ken Siprell wrote:
Can someone verify that watchedResources is working correctly in a Grails 3 plugin? I'm not having any luck. I've searched grails-core and checked the grails3-plugins, but I didn't find anything helpful.

Here's my definition: <a href="https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;">https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31.

When I edit and save a watched file it's recompiled, but the onChange method is not called.

Thanks,
Ken

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/8e6bd900-6ed9-4209-b59f-5a6780bbd5b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Grails 3 Plugins and watchedResources

budjb
Digging through the Grails source code with the use of the intellij debugger, I found this little gem: AbstractGrailsPluginManager.informOfClassChange. It looks like it first finds the artefact handler for the reloaded artefact type, and if it exists, tries to retrieve the plugin by the same name as the artefact type. Only if it finds a plugin with the same name does it fire off an EVENT_ON_CHANGE event, which triggers the onChange method call.

A couple questions then. I may have missed it, but I didn't see anything in the documentation that stated that artefacts needed to match the name of the plugin. If that's truly the case, that breaks previous Grails behavior, especially when a plugin creates more than one artefact type. Second, does this also mean that only one plugin can be notified of a watched class reload? This also breaks previous behavior.

My apologies if I've misunderstood the logic here, and any help would be appreciated.

On Wednesday, April 6, 2016 at 9:24:42 PM UTC-5, Bud Byrd wrote:
Reviving this one. I'm having a similar problem where watched resources are not triggering a plugin's onchange method. I know that Grails is reloading the object because there's logging when the artefact handler fires, but I'm never seeing the onchange work. Before I start posting code, I just want to know, is the onChange functionality with hot loading actually working? I'm using Grails 3.1.4.

On Sunday, March 22, 2015 at 12:40:05 PM UTC-5, Ken Siprell wrote:
Can someone verify that watchedResources is working correctly in a Grails 3 plugin? I'm not having any luck. I've searched grails-core and checked the grails3-plugins, but I didn't find anything helpful.

Here's my definition: <a href="https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;">https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31.

When I edit and save a watched file it's recompiled, but the onChange method is not called.

Thanks,
Ken

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/9d47d5d9-d8a5-4d23-8a17-c0c8ccea949d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Grails 3 Plugins and watchedResources

budjb
So it looks like I went down a rabbit hole with the previous post that didn't help me much. Looks like that has to do with spring loaded and it is not the only trigger for the onchange stuff to occur.

It looks like the culprit for onChange not firing has to do with GrailsApp.enableDevelopmentModeWatch. I'm not sure why, but the logic in the loop will only fire off the onchange event if the changed file is also a new file. From the Grails 3.1.4 source, see line 222. I'd have guessed this logic was reversed, but if the changed file is also a new file, there's a line that removes that file from the new files list, and then it submits the file change event.

Whatever the reason for this, the end result is that my plugin's onChange method is not being trigger for a file that is being watched. I've confirmed through debugging that the watched files list is being loaded correctly, and I'm not sure where to go from here. If my understanding of the above is wrong, my apologies. If this sounds like a bug, I'd be happy to submit a JIRA.

Also, I'd really like to understand how a changed file can also be a new file, and why onChange will only fire if both are true.

Thanks for any help.

On Wednesday, April 6, 2016 at 10:15:58 PM UTC-5, Bud Byrd wrote:
Digging through the Grails source code with the use of the intellij debugger, I found this little gem: AbstractGrailsPluginManager.informOfClassChange. It looks like it first finds the artefact handler for the reloaded artefact type, and if it exists, tries to retrieve the plugin by the same name as the artefact type. Only if it finds a plugin with the same name does it fire off an EVENT_ON_CHANGE event, which triggers the onChange method call.

A couple questions then. I may have missed it, but I didn't see anything in the documentation that stated that artefacts needed to match the name of the plugin. If that's truly the case, that breaks previous Grails behavior, especially when a plugin creates more than one artefact type. Second, does this also mean that only one plugin can be notified of a watched class reload? This also breaks previous behavior.

My apologies if I've misunderstood the logic here, and any help would be appreciated.

On Wednesday, April 6, 2016 at 9:24:42 PM UTC-5, Bud Byrd wrote:
Reviving this one. I'm having a similar problem where watched resources are not triggering a plugin's onchange method. I know that Grails is reloading the object because there's logging when the artefact handler fires, but I'm never seeing the onchange work. Before I start posting code, I just want to know, is the onChange functionality with hot loading actually working? I'm using Grails 3.1.4.

On Sunday, March 22, 2015 at 12:40:05 PM UTC-5, Ken Siprell wrote:
Can someone verify that watchedResources is working correctly in a Grails 3 plugin? I'm not having any luck. I've searched grails-core and checked the grails3-plugins, but I didn't find anything helpful.

Here's my definition: <a href="https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;">https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31.

When I edit and save a watched file it's recompiled, but the onChange method is not called.

Thanks,
Ken

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/082b40e7-fce2-4494-9319-01b9c8ce055d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Grails 3 Plugins and watchedResources

budjb
I've submitted an issue on the grails-core project in Github. You can find it here: https://github.com/grails/grails-core/issues/9848.

On Wednesday, April 6, 2016 at 10:45:12 PM UTC-5, Bud Byrd wrote:
So it looks like I went down a rabbit hole with the previous post that didn't help me much. Looks like that has to do with spring loaded and it is not the only trigger for the onchange stuff to occur.

It looks like the culprit for onChange not firing has to do with GrailsApp.enableDevelopmentModeWatch. I'm not sure why, but the logic in the loop will only fire off the onchange event if the changed file is also a new file. From the Grails 3.1.4 source, see line 222. I'd have guessed this logic was reversed, but if the changed file is also a new file, there's a line that removes that file from the new files list, and then it submits the file change event.

Whatever the reason for this, the end result is that my plugin's onChange method is not being trigger for a file that is being watched. I've confirmed through debugging that the watched files list is being loaded correctly, and I'm not sure where to go from here. If my understanding of the above is wrong, my apologies. If this sounds like a bug, I'd be happy to submit a JIRA.

Also, I'd really like to understand how a changed file can also be a new file, and why onChange will only fire if both are true.

Thanks for any help.

On Wednesday, April 6, 2016 at 10:15:58 PM UTC-5, Bud Byrd wrote:
Digging through the Grails source code with the use of the intellij debugger, I found this little gem: AbstractGrailsPluginManager.informOfClassChange. It looks like it first finds the artefact handler for the reloaded artefact type, and if it exists, tries to retrieve the plugin by the same name as the artefact type. Only if it finds a plugin with the same name does it fire off an EVENT_ON_CHANGE event, which triggers the onChange method call.

A couple questions then. I may have missed it, but I didn't see anything in the documentation that stated that artefacts needed to match the name of the plugin. If that's truly the case, that breaks previous Grails behavior, especially when a plugin creates more than one artefact type. Second, does this also mean that only one plugin can be notified of a watched class reload? This also breaks previous behavior.

My apologies if I've misunderstood the logic here, and any help would be appreciated.

On Wednesday, April 6, 2016 at 9:24:42 PM UTC-5, Bud Byrd wrote:
Reviving this one. I'm having a similar problem where watched resources are not triggering a plugin's onchange method. I know that Grails is reloading the object because there's logging when the artefact handler fires, but I'm never seeing the onchange work. Before I start posting code, I just want to know, is the onChange functionality with hot loading actually working? I'm using Grails 3.1.4.

On Sunday, March 22, 2015 at 12:40:05 PM UTC-5, Ken Siprell wrote:
Can someone verify that watchedResources is working correctly in a Grails 3 plugin? I'm not having any luck. I've searched grails-core and checked the grails3-plugins, but I didn't find anything helpful.

Here's my definition: <a href="https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Fkensiprell%2Fgrails3-drools%2Fblob%2Fmaster%2Fsrc%2Fmain%2Fgroovy%2Fgrails%2Fplugin%2Fdrools%2FDroolsGrailsPlugin.groovy%23L26-L31\46sa\75D\46sntz\0751\46usg\75AFQjCNGQL7rRWGodcXQ7qWM_T3TOOMeaqg&#39;;return true;">https://github.com/kensiprell/grails3-drools/blob/master/src/main/groovy/grails/plugin/drools/DroolsGrailsPlugin.groovy#L26-L31.

When I edit and save a watched file it's recompiled, but the onChange method is not called.

Thanks,
Ken

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/1992c134-8f74-4aa3-bd2a-5596386e1d38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...