Results 1 to 9 of 9

Thread: Spring context initialized event?

Hybrid View

  1. #1
    Join Date
    Jul 2006
    Posts
    126

    Default Spring context initialized event?

    Hi,

    I would like to know if there is a way I can get an event if spring context is initialized without any errors. I want to start configuring other components after this is done. Currently I have used ApplicationContextAware class to get a callback to set application context.

    However this would get called even if there any services in the OSGi registry which remain unresolved. This would be a false event then.

    Please throw some pointers.

    Regards,
    Shashi

  2. #2
    Join Date
    May 2010
    Posts
    9

    Default same question

    I have the same question. I want to get called back after all beans have been instantiated and their init-methods have been called and after all bean post-processors have been run.

  3. #3
    Join Date
    Jul 2006
    Posts
    126

    Default

    Can somebody please throw some light?

    Regards,
    Shashi

  4. #4
    Join Date
    May 2010
    Posts
    9

    Default implement ApplicationListener<ContextRefreshedEvent>

    I tried implementing ApplicationListener<ContextRefreshedEvent> and onApplicationEvent gets called before I get the message

    INFO - org.springframework.web.context.ContextLoader.init WebApplicationContext:214 | Root WebApplicationContext: initialization completed in 12429 ms

    so that seems to be a good bet.

  5. #5
    Join Date
    Jul 2006
    Posts
    126

    Default

    Thanks,

    Was that in a web application or Spring DM? I am not sure if the similar event is raised in DM environment.

    Regards,
    Shashi

  6. #6
    Join Date
    May 2010
    Posts
    9

    Default

    in a web app
    -- Eric

  7. #7
    Join Date
    Jul 2006
    Posts
    126

    Default

    Hi,

    Context may be refreshed multiple times (e.g. by bean post processors) and doesn't guarantee that it's initialized completely once this event is raised.

    Is there any guaranteed way to ensure that context has been initialized completely?

    Regards,
    Shashi

Posting Permissions

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