Hello,
I would like to call a bootstrap method upon application deploiement. What's the best way to do this?
Hello,
I would like to call a bootstrap method upon application deploiement. What's the best way to do this?
You can add a class implementing BeanFactoryPostProcessor to your context. Implementto post process your bean factory. You can for instance retrieve a bean here and do whatever you want with it.Code:postProcessBeanFactory(BeanFactory)
BeanFactoryPostProcessors are automtically loaded after the context is created and any singletons have been initialized.
If it is a web application you can also use org.springframework.web.context.ContextLoaderListe ner or org.springframework.web.context.ContextLoaderServl et to perform bootstrap initializations. In that case the initialization code is executed only once.
Using a BeanPostProcessor might be problematic if the configuration is processed more than once (e.g. if you initialize pooled EJBs). In that case your init-code will be executed multiple times.
Regards,
Andreas