Hey! >> Where can I find an example of how to do this? Or would it be easier if I >> simply used a tool like AspectJ? Does AspectJ play nicely with OSGi? > > Possibly not… AspectJ does a fair bit more than you actually need. If > somebody has gone to the trouble of fully integrating AspectJ into OSGi then > you might want to use it, otherwise you’re probably looking at a lot more > work than necessary. > > I would go with ASM, personally.
+1 from my side. But I think I should at least mention that there is indeed an implementation of load-time weaving for the full AspectJ language for OSGi systems that are running on top of Equinox. It is not based on the OSGi weaving hook (yet), but uses some Equinox internal API to implement load-time weaving and caching of woven OSGi bundles. Some basic information can be found here: https://www.eclipse.org/equinox/weaving/ Although this is quite old and maybe a bit outdated. It is a long time ago that I implemented this. The Spring Tool Suite uses this in action to weave some code into the Java tooling of Eclipse, for example. Anyway, I would recommend to use ASM for your issue (AspectJ weaving might be a bit heavyweight for the issue), but if you would like to spend some time getting your hands dirty with AspectJ weaving for OSGi, here are the pointers. Cheers, -Martin > > Regards, > Neil > > >> >> From: osgi-dev-boun...@mail.osgi.org [mailto:osgi-dev-boun...@mail.osgi.org] >> On Behalf Of Raymond Auge >> Sent: Thursday, February 18, 2016 11:25 AM >> To: OSGi Developer Mail List >> Subject: Re: [osgi-dev] Monitor method calls for a bundle? >> >> If you want to get really crazy you can go to full Weaving (Chapter 56 of >> Core spec). >> >> - Ray >> >> On Thu, Feb 18, 2016 at 11:17 AM, elias vasylenko <eliasvasyle...@gmail.com> >> wrote: >> The standard OSGi way I suppose would be to use service hooks to intercept >> service registrations, and re-register proxied versions. Would be simple >> enough to intercept invocation parameters and results in this way. >> >> Cheers, >> >> Eli >> >> On Thu, 18 Feb 2016 at 16:10 Steve Marotta <smaro...@cra.com> wrote: >> Hello, >> >> I was wondering if there was a way, built into OSGi, to automatically listen >> for any time that code in one bundle invokes a method on a service in >> another bundle. For example, if I have a service defined with a method that >> takes a “name” string and queries a database to return an “address” string, >> I want to be able to build a separate component that will listen for these >> method calls and invoke a callback both when the method is called, where I >> can see the name string that was passed, and a callback when the method >> returns, where I can see the address string that comes back. I could do this >> manually using something like aspect-oriented programming, but if there is a >> way to do this that is built into OSGi, then it will save me the trouble. >> >> Thanks, >> Steve >> _______________________________________________ >> OSGi Developer Mail List >> osgi-dev@mail.osgi.org >> https://mail.osgi.org/mailman/listinfo/osgi-dev >> >> _______________________________________________ >> OSGi Developer Mail List >> osgi-dev@mail.osgi.org >> https://mail.osgi.org/mailman/listinfo/osgi-dev >> >> >> >> -- >> Raymond Augé (@rotty3000) >> Senior Software Architect Liferay, Inc. (@Liferay) >> Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance) >> _______________________________________________ >> OSGi Developer Mail List >> osgi-dev@mail.osgi.org >> https://mail.osgi.org/mailman/listinfo/osgi-dev > > _______________________________________________ > OSGi Developer Mail List > osgi-dev@mail.osgi.org > https://mail.osgi.org/mailman/listinfo/osgi-dev _______________________________________________ OSGi Developer Mail List osgi-dev@mail.osgi.org https://mail.osgi.org/mailman/listinfo/osgi-dev