Grails 3 : Adding listeners to a plugin

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails 3 : Adding listeners to a plugin

vahid
Hi All

Tried a lot of different things and not go very far:

I raised this question a while back in regards to doWithWebDescriptor:

http://stackoverflow.com/questions/28902928/grails-grails3-dowithwebdescriptor

of course as Joshua pointed out this is now all via spring boot.

I have tried the variations of the example provided from the other link provided by Joshua none of which appears to be actually working as in a basic default tomcat listener which appears not to even return test printlns etc..


According to : http://java.dzone.com/articles/spring-boot-my-favorite


To implement a custom listener one can use addListener of SpringApplication or add it to context.listener.classes property. An attempt to implement SpringApplicationRunListener to listen to the lifecycle of Spring Boot will not succeed because the implementations of this interface will be loaded only from META-INF/spring.factories. So, the way to have access to the Spring Boot lifecycle is to implement ApplicationListener that EventPublishingRunListener will publish the events to accordingly. In this phase EventPublishingRunListener publishes the ApplicationStartedEvent event and all registered listeners can react upon it.


I have tried a lot of variations including:

class WsChatEndpoint extends ChatUtils  implements ServletContextListener, ApplicationListener<ContextStartedEvent> {
class WsChatEndpoint extends ChatUtils implements ServletContextListener,ApplicationListener<ParentContextAvailableEvent> {


I still get no test log back from any of those listener interfaces..

I am just wondering if what I ask is even possible under spring boot with grails or should I start looking at spring websocket to work alongside spring boot ?

Regards
Vahid



--
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/e170baf4-9853-473c-b1cc-5dc7e8d3939d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails 3 : Adding listeners to a plugin

vahid

Hi All

I have managed to get default tomcat websocket listener to work via a spring boot grails app:

It is documented here:

https://github.com/vahidhedayati/testwebsocket-grails3

Regards
Vahid





On Monday, April 20, 2015 at 5:33:00 PM UTC+1, Vahid Hedayati wrote:
Hi All

Tried a lot of different things and not go very far:

I raised this question a while back in regards to doWithWebDescriptor:

<a href="http://stackoverflow.com/questions/28902928/grails-grails3-dowithwebdescriptor" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F28902928%2Fgrails-grails3-dowithwebdescriptor\46sa\75D\46sntz\0751\46usg\75AFQjCNGO2_FjMDNc-5LmcbPujqXa6yjgcA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F28902928%2Fgrails-grails3-dowithwebdescriptor\46sa\75D\46sntz\0751\46usg\75AFQjCNGO2_FjMDNc-5LmcbPujqXa6yjgcA';return true;">http://stackoverflow.com/questions/28902928/grails-grails3-dowithwebdescriptor

of course as Joshua pointed out this is now all via spring boot.

I have tried the variations of the example provided from the other link provided by Joshua none of which appears to be actually working as in a basic default tomcat listener which appears not to even return test printlns etc..


According to : <a href="http://java.dzone.com/articles/spring-boot-my-favorite" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fjava.dzone.com%2Farticles%2Fspring-boot-my-favorite\46sa\75D\46sntz\0751\46usg\75AFQjCNFxz_NUvrBBABukWhU8xc0YSIjQ4g';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fjava.dzone.com%2Farticles%2Fspring-boot-my-favorite\46sa\75D\46sntz\0751\46usg\75AFQjCNFxz_NUvrBBABukWhU8xc0YSIjQ4g';return true;">http://java.dzone.com/articles/spring-boot-my-favorite


To implement a custom listener one can use addListener of SpringApplication or add it to context.listener.classes property. An attempt to implement SpringApplicationRunListener to listen to the lifecycle of Spring Boot will not succeed because the implementations of this interface will be loaded only from META-INF/spring.factories. So, the way to have access to the Spring Boot lifecycle is to implement ApplicationListener that EventPublishingRunListener will publish the events to accordingly. In this phase EventPublishingRunListener publishes the ApplicationStartedEvent event and all registered listeners can react upon it.


I have tried a lot of variations including:

class WsChatEndpoint extends ChatUtils  implements ServletContextListener, ApplicationListener<ContextStartedEvent> {
class WsChatEndpoint extends ChatUtils implements ServletContextListener,ApplicationListener<ParentContextAvailableEvent> {


I still get no test log back from any of those listener interfaces..

I am just wondering if what I ask is even possible under spring boot with grails or should I start looking at spring websocket to work alongside spring boot ?

Regards
Vahid



--
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/dcf3f5a7-91e1-4229-b8fc-cdc822ebb1fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.