|
From: Kopylenko, D. <dko...@ac...> - 2004-03-03 19:02:36
|
>But instead, according to the code in AbstractApplicationContext, it appears that this method call is firing before the >getBeanFactory().preInstantiateSingletons() method? Yes, this is the correct behavior of the BeanFactoryPostProcessor. postProcessBeanFactory() gets called when all bean definitions will = have been loaded, but no beans will have been instantiated yet. Regards, Dmitriy. > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...] On=20 > Behalf Of Dmitriy Kopylenko > Sent: Tuesday, March 02, 2004 11:11 PM > To: spr...@li... > Subject: Re: RE: [Springframework-developer] Lifecycle methods >=20 > Alef, oops, didn't see that you already suggested=20 > BeanFactoryPostProcessor... :-) >=20 > D. >=20 > ----- Original Message ----- > From: Dmitriy Kopylenko <dko...@ru...> > Date: Tuesday, March 2, 2004 7:18 pm > Subject: Re: RE: [Springframework-developer] Lifecycle methods >=20 > > I just want to add - before step 1 (instantiation of any beans) - > > > = BeanFactoryPostProcessor.postProcessBeanFactory(ConfigurableListableBe > anFa > ctory beanFactory) "kicks in". So with the custom implemetation of = the > post processor it might be quite possible to eager-initialize = concerned > beans (dao impl in this case) before any other beans in the = BeanFactory. > Any thoughts on this? > > > > Regards, > > Dmitriy. > > > > ----- Original Message ----- > > From: Alef Arendsen <al...@jt...> > > Date: Tuesday, March 2, 2004 6:43 pm > > Subject: RE: [Springframework-developer] Lifecycle methods > > > > > The order is as follows: > > > > > > 1. setting of bean properties (so, including your DAO) > > > 2. BeanNameAware > > > 3. BeanFactoryAware > > > 4. beanpostprocessor - preInitialize > > > 5. afterPropertiesSet > > > 6. init-method > > > 7. beanpostprocessor - postInitialize > > > 8. next bean > > > > > > ((( This should be added to the docs by the way, I'll try to > > write > > > a decent > > > piece about it as soon as I have time and also after this=20 > > > discussion ))) > > > > > > This means you're indeed you're going to run into problems > > there. I've > > > checked the BeanFactory and somewhere it states that (before > > step > > > 1) it > > > guarantees that all beans the current bean depends on are=20 > > > guaranteed to be initialized (of which I don't understand how = that=20 > > > could be possible because > > > we're talking circular here). So I guess we'll have to call in > > the > > > experthere ;-). > > > > > > J=FCrgen, could you elaborate a bit more here... > > > > > > Alef > > > > > > p.s. if you need a solution ASAP, I suggest you use a=20 > > > BeanFactoryPostProcessor for now (just add one to your > > application > > > context,doing some initialization work, it'll get detected=20 > > > automatically, or - in case you're using just the BeanFactory,=20 > > > apply it programmatically). > > > > > > > -----Original Message----- > > > > From: spr...@li... > > > > [spr...@li...] On=20 > > > > Behalf Of James Cook > > > > Sent: Tuesday, March 02, 2004 9:23 PM > > > > To: spr...@li... > > > > Subject: [Springframework-developer] Lifecycle methods > > > > > > > > I think I am missing some basic lifecycle method, but I have > > > read the docs > > > > and maybe it does not exist? > > > > > > > > I have a cyclic relationship between two beans: > > > > > > > > <bean id=3D"CategoryDAO" class=3D"my.CategoryDAOHibernate"> > > > > <property name=3D"sessionFactory"> > > > > <ref local=3D"sessionFactory"/> > > > > </property> > > > > <property name=3D"categoryHierarchy"> > > > > <ref local=3D"CategoryHierarchy"/> > > > > </property> > > > > </bean> > > > > > > > > <bean id=3D"CategoryHierarchy" class=3D"my.CategoryHierarchy"> > > > > <property name=3D"categoryDAO"> > > > > <ref local=3D"CategoryDAO"/> > > > > </property> > > > > </bean> > > > > > > > > CategoryDAO extends HibernateDaoSupport, so it's > > > afterPropertiesSet()> method > > > > uses the session factory to initialize the DAO which creates a > > > hibernate> template. > > > > > > > > The CategoryHierarchy is not a database-aware object and it > > uses the > > > > CategoryDAO object for any data-access it may need. > > > > > > > > The problem is in the afterPropertiesSet() method on the > > > CategoryHierarchy> object. This is where I decided to make a > > call > > > to the CateogryDAO and get > > > > some data that the CategoryHierarchy object needs. > > > Unfortunately, I get a > > > > NullPointerException because the CategoryDAO object has yet to > > > have its > > > > afterPropertiesSet method invoked. This method sets up the=20 > > > > HibernateTemplate object. It is null, thus my NPE. > > > > > > > > Here is the order I am seeing: > > > > > > > > 1. CategoryDAO <init> > > > > 2. CategortHierarchy <init> > > > > 3. CategoryHierarchy.setCategoryDAO(o) > > > > 4. CategoryHierarchy.afterPropertiesSet() > > > > - NPE because it makes a call using CategoryDAO object 5.=20 > > > > CategoryDAO.setSessionFactory(o) 6.=20 > > > > CategoryDAO.setCategoryHierarchy(o) > > > > 7. CategoryDAO.afterPropertiesSet() > > > > - CategoryDAO can only answer calls after this step > > > > > > > > Is there a lifecycle event that fires *after* the factory has > > > configured> all > > > > of the static beans including all aop bindings? > > > > > > > > I have tried the 'init-method' attribute on the bean. It seems > > > to fire > > > > before afterPropertiesSet. I have tried the BeanFactoryAware > > > interface,> but > > > > it still fires pretty early. Is there an event that is > > triggered > > > after the > > > > factory wires up everything? > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build=20 > > > > and deploy apps & Web services for Linux with a free DVD=20 > > > > software kit from IBM. Click Now!=20 > > > > http://ads.osdn.com/?ad_id=3D1356&alloc_id=3D3438&op=3Dclick > > > > _______________________________________________ > > > > Springframework-developer mailing list=20 > > > > Spr...@li... > > > > https://lists.sourceforge.net/lists/listinfo/springframework- > > > developer > > > > > > > > > ------------------------------------------------------- > > > SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build = and=20 > > > deploy apps & Web services for Linux with a free DVD software kit = > > > from IBM. Click Now!=20 > > > http://ads.osdn.com/?ad_id=1356&alloc_id438&op=3Dclick > > > _______________________________________________ > > > Springframework-developer mailing list=20 > > > Spr...@li... > > > https://lists.sourceforge.net/lists/listinfo/springframework- > > developer> > > > > > > > > ------------------------------------------------------- > > SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and=20 > > deploy apps & Web services for Linux with a free DVD software kit=20 > > from IBM. Click Now!=20 > > http://ads.osdn.com/?ad_id=1356&alloc_id438&op=3Dclick > > _______________________________________________ > > Springframework-developer mailing list=20 > > Spr...@li... > > = https://lists.sourceforge.net/lists/listinfo/springframework-develop > > er > > >=20 >=20 >=20 > ------------------------------------------------------- > SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and=20 > deploy apps & Web services for Linux with a free DVD software kit = from=20 > IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id438&op=3Dick > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > = https://lists.sourceforge.net/lists/listinfo/springframework-developer ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id438&op=3Dclick _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |