I am trying to create an spring DM powered OSGi bundle (Bundle-A) which had an AOP advice and a client osgi bundle (Bundle-B) that would use this. In my Bundle-A I have an interface and its Impl in 2 differnet packages. For development, I have exported both the packages in its MANIFEST.MF.
Now in my Bundle-B I am trying to use the exported class as an AOP advice. First I tried defining a bean with the class as the actual Impl class from Bundle-A(This export of impl is just for dev). When I use this as my aop:aspect for method-before, it works fine and the method in the Bundle-A gets called. But I understand that exposing the impl class is not the right way, so I exported the interface in Bundle-A as an osgi:service and tried refering to it as osgi:reference in Bundle-B. But This is throwing the below exception--
This is the spring file in Bundle-A--Code:org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'loggerService': Requested bean is currently in creation: Is there an unresolvable circular reference?
This is the spring file in Bundle-B--Code:<?xml version="1.0" encoding="UTF-8"?> <beans ...> <!-- Expose the interface as a osgi service --> <osgi:service id="logger" ref="loggerBean" interface="ri.services.samples.aspect.LogService" /> <bean id="loggerBean" class="ri.services.samples.aspect.advice.LogServiceImpl" /> </beans>
Any help would be greatly appreciated!Code:<?xml version="1.0" encoding="UTF-8"?> <beans ..> <!-- refer the IMPL class directly --> <bean id="aspectBean" class="ri.services.samples.aspect.advice.LogServiceImpl" /> <!-- refer the interface as an osgi service --> <osgi:reference id="loggerService" interface="ri.services.samples.aspect.LogService" /> <!-- AOP config --> <aop:config> <!-- Works if ref="aspectBean", Throws excpetion if ref="loggerService" --> <aop:aspect id="myAspect" ref="loggerService"> <aop:pointcut id="anyPublicOperation" expression="execution(public * ri.services.samples.aspect.services.*.dooA1(..))" /> <aop:before pointcut-ref="anyPublicOperation" method="justLog" /> </aop:aspect> </aop:config> </beans>
Thanks!



