Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] weaving into Eclipse classes

Hi Davi,

It is possible to a long way with Eclipse and AspectJ
without special tools.
All aspects have to be woven into your code, not Eclipse's
but that is not as bad as it sounds.
Usually you want advice at the interface
between your code and Eclipse
The main trick is that
call( ) pointcut weave into the caller
and execution( ) weaves into the callee,
So you use call( ) for when your code calls Eclipse
and execution for when Eclipse calls your code.
You can't put advice on Eclipse calling itself,
but you do not need that as often as you might think
(do you really know/care how/when Eclipse calls its own code?)
When you do need that there are a few workarounds:

When you subclass Eclipse classes
you can override parent methods
with trivial methods that just do super calls.
This preserves the semantics, but gives you a join point you can use.
You can even subclass classes you just to do the above,
and then make sure your factories use your subclasses.
(of course if you have to do that a lot
you are not really getting much benefit from AOP).

I belive you can also import an Eclipse plugin into your workspace
and thus make it 'yours'. You should the be able to weave inside it.
I have not had to do that yet, so I do not know how well that works in practice.

The thing I really miss in my approach is the ability
to declare parents on Eclipse classes.
Unfortunately, AJEER has not been adapted to work
with current Eclipse versions and I did not get it to work
on an older Eclipse verion either.
AOSGI sounds very promising,
but is no indication of when it is scheduled to be released.


Still I am very happy to be using AspectJ to develop EMF plugins.
Classes genterated by EMF do not have common ancestors,
so customizing methods globally otherwise either
involves repetitive editing or messing with JET templates.
With aspects you apply a single piece of advice
to tens or even hundreds of join points,
and you gett to keep you customizations
in one place separate from  the generated code.

Let me know how you get on.

Daniel

On 10/9/06, Davi Pires <inhodpr@xxxxxxxxx> wrote:
Arjun,

Thanks. I'll take a look at AJEER and see if it helps.

However, from those threads I read, it seems to be possible to weave into
other plugins without using any special technology. And that would be the
best choice, undoubtedly, but I can't figure out how it can be done.

Perhaps Mr. Mahler himself could show me the way...

Thanks for the help.

Davi Pires



On 10/6/06, Arjun Singh <aasingh@xxxxxxxxx> wrote:
>
> Each plugin has its own classloader.  According the the aspectj
> developer guide, load time weaving is done in the context of a class
> loader.  A class loader can only weave classes that it defines, not
> classes loaded by other class loaders.  So I believe that is why an
> aspect in your plugin is not woven into any of the eclipse plugins.
> AJEER defines specialized classloaders that somehow address this.
>
> Hope that helps,
> Arjun
>
> On 10/6/06, Davi Pires <inhodpr@xxxxxxxxx> wrote:
> > Not really, actually.
> >
> > In the second thread, Mahler says:
> > > I now know that one cannot apply aspects within Eclipse code
> > > without using something like AJEER (or AOSGI when it becomes
> available).
> > >
> >
> > And that's precisely what I don't know.
> >
> >
> >
> >
> >  On 10/6/06, Arjun Singh <aasingh@xxxxxxxxx> wrote:
> > > Hi Davi,
> > >
> > > There are two related threads that might help you:
> > >
> > >
> > http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg06409.html
> > >
> > http://dev.eclipse.org/mhonarc/lists/aspectj-users/msg06414.html
> > >
> > > After reading those, do you have any questions?
> > >
> > > Arjun
> > >
> > > On 10/6/06, Davi Pires < inhodpr@xxxxxxxxx> wrote:
> > > > Hi all,
> > > >
> > > > I'm writing an Eclipse plugin that tries to use AspectJ to weave
> some
> > > > methods into the classes of Eclipse AST, which are in the package
> > > > org.eclipse.jdt.core.dom.
> > > >
> > > > However, I don't understand the warning I get from the compiler,
> saying
> > that
> > > > "the type is not exposed to the weaver". I have the plugins in the
> > > > dependencies list of my plugin, and I thought the load time weaver
> could
> > > >
> > > > Anyone can show me a way to get around this (if there is any)?
> > > >
> > > > Thanks.
> > > >
> > > > Davi Pires
> > > >
> > > > _______________________________________________
> > > > aspectj-users mailing list
> > > > aspectj-users@xxxxxxxxxxx
> > > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > > >
> > > >
> > > >
> > > _______________________________________________
> > > aspectj-users mailing list
> > > aspectj-users@xxxxxxxxxxx
> > > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> > >
> >
> >
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >
> >
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>




Back to the top