Hello, Please don't take me wrong, but I would call it a "poor man's AOP" :)We cannot explicitly express concepts such as joinpoints, pointcuts or advices. Hooks provide an elegant but limited workaround. Depending on what you need, it may not be enough.I could not find a way to intercept the actual service object being served (i.e. getService). A BindHook proposed in the service hooks specification draft would do that, but it was apparently rejected since it is described as a considered alternative, but not present in the final spec.By using AspectJ I could do that as well as other things I needed, with relative portability since it worked in different versions of Felix, Knopflerfish and Equinox without much effort. However, by doing that you no longer have a standard framework implementation. I'm not sure if this message helps, but I just wanted to share what I did with AOP on top of OSGi. Cheers,Kiev
> Date: Wed, 31 Mar 2010 12:30:46 +0200 > Subject: Re: AOP in Apache Felix > From: [email protected] > To: [email protected] > > Thankyou guys, > > I will try and look at both service hooks and @AspectService(ranking=1)... > I see I still have a bit of information to process to get up to walking > speed > > Ivanbhoe > > > On Wed, Mar 31, 2010 at 11:43 AM, Marcel Offermans < > [email protected]> wrote: > > > On Mar 31, 2010, at 11:12 , Guillaume Nodet wrote: > > > > > Wouldn't it make more sense to use service hooks instead ? > > > > Service hooks are somewhat less dynamic in that I cannot decide lateron to > > install them and have them work with "everything that was already in place". > > This is explained in 12.7.3 about Ordering. I wanted to have this ability, > > even for services that were already used by clients before the aspect was > > installed. If you don't need that ability, and don't mind being able to run > > only on 4.2 frameworks, then service hooks are a good alternative. > > > > > The current design is limited as if a user wants to grab the list of > > > services and use those, that would not work. > > > > That depends on how you actually grab that list of course. If you just grab > > a list of all services of a certain type, that won't work, but it's not > > actually too hard to pick only the highest ranking service if there are > > multiple services in the list that otherwise have the same properties. But > > you are right, this is a little bit more involved and would be simpler if > > service hooks were used. > > > > Perhaps it would be nice to have the option to use service hooks if your > > trade offs are different and you don't mind having to install the hooks > > first. > > > > Greetings, Marcel > > > > > > > > > > On Wed, Mar 31, 2010 at 11:06, Marcel Offermans < > > [email protected] > > >> wrote: > > > > > >> On Mar 31, 2010, at 11:02 , Ivanhoe Abrahams wrote: > > >> > > >>> This is helpful in getting me pointing in the right direction. > > >>> So just to recap. > > >>> > > >>> Option 1 in your email is the traditional approach where you have aop > > >>> pointcuts, etc. defined > > >>> Option 2 is intercepting the calls and dynamically weaves in > > >>> code...something akin to asm bytecode weaving? > > >> > > >> It does not do bytecode weaving at all, it relies on the fact that > > services > > >> have a service ranking, so the aspect simply publishes a service with > > all > > >> the same properties as the original one, but a higher ranking. Clients > > will > > >> automatically pick the service with the highest ranking. So there's no > > >> bytecode weaving at all (which makes debugging a lot easier, since your > > code > > >> still looks exactly like you wrote it). > > >> > > >> Greetings, Marcel > > >> > > >> > > >> --------------------------------------------------------------------- > > >> To unsubscribe, e-mail: [email protected] > > >> For additional commands, e-mail: [email protected] > > >> > > >> > > > > > > > > > -- > > > Cheers, > > > Guillaume Nodet > > > ------------------------ > > > Blog: http://gnodet.blogspot.com/ > > > ------------------------ > > > Open Source SOA > > > http://fusesource.com > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [email protected] > > For additional commands, e-mail: [email protected] > > > > _________________________________________________________________ Hotmail: Powerful Free email with security by Microsoft. https://signup.live.com/signup.aspx?id=60969

