If I understand correctly, you are trying to execute some logic when starting the application (init context).
If so, I would suggest using BeanPostProcessor to perform any special operations when the application starts.
public class MyBeanPostProcessor implements BeanPostProcessor { @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { .. **perform special things** return bean; } @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { ..**perform special things** return bean; } }
Remember to tell Spring about your mail processor
<context:component-scan base-package="some.package" /> <bean class="some.package.MyBeanPostProcessor"
Read more here http://static.springsource.org/spring/docs/3.0.0.M3/reference/html/ch04s07.html
Hope this helps.
sashok_bg
source share