|
From: James C. <jim...@do...> - 2004-05-14 13:29:25
|
Anyone have any thoughts on this? > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...] On Behalf > Of James Cook > Sent: Wednesday, May 12, 2004 10:05 AM > To: spr...@li... > Subject: RE: [Springframework-developer] Bean not advised because another > dependency grabs it first? > > A simpler example may be in order. > > <bean id="SAO" class="MySAO" /> > > <bean id="AutoProxy" > class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreato > r" > > > <property name="interceptorNames"> > <list> > <idref local="transactionInterceptor"/> > </list> > </property> > <property name="beanNames"> > <list> > <idref local="SAO"/> > </list> > </property> > </bean> > > <bean id="ClassThatUsesSAO" class="MyBusinessObject"> > <property name="sao"><ref bean="SAO" /></property> > </bean> > > The problem is that the "ClassThatUsesSAO" is noticed first be Spring, and > Spring discovers that there is a property on this bean that uses the "SAO" > bean. Spring then instantiates the SAO bean and sets the resulting value > to > the property on the "ClassThatUsesSAO". Unfortunately, the SAO bean is not > auto proxied at this time, and never will be as far as the > "ClassThatUsesSAO" is concerned. > > Is there any way to ensure that the autoproxy has a chance to advise the > "SAO" bean prior to invoking setSao() on the "ClassThatUsesSAO"? |