> Is it possible to use an OSGI service in the advice of an aspect? It requires 
> a BundleContext to use a service, which I have always gotten from an 
> Activator. Should I make my Aspect into a bundle? I am lost of how to tackle 
> this problem as of now :(

No.  Bundle activators and aspects have incompatible instatiation
models. Bundle activaors are created by OSGi and aspects, by the
aspectj runtime (and are ususally singletons unless a per-clause is
used).

Bundle activators are themselves singletons.  It should be possible to
get a handle on the activator from within the aspect.  So, really,
getting an OSGi service in an aspect is no different than getting one
from a class.

As a side note, a generally accepted programming principle of AOP is
that aspects should do as little 'real' work as possible and delegate
as much computation to a class as possible.

>
> My goal is to hide the cross-cutting concern of undo from my gui classes that 
> contain swing components. For example, all my JTextfields are undoable, and 
> the code that enables this is very repetitive and it would be nice to 
> centralise that code in one spot in an aspect :)
>
_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to