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

Dear all,

I am new to this list and new to Aspectj, and I would like to ask my first, perhaps a freshman, 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?

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.

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.