Hello,
I need to call a method on a bean after the application is fully deployed. How do I do that?
Thanks
Tom
Printable View
Hello,
I need to call a method on a bean after the application is fully deployed. How do I do that?
Thanks
Tom
You can create an object which implements ApplicationListener and deploy it in your application context. It will get invoked whenever an ApplicationContext event occurs. One of those events is when the ApplicationContext is either initialized or refreshed.
or you can use a scheduler to run a method in 1 min after start.
silly, but works :)
Unless you are on a server which takes more than a minute to startup. Or the startup is so quick, you'd rather want your method called ASAP rather than waiting a minute.
sure.
anyway, in some cases it might be the best solution. The main (and only) advantage of this approach, is that you don't introduce any dependency on Spring's life-cycle
Hello,
Thanks for the suggestions. I tried implementing the ApplicationListener and catching the ContextRefreshedEvent but that happens before the deployment is complete.
Thanks
Tom