Results 1 to 6 of 6

Thread: Post Deployment Method Call

  1. #1

    Default 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. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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.
    Bill

  3. #3
    Join Date
    Dec 2005
    Posts
    269

    Default

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

  4. #4
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    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.
    Bill

  5. #5
    Join Date
    Dec 2005
    Posts
    269

    Default

    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

  6. #6

    Default

    Hello,

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

    Thanks
    Tom

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •