May 19th, 2010, 01:11 PM
Spring context initialized event?
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.
May 20th, 2010, 09:10 AM
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.
May 20th, 2010, 10:44 PM
Can somebody please throw some light?
May 21st, 2010, 07:19 AM
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.
May 23rd, 2010, 11:08 PM
Was that in a web application or Spring DM? I am not sure if the similar event is raised in DM environment.
May 23rd, 2010, 11:24 PM
May 23rd, 2010, 11:27 PM
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?