|
From: Dmitriy K. <dko...@ru...> - 2004-03-03 00:32:07
|
I just want to add - before step 1 (instantiation of any beans) - BeanFac= toryPostProcessor=2EpostProcessBeanFactory(ConfigurableListableBeanFactor= y beanFactory) =22kicks in=22=2E So with the custom implemetation of the = post processor it might be quite possible to eager-initialize concerned b= eans (dao impl in this case) before any other beans in the BeanFactory=2E= Any thoughts on this=3F Regards=2C Dmitriy=2E ----- Original Message ----- From=3A Alef Arendsen =3Calef=40jteam=2Enl=3E Date=3A Tuesday=2C March 2=2C 2004 6=3A43 pm Subject=3A RE=3A =5BSpringframework-developer=5D Lifecycle methods =3E The order is as follows=3A =3E = =3E 1=2E setting of bean properties (so=2C including your DAO) =3E 2=2E BeanNameAware =3E 3=2E BeanFactoryAware =3E 4=2E beanpostprocessor - preInitialize =3E 5=2E afterPropertiesSet =3E 6=2E init-method =3E 7=2E beanpostprocessor - postInitialize =3E 8=2E next bean =3E = =3E ((( This should be added to the docs by the way=2C I=27ll try to writ= e = =3E a decent =3E piece about it as soon as I have time and also after this = =3E discussion ))) =3E = =3E This means you=27re indeed you=27re going to run into problems there=2E= I=27ve =3E checked the BeanFactory and somewhere it states that (before step = =3E 1) it =3E guarantees that all beans the current bean depends on are = =3E guaranteed to be =3E initialized (of which I don=27t understand how that could be = =3E possible because =3E we=27re talking circular here)=2E So I guess we=27ll have to call in = the = =3E experthere =3B-)=2E =3E = =3E J=C3=BCrgen=2C could you elaborate a bit more here=2E=2E=2E =3E = =3E Alef =3E = =3E p=2Es=2E if you need a solution ASAP=2C I suggest you use a =3E BeanFactoryPostProcessor for now (just add one to your application = =3E context=2Cdoing some initialization work=2C it=27ll get detected = =3E automatically=2C or - in =3E case you=27re using just the BeanFactory=2C apply it programmatically= )=2E =3E = =3E =3E -----Original Message----- =3E =3E From=3A springframework-developer-admin=40lists=2Esourceforge=2En= et =3E =3E =5Bspringframework-developer-admin=40lists=2Esourceforge=2Enet=5D= On Behalf =3E =3E Of James Cook =3E =3E Sent=3A Tuesday=2C March 02=2C 2004 9=3A23 PM =3E =3E To=3A springframework-developer=40lists=2Esourceforge=2Enet =3E =3E Subject=3A =5BSpringframework-developer=5D Lifecycle methods =3E =3E = =3E =3E I think I am missing some basic lifecycle method=2C but I have = =3E read the docs =3E =3E and maybe it does not exist=3F =3E =3E = =3E =3E I have a cyclic relationship between two beans=3A =3E =3E = =3E =3E =3Cbean id=3D=22CategoryDAO=22 class=3D=22my=2ECategoryDAOHiberna= te=22=3E =3E =3E =3Cproperty name=3D=22sessionFactory=22=3E =3E =3E =3Cref local=3D=22sessionFactory=22/=3E =3E =3E =3C/property=3E =3E =3E =3Cproperty name=3D=22categoryHierarchy=22=3E =3E =3E =3Cref local=3D=22CategoryHierarchy=22/=3E =3E =3E =3C/property=3E =3E =3E =3C/bean=3E =3E =3E = =3E =3E =3Cbean id=3D=22CategoryHierarchy=22 class=3D=22my=2ECategoryHier= archy=22=3E =3E =3E =3Cproperty name=3D=22categoryDAO=22=3E =3E =3E =3Cref local=3D=22CategoryDAO=22/=3E =3E =3E =3C/property=3E =3E =3E =3C/bean=3E =3E =3E = =3E =3E CategoryDAO extends HibernateDaoSupport=2C so it=27s = =3E afterPropertiesSet()=3E method =3E =3E uses the session factory to initialize the DAO which creates a = =3E hibernate=3E template=2E =3E =3E = =3E =3E The CategoryHierarchy is not a database-aware object and it uses = the =3E =3E CategoryDAO object for any data-access it may need=2E =3E =3E = =3E =3E The problem is in the afterPropertiesSet() method on the = =3E CategoryHierarchy=3E object=2E This is where I decided to make a call= = =3E to the CateogryDAO and get =3E =3E some data that the CategoryHierarchy object needs=2E = =3E Unfortunately=2C I get a =3E =3E NullPointerException because the CategoryDAO object has yet to = =3E have its =3E =3E afterPropertiesSet method invoked=2E This method sets up the =3E =3E HibernateTemplate =3E =3E object=2E It is null=2C thus my NPE=2E =3E =3E = =3E =3E Here is the order I am seeing=3A =3E =3E = =3E =3E 1=2E CategoryDAO =3Cinit=3E =3E =3E 2=2E CategortHierarchy =3Cinit=3E =3E =3E 3=2E CategoryHierarchy=2EsetCategoryDAO(o) =3E =3E 4=2E CategoryHierarchy=2EafterPropertiesSet() =3E =3E - NPE because it makes a call using CategoryDAO object =3E =3E 5=2E CategoryDAO=2EsetSessionFactory(o) =3E =3E 6=2E CategoryDAO=2EsetCategoryHierarchy(o) =3E =3E 7=2E CategoryDAO=2EafterPropertiesSet() =3E =3E - CategoryDAO can only answer calls after this step =3E =3E = =3E =3E Is there a lifecycle event that fires *after* the factory has = =3E configured=3E all =3E =3E of the static beans including all aop bindings=3F =3E =3E = =3E =3E I have tried the =27init-method=27 attribute on the bean=2E It se= ems = =3E to fire =3E =3E before afterPropertiesSet=2E I have tried the BeanFactoryAware = =3E interface=2C=3E but =3E =3E it still fires pretty early=2E Is there an event that is triggere= d = =3E after the =3E =3E factory wires up everything=3F =3E =3E = =3E =3E = =3E =3E = =3E =3E = =3E =3E ------------------------------------------------------- =3E =3E SF=2ENet is sponsored by=3A Speed Start Your Linux Apps Now=2E =3E =3E Build and deploy apps =26 Web services for Linux with =3E =3E a free DVD software kit from IBM=2E Click Now! =3E =3E http=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=3D1356=26alloc=5Fid=3D3438=26= op=3Dclick =3E =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =3E =3E Springframework-developer mailing list =3E =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframewor= k- =3E developer =3E = =3E = =3E ------------------------------------------------------- =3E SF=2ENet is sponsored by=3A Speed Start Your Linux Apps Now=2E =3E Build and deploy apps =26 Web services for Linux with =3E a free DVD software kit from IBM=2E Click Now! =3E http=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=1356=26alloc=5Fid438=26op=3Dclic= k =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F =3E Springframework-developer mailing list =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframework-de= veloper =3E |
|
From: Dmitriy K. <dko...@ru...> - 2004-03-03 04:24:04
|
Alef=2C oops=2C didn=27t see that you already suggested BeanFactoryPostPr= ocessor=2E=2E=2E =3A-) D=2E ----- Original Message ----- From=3A Dmitriy Kopylenko =3Cdkopylen=40rutgers=2Eedu=3E Date=3A Tuesday=2C March 2=2C 2004 7=3A18 pm Subject=3A Re=3A RE=3A =5BSpringframework-developer=5D Lifecycle methods =3E I just want to add - before step 1 (instantiation of any beans) - = =3E BeanFactoryPostProcessor=2EpostProcessBeanFactory(ConfigurableListabl= eBeanFactory beanFactory) =22kicks in=22=2E So with the custom implemetat= ion 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 Bea= nFactory=2E Any thoughts on this=3F =3E = =3E Regards=2C =3E Dmitriy=2E =3E = =3E ----- Original Message ----- =3E From=3A Alef Arendsen =3Calef=40jteam=2Enl=3E =3E Date=3A Tuesday=2C March 2=2C 2004 6=3A43 pm =3E Subject=3A RE=3A =5BSpringframework-developer=5D Lifecycle methods =3E = =3E =3E The order is as follows=3A =3E =3E = =3E =3E 1=2E setting of bean properties (so=2C including your DAO) =3E =3E 2=2E BeanNameAware =3E =3E 3=2E BeanFactoryAware =3E =3E 4=2E beanpostprocessor - preInitialize =3E =3E 5=2E afterPropertiesSet =3E =3E 6=2E init-method =3E =3E 7=2E beanpostprocessor - postInitialize =3E =3E 8=2E next bean =3E =3E = =3E =3E ((( This should be added to the docs by the way=2C I=27ll try to = =3E write = =3E =3E a decent =3E =3E piece about it as soon as I have time and also after this = =3E =3E discussion ))) =3E =3E = =3E =3E This means you=27re indeed you=27re going to run into problems = =3E there=2E I=27ve =3E =3E checked the BeanFactory and somewhere it states that (before = =3E step = =3E =3E 1) it =3E =3E guarantees that all beans the current bean depends on are = =3E =3E guaranteed to be =3E =3E initialized (of which I don=27t understand how that could be = =3E =3E possible because =3E =3E we=27re talking circular here)=2E So I guess we=27ll have to call= in = =3E the = =3E =3E experthere =3B-)=2E =3E =3E = =3E =3E J=C3=BCrgen=2C could you elaborate a bit more here=2E=2E=2E =3E =3E = =3E =3E Alef =3E =3E = =3E =3E p=2Es=2E if you need a solution ASAP=2C I suggest you use a =3E =3E BeanFactoryPostProcessor for now (just add one to your = =3E application = =3E =3E context=2Cdoing some initialization work=2C it=27ll get detected = =3E =3E automatically=2C or - in =3E =3E case you=27re using just the BeanFactory=2C apply it programmatic= ally)=2E =3E =3E = =3E =3E =3E -----Original Message----- =3E =3E =3E From=3A springframework-developer-admin=40lists=2Esourceforge= =2Enet =3E =3E =3E =5Bspringframework-developer-admin=40lists=2Esourceforge=2Ene= t=5D On Behalf =3E =3E =3E Of James Cook =3E =3E =3E Sent=3A Tuesday=2C March 02=2C 2004 9=3A23 PM =3E =3E =3E To=3A springframework-developer=40lists=2Esourceforge=2Enet =3E =3E =3E Subject=3A =5BSpringframework-developer=5D Lifecycle methods =3E =3E =3E = =3E =3E =3E I think I am missing some basic lifecycle method=2C but I hav= e = =3E =3E read the docs =3E =3E =3E and maybe it does not exist=3F =3E =3E =3E = =3E =3E =3E I have a cyclic relationship between two beans=3A =3E =3E =3E = =3E =3E =3E =3Cbean id=3D=22CategoryDAO=22 class=3D=22my=2ECategoryDAOHib= ernate=22=3E =3E =3E =3E =3Cproperty name=3D=22sessionFactory=22=3E =3E =3E =3E =3Cref local=3D=22sessionFactory=22/=3E =3E =3E =3E =3C/property=3E =3E =3E =3E =3Cproperty name=3D=22categoryHierarchy=22=3E =3E =3E =3E =3Cref local=3D=22CategoryHierarchy=22/=3E =3E =3E =3E =3C/property=3E =3E =3E =3E =3C/bean=3E =3E =3E =3E = =3E =3E =3E =3Cbean id=3D=22CategoryHierarchy=22 class=3D=22my=2ECategory= Hierarchy=22=3E =3E =3E =3E =3Cproperty name=3D=22categoryDAO=22=3E =3E =3E =3E =3Cref local=3D=22CategoryDAO=22/=3E =3E =3E =3E =3C/property=3E =3E =3E =3E =3C/bean=3E =3E =3E =3E = =3E =3E =3E CategoryDAO extends HibernateDaoSupport=2C so it=27s = =3E =3E afterPropertiesSet()=3E method =3E =3E =3E uses the session factory to initialize the DAO which creates = a = =3E =3E hibernate=3E template=2E =3E =3E =3E = =3E =3E =3E The CategoryHierarchy is not a database-aware object and it = =3E uses the =3E =3E =3E CategoryDAO object for any data-access it may need=2E =3E =3E =3E = =3E =3E =3E The problem is in the afterPropertiesSet() method on the = =3E =3E CategoryHierarchy=3E object=2E This is where I decided to make a = =3E call = =3E =3E to the CateogryDAO and get =3E =3E =3E some data that the CategoryHierarchy object needs=2E = =3E =3E Unfortunately=2C I get a =3E =3E =3E NullPointerException because the CategoryDAO object has yet t= o = =3E =3E have its =3E =3E =3E afterPropertiesSet method invoked=2E This method sets up the =3E =3E =3E HibernateTemplate =3E =3E =3E object=2E It is null=2C thus my NPE=2E =3E =3E =3E = =3E =3E =3E Here is the order I am seeing=3A =3E =3E =3E = =3E =3E =3E 1=2E CategoryDAO =3Cinit=3E =3E =3E =3E 2=2E CategortHierarchy =3Cinit=3E =3E =3E =3E 3=2E CategoryHierarchy=2EsetCategoryDAO(o) =3E =3E =3E 4=2E CategoryHierarchy=2EafterPropertiesSet() =3E =3E =3E - NPE because it makes a call using CategoryDAO object =3E =3E =3E 5=2E CategoryDAO=2EsetSessionFactory(o) =3E =3E =3E 6=2E CategoryDAO=2EsetCategoryHierarchy(o) =3E =3E =3E 7=2E CategoryDAO=2EafterPropertiesSet() =3E =3E =3E - CategoryDAO can only answer calls after this step =3E =3E =3E = =3E =3E =3E Is there a lifecycle event that fires *after* the factory has= = =3E =3E configured=3E all =3E =3E =3E of the static beans including all aop bindings=3F =3E =3E =3E = =3E =3E =3E I have tried the =27init-method=27 attribute on the bean=2E I= t seems = =3E =3E to fire =3E =3E =3E before afterPropertiesSet=2E I have tried the BeanFactoryAwar= e = =3E =3E interface=2C=3E but =3E =3E =3E it still fires pretty early=2E Is there an event that is = =3E triggered = =3E =3E after the =3E =3E =3E factory wires up everything=3F =3E =3E =3E = =3E =3E =3E = =3E =3E =3E = =3E =3E =3E = =3E =3E =3E ------------------------------------------------------- =3E =3E =3E SF=2ENet is sponsored by=3A Speed Start Your Linux Apps Now=2E= =3E =3E =3E Build and deploy apps =26 Web services for Linux with =3E =3E =3E a free DVD software kit from IBM=2E Click Now! =3E =3E =3E http=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=3D1356=26alloc=5Fid=3D34= 38=26op=3Dclick =3E =3E =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F =3E =3E =3E Springframework-developer mailing list =3E =3E =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E =3E =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springfram= ework- =3E =3E developer =3E =3E = =3E =3E = =3E =3E ------------------------------------------------------- =3E =3E SF=2ENet is sponsored by=3A Speed Start Your Linux Apps Now=2E =3E =3E Build and deploy apps =26 Web services for Linux with =3E =3E a free DVD software kit from IBM=2E Click Now! =3E =3E http=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=1356=26alloc=5Fid438=26op=3D= click =3E =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =3E =3E Springframework-developer mailing list =3E =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframewor= k- =3E developer=3E = =3E = =3E = =3E = =3E ------------------------------------------------------- =3E SF=2ENet is sponsored by=3A Speed Start Your Linux Apps Now=2E =3E Build and deploy apps =26 Web services for Linux with =3E a free DVD software kit from IBM=2E Click Now! =3E http=3A//ads=2Eosdn=2Ecom/=3Fad=5Fid=1356=26alloc=5Fid438=26op=3Dclic= k =3E =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F= =5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F =3E Springframework-developer mailing list =3E Springframework-developer=40lists=2Esourceforge=2Enet =3E https=3A//lists=2Esourceforge=2Enet/lists/listinfo/springframework-de= veloper =3E |
|
From: James C. <jim...@do...> - 2004-03-03 18:26:13
|
I'm seeing strange behavior when I try to use this interface. I have
implemented a class that implements this interface and registered it in =
my
app config.
public class BeanPostProcessorFactory implements =
BeanFactoryPostProcessor {
public void postProcessBeanFactory(ConfigurableListableBeanFactory
beanFactory) throws BeansException {
Map map =3D
beanFactory.getBeansOfType(BeanPostProcessor.class, true, true);
for (Iterator i =3D map.values().iterator(); i.hasNext();) {
BeanPostProcessor bean =3D (BeanPostProcessor)
i.next();
bean.postProcessBean(beanFactory);
}
}
}
So I've created an interface that I can apply to my beans, causing them =
to
be invoked by the BeanFactoryPostProcessor.
What's strange is that this BeanFactoryPostProcessor does not seem to =
fire
when I expected. I expected it to fire *after* the BeanFactory has
instantiated and wired up all of the beans.
But instead, according to the code in AbstractApplicationContext, it =
appears
that this method call is firing before the
getBeanFactory().preInstantiateSingletons() method?
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...] On =
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
> 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(ConfigurableListableBeanF=
a
> 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
> > > 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
> > > guaranteed to be
> > > initialized (of which I don't understand how that 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
> > > BeanFactoryPostProcessor for now (just add one to your
> > application
> > > context,doing some initialization work, it'll get detected
> > > automatically, or - in
> > > case you're using just the BeanFactory, apply it =
programmatically).
> > >
> > > > -----Original Message-----
> > > > From: spr...@li...
> > > > [spr...@li...] On =
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
> > > > 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. CategoryDAO.setSessionFactory(o)
> > > > 6. 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 and deploy apps & Web services for Linux with
> > > > a free DVD software kit from IBM. Click Now!
> > > > http://ads.osdn.com/?ad_id=3D1356&alloc_id=3D3438&op=3Dclick
> > > > _______________________________________________
> > > > 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>
> >
> >
> >
> > -------------------------------------------------------
> > 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
> >
>=20
>=20
>=20
> -------------------------------------------------------
> 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=3Dick
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
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 |
|
From: James C. <jim...@do...> - 2004-03-03 19:09:18
|
Thanks, but in relation to my original request, how can I invoke a method on my singleton bean only after all other beans have been created by the factory? Does this capability exist? How are others handling a cyclic redundancy between two beans? > -----Original Message----- > [mailto:spr...@li...] On Behalf > Of Kopylenko, Dmitry > 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. |
|
From: Kopylenko, D. <dko...@ac...> - 2004-03-03 20:57:34
|
I would think by doing something like this:
postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
beanFactory.getBean("beanName");
}
it would instantiate the bean, if not done so already and call its lifecycle
callbacks
Juergen, can you confirm, please.
-----Original Message-----
From: James Cook [mailto:jim...@do...]
Sent: Wednesday, March 03, 2004 1:56 PM
To: spr...@li...
Subject: RE: RE: [Springframework-developer] Lifecycle methods
Thanks, but in relation to my original request, how can I invoke a method on
my singleton bean only after all other beans have been created by the
factory? Does this capability exist?
How are others handling a cyclic redundancy between two beans?
> -----Original Message-----
> [mailto:spr...@li...] On
> Behalf Of Kopylenko, Dmitry 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.
-------------------------------------------------------
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_id=3438&op=click
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: James C. <jim...@do...> - 2004-03-03 21:42:55
|
Well, the getBean("") call is done by the BeanFactory because these are
singleton beans. After the bean in instanced is when the
postProcessBeanFactory() method is invoked.
Even then, it is still too early. I think we need an interface that any bean
can implement that fires after the BeanFactory completes its configuration.
Something like:
public interface postBeanFactoryConfigure {
void postConfigureBeanFactory(BeanFactory beanFactory);
}
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...] On Behalf
> Of Kopylenko, Dmitry
> Sent: Wednesday, March 03, 2004 3:44 PM
> To: 'spr...@li...'
> Subject: RE: RE: [Springframework-developer] Lifecycle methods
>
> I would think by doing something like this:
>
> postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
> beanFactory.getBean("beanName");
> }
>
> it would instantiate the bean, if not done so already and call its
> lifecycle
> callbacks
>
> Juergen, can you confirm, please.
>
> -----Original Message-----
> From: James Cook [mailto:jim...@do...]
> Sent: Wednesday, March 03, 2004 1:56 PM
> To: spr...@li...
> Subject: RE: RE: [Springframework-developer] Lifecycle methods
>
>
> Thanks, but in relation to my original request, how can I invoke a method
> on
> my singleton bean only after all other beans have been created by the
> factory? Does this capability exist?
>
> How are others handling a cyclic redundancy between two beans?
>
> > -----Original Message-----
> > [mailto:spr...@li...] On
> > Behalf Of Kopylenko, Dmitry 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.
>
>
>
>
>
> -------------------------------------------------------
> 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_id=3438&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: Kopylenko, D. <dko...@ac...> - 2004-03-03 21:49:17
|
Nope, this is exactly what the BeanFactoryPostProcessor is all about - no
bean instances has been created yet, but all RootBeanDefinitions has been
"prepared".
What do you mean it's still too early?
-----Original Message-----
From: James Cook [mailto:jim...@do...]
Sent: Wednesday, March 03, 2004 4:29 PM
To: spr...@li...
Subject: RE: RE: [Springframework-developer] Lifecycle methods
Well, the getBean("") call is done by the BeanFactory because these are
singleton beans. After the bean in instanced is when the
postProcessBeanFactory() method is invoked.
Even then, it is still too early. I think we need an interface that any bean
can implement that fires after the BeanFactory completes its configuration.
Something like:
public interface postBeanFactoryConfigure {
void postConfigureBeanFactory(BeanFactory beanFactory);
}
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...] On
> Behalf Of Kopylenko, Dmitry
> Sent: Wednesday, March 03, 2004 3:44 PM
> To: 'spr...@li...'
> Subject: RE: RE: [Springframework-developer] Lifecycle methods
>
> I would think by doing something like this:
>
> postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
> beanFactory.getBean("beanName");
> }
>
> it would instantiate the bean, if not done so already and call its
> lifecycle callbacks
>
> Juergen, can you confirm, please.
>
> -----Original Message-----
> From: James Cook [mailto:jim...@do...]
> Sent: Wednesday, March 03, 2004 1:56 PM
> To: spr...@li...
> Subject: RE: RE: [Springframework-developer] Lifecycle methods
>
>
> Thanks, but in relation to my original request, how can I invoke a
> method on my singleton bean only after all other beans have been
> created by the factory? Does this capability exist?
>
> How are others handling a cyclic redundancy between two beans?
>
> > -----Original Message-----
> > [mailto:spr...@li...] On
> > Behalf Of Kopylenko, Dmitry 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.
>
>
>
>
>
> -------------------------------------------------------
> 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_id=3438&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: IBM Linux Tutorials
> Free Linux tutorial presented by Daniel Robbins, President and CEO of
> GenToo technologies. Learn everything from fundamentals to system
> administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo
technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: James C. <jim...@do...> - 2004-03-03 22:16:25
|
I think we are both on the same page, but you have to go back to my initial post to see the problem. I have two singleton beans that point at each other. One is a DAO (BEAN_DAO) and the other is not (BEAN_NOT_DAO). The problem is that I need to initialize BEAN_NOT_DAO once the factory has set all of the properties on *both* beans. This is because BEAN_NOT_DAO depends on a call to BEAN_DAO that requires the setSessionFactory(HibernateSession) call to be made already. Unfortunately, there does not seem to be a hook provided by the BeanFactory to configure objects after all there dependencies are resolved. > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...] On Behalf > Of Kopylenko, Dmitry > Nope, this is exactly what the BeanFactoryPostProcessor is all about - no > bean instances has been created yet, but all RootBeanDefinitions has been > "prepared". > > What do you mean it's still too early? |
|
From: <tri...@tr...> - 2004-03-03 22:52:27
|
James, Have you tried implementing an ApplicationListener interface in your BEAN_NOT_DAO. I've never used it but it sounds like it could solve your problem. Look at section 3.10.2 in the reference manual. Thomas Quoting James Cook <jim...@do...>: > I think we are both on the same page, but you have to go back to my initial > post to see the problem. I have two singleton beans that point at each > other. One is a DAO (BEAN_DAO) and the other is not (BEAN_NOT_DAO). The > problem is that I need to initialize BEAN_NOT_DAO once the factory has set > all of the properties on *both* beans. This is because BEAN_NOT_DAO depends > on a call to BEAN_DAO that requires the setSessionFactory(HibernateSession) > call to be made already. > > Unfortunately, there does not seem to be a hook provided by the BeanFactory > to configure objects after all there dependencies are resolved. > > > -----Original Message----- > > From: spr...@li... > > [mailto:spr...@li...] On Behalf > > Of Kopylenko, Dmitry > > Nope, this is exactly what the BeanFactoryPostProcessor is all about - no > > bean instances has been created yet, but all RootBeanDefinitions has been > > "prepared". > > > > What do you mean it's still too early? > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > |