Circular references with ProxyFactoryBean
I'm about at my wit's end. Hopefully somebody can help me out here.
I'm doing the typical: (forgive the crudeness of the xml, I don't have the code in front of me, but this is the idea)
<bean id="abstractProxy" class="ProxyFactoryBean" abstract="true">
<property name="interceptors">
<list>
<value>myInterceptor</value>
<list>
</property>
</bean>
<bean id="abstractBean" class="BaseBean" abstract="true"/>
<bean id="myProxiedBean" parent="abstractProxy">
<property name="proxiedInterfaces">
<list>
<value>InterfaceForProxiedBean</value>
</list>
</property>
<property name="target">
<bean parent="abstractBean">
...
...
</bean>
</property>
</bean>
<bean id="mySecondProxiedBean" parent="abstractProxy">
<property name="proxiedInterfaces">
<list>
<value>InterfaceForSecondProxiedBean</value>
</list>
</property>
<property name="target">
<bean parent="abstractBean">
...
...
</bean>
</property>
</bean>
<bean id ="myThirdProxyBean>
...
...
</bean>
fourth,
fifth,
sixth, etc.
<bean id="myManager" class="MyManager">
<property name="bean1" value="myProxiedBean"/>
<property name="bean2" value="mySecondProxiedBean"/>
</bean>
(bean1 and bean2 are of type InterfaceForProxiedBean and INterfaceForSecondProxiedBean, respectively)
<bean id="myManager2" class="MyManager2">
<property name="bean1" value="myProxiedBean"/>
<property name="bean2" value="mySecondProxiedBean"/>
</bean>
(bean1 and bean2 are of type InterfaceForProxiedBean and
INterfaceForSecondProxiedBean, respectively)
And last of all:
<bean id="proxyCreator" class="BeanNameAutoProxyCreator">
<property name="*Manager" />
<property name="interceptorNames">
<list>
<value>someInterceptor</value>
</list>
</property>
</bean>
This works nearly ALL the time, but sometimes it fails.
I get INTERMITTENT and UNPREDICTABLE circular reference errors and BeanNotCreated Exceptions.
When I remove the BeanNameAutoProxyCreator everything works fine. Obviously that's where the circular problem is appearing. Does this qualify as being circular?
Is there a workaround for this? I've wanted to use an aop:config block but I think that the aop:config block only allows introductions on an object when the pointcut has been satisfied. I need to proxy certain interfaces earlier than that.
Does anybody know how to handle this?
Can it be handled?
The fact that it works intermittently tells me that this approach is at least somewhat correct. Is this a bug or is this just bad practice on my part?