Skip to main content

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


Jan,

It works for me in AJDT 1.4.1 in Eclipse 3.2. How are you building your code?

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/



Jan <jan@xxxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

28/11/2006 13:08

Please respond to
aspectj-users@xxxxxxxxxxx

To
aspectj-users@xxxxxxxxxxx
cc
Subject
[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


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top