Hi Martin, Thank you very much for the quick reply! I thought the weaving with 'ajc' would already include the aspect in the bundle but now I see it's not the case.
Thanks again! Tiago On Fri, Jan 14, 2011 at 12:02 PM, Martin Lippert <lipp...@acm.org> wrote: > Hi Tiago! > > You can weave aspects into OSGi bundles at compile time, but you need to > take care of the dependencies that the weaving creates. > > 1. > The woven class will depend on types from org.aspectj.lang or > org.aspectj.runtime. So you need to change the OSGi manifest of your host > bundle to import those packages. > > 2. > The woven class will depend on the type of the aspect. So depending on > where the aspect actually is, you need to add that dependency to the OSGi > manifest as well. If you put your aspect into your host bundle, there is > nothing you need to do. If your aspect resides in a different bundle, you > need to import the package of the aspect into your host bundle via the > manifest. > > HTH, > Martin > > > > On 14.01.11 11:52, Tiago Espinha wrote: > >> Dear all, >> >> I've been trying to use AspectJ to weave an aspect into an existing OSGi >> bundle (I'm trying to weave directly in to the JAR, as that's actually >> the point of what I'm doing) but I'm getting strange results. >> >> So far I've been able to do the actual weaving but when I load the >> bundle onto Apache Felix, I get the following: >> -------------------8<--------------------- >> g! felix:start 20 >> g! Exception in thread "AWT-EventQueue-0" >> java.lang.NoClassDefFoundError: org/aspectj/lang/NoAspectBoundException >> at >> >> org.apache.felix.example.servicebased.host.DrawingFrame.<init>(DrawingFrame.java:54) >> at >> >> org.apache.felix.example.servicebased.host.Activator$1.run(Activator.java:69) >> at java.awt.event.InvocationEvent.dispatch(Unknown Source) >> at java.awt.EventQueue.dispatchEvent(Unknown Source) >> at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown >> Source) >> --------------------8<-------------------- >> >> The bundle I've been using for my experiments is the one provided by the >> Felix project itself at [1]. I'm trying to weave the following aspect >> into the 'host' bundle: >> --------------------8<-------------------- >> import java.awt.*; >> import java.awt.event.*; >> import java.util.*; >> >> import javax.swing.*; >> >> import org.apache.felix.example.servicebased.host.DrawingFrame; >> >> public aspect ComponentLogger { >> pointcut frameConstruction(DrawingFrame d) : this(d) && >> execution(DrawingFrame.new()); >> >> before(DrawingFrame d) : frameConstruction(d) >> { >> JOptionPane.showMessageDialog(d,"We've just weaved into the >> constructor!"); >> } >> } >> --------------------8<------------------ >> >> The goal of this would be to have a message dialog show up whenever a >> DrawingFrame is created. Am I doing something blatantly wrong? Or is it >> simply not possible to weave aspects into OSGi bundles? >> >> Many Thanks, >> Tiago >> >> [1] - >> http://felix.apache.org/site/apache-felix-application-demonstration.html >> >> >> >> _______________________________________________ >> aspectj-users mailing list >> aspectj-users@eclipse.org >> https://dev.eclipse.org/mailman/listinfo/aspectj-users >> > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > https://dev.eclipse.org/mailman/listinfo/aspectj-users >
_______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org https://dev.eclipse.org/mailman/listinfo/aspectj-users