|
From: Andreas R. <ar...@gm...> - 2003-12-16 09:49:32
|
Hi, setApplicationContext() of an ApplicationContextAware bean is called behind of afterPropertiesSet. So it is not possible to load the referenced bean from within afterPropertiesSet. See AbstractBeanFactory line 518 - 520 Best regards Andy > Ah ok, so the afterPropertiesSet() is called *after* all the beans are > loaded and the setters are called, and the setApplicationContext() has > been called (in case my bean is ApplicationContextAware) so I can load the > referenced bean in the afterPropertiesSet() and do my initialization there? > > This will fix my issue i guess, thanx > > Joost > ----- Original Message ----- > From: Alef Arendsen > To: spr...@li... > Cc: Jo...@jt... > Sent: Tuesday, December 16, 2003 12:48 AM > Subject: RE: [Springframework-developer] Hibernate session and > ApplicationContext > > > > Suppose there's two app contexts, A and B. In A there's bean 1 > > > depending > > > > on bean 2 in B. In B, there's bean 3, depending on bean 4 in > > A. This is circular, however, I still want to somehow be able > > to do this. Basically the BeanFactory stops processing bean > > definitions if it can't find a bean reference that might be > > located in a sibbling context. I tend to state that the bean > > definition creation should postponed until all > > sibbling-contexts are resolved and maybe then try it again? > > Any suggestions (or just 'no not possible' will do as well :) > > > > This should be possible already. In case of multiple context > > definition files, all the bean definitions from all files get > > loaded first - *then* context initialization and bean > > pre-instantiation begins. The only thing that doesn't work, > > because it arguably can't work, is two FactoryBeans > > referencing each other. Can you give some details on what > > doesn't work in your scenario? > > I'll ask joost if I can't more details... He's probably got a couple of > example context files lying around... > > Alef -- |