Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Pointcut expression for matching generic interface

Dear AspectJ users,

Considering the following interface:

public interface IFooService<T extends Foo>
{
 public T create();
 public void save (T foo);
}

with object classes:

class Foo {}
class Bar extends Foo {}

and factory implementation

public class BarService implements IFooService<Bar>
{
 public Bar create() { return new Bar(); }
 public void save (Bar bar)
 {
   // save the object
 }
}

How would one formulate a pointcut expression matching "any method on implementations of IFooService"?

I tried the following:
execution(* IFooService.*(..))

but that would only match the create() function, not the save() function!!! I suspect this is due to the type erasure that comes into play when using generics; IFooService will contain a save(Foo) method, while BarService implements a save(Bar) method....these don't match exactly.

Still, I'd like to formulate "any implementation of IFooService, with any generic type".... ideas?

Regards
Jan Ypma




Back to the top