Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Choosing which mixin among a collection of possible ones to actually use

Hi,

I was trying to make some simple mixins using AspectJ.

My scenario is the following. I have an (abstract) class, let's say Foo, that implements the interface Bar, and that has a template method in which it calls the methods provided by the Bar interface.

interface Bar {
  String barMethod();
}

abstract class Foo implements Bar {

  public void run() {
    System.out.println( barMethod() );
  }
}

so, I would like to have various mixins which can provide the Bar implementation, and only choose one of them to be actually merged in.

I was trying to adopt the approach of writing them in the following way:

public privileged aspect BarAspect_First {
public String Foo.barMethod() {
           return "First";
        }
}


public privileged aspect BarAspect_Second{
public String Foo.barMethod() {
           return "Second";
        }
}

but clearly Eclipse/AJDT complains about conflict inter-type declarations.

So going back to my question, how do I declare the mixins and them be able to specify which one to actually be used? 

Thanks in advance for any suggestion.
Regards,
Alessio Pace.

Back to the top