Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Weaving into a Java Project

> Over the context menu's properties entry I set the Inpath of "WeavingSource"
> to the project "WeavingTarget" and enabled the output of weaving information
> to the problems view.

This configuration means that when building WeavingSource it will
consume the output class files from WeavingTarget, apply the aspect,
and then write the woven class files *to the output folder for
WeavingSource*.  WeavingTarget is completely untouched and the class
files within it remain unwoven.  This means you will only be executing
the woven classes if you 'run'/'load' those in the WeavingSource as
replacements for those in WeavingTarget.

The simplest configuration is Convert WeavingTarget to an AspectJ
project then put WeavingSource on its aspectpath.  I realise you don't
want to change WeavingTarget, but this would be the simplest way.  Or
you could use equinox aspects weaving as you are in a plugin
environment anyway, that will load time weaving your aspect, but
weaving is then a loadtime activity rather than a compile time
activity.

Andy

2010/1/11 Holger Gulrot <holger.gulrot@xxxxxxxxx>:
> Dear all,
>
> I am new to this list and new to Aspectj, and I would like to ask my first,
> perhaps a freshman, question.
>
> Question:
> Why is advice of an aspect in one eclipse plug-in not invoked when running
> another eclipse plug-in that contains a class with the corresponding join
> point despite ajdt telling me that the join point is advised?
>
> Explanation:
> I have two eclipse plug-in projects. As a minimal example, I created a
> plug-in "WeavingTarget" that contains the "Sample XML Editor" which you can
> choose when creating a new plug-in project. As a second plug-in, named
> "WeavingSource", I generated an empty plug-in project (without an activator)
> converted it into an Aspectj project (using the context menu entry) and
> added the following aspect to it:
>
>
>     package weavingsource;
>
>     public aspect ActivatorAspect {
>
>         pointcut start() : execution(public void *.start(..));
>
>         after() : start() {
>             System.out.println("plugin was started");
>         }
>     }
>
> Over the context menu's properties entry I set the Inpath of "WeavingSource"
> to the project "WeavingTarget" and enabled the output of weaving information
> to the problems view. Where the folowing information gets displayed:
>
>     Join point 'method-execution(void
> weavingtarget.Activator.start(org.osgi.framework.BundleContext))' in Type
> 'weavingtarget.Activator' (Activator.java:28)     advised by after advice
> from 'weavingsource.ActivatorAspect' (ActivatorAspect.aj:7)    WeavingSource
>
> Thus I assume that my advice was correctly applied to the specified join
> point.
>
> After starting eclipse's runtime instance (via run as eclipse application)
> and after opening an xml file with the Sample XML Editor, the Activator's
> start method was called and the console should display the message specified
> in the aspect's advice.
> But this does not happen. Why? Do I need to set something else/more then the
> Inpath of "WeavingSource"? Even setting a plug-in dependency in the manifest
> file from "WeavingSource" to "WeavingTarget" does not produce another
> result...
> For testing purposes I put the aspect next to the Activator in the
> "WeavingTarget" plug-in and this results in displaying the aspect's advice
> message when opening the Sample XML Editor. I do not want to make use of
> this workaround since I want to leave the "WeavingTarget" plug-in
> unmodified.
>
> Setup:
> I am using eclipse galileo (3.5.1) with ajdt (2.0.1) and aspectj (1.6.6).
>
>
> I would appreciate if you could help me out.
>
> Best,
> Holger
>
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>


Back to the top