Announcement Announcement Module
Collapse
No announcement yet.
Post Deployment Method Call Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Post Deployment Method Call

    Hello,

    I need to call a method on a bean after the application is fully deployed. How do I do that?

    Thanks
    Tom

  • #2
    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.

    Comment


    • #3
      or you can use a scheduler to run a method in 1 min after start.
      silly, but works

      Comment


      • #4
        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.

        Comment


        • #5
          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

          Comment


          • #6
            Hello,

            Thanks for the suggestions. I tried implementing the ApplicationListener and catching the ContextRefreshedEvent but that happens before the deployment is complete.

            Thanks
            Tom

            Comment

            Working...
            X