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

Hi Jan,

How about 
execution(* IFooService+.*(..))

Note the extra '+'.  This should match the IFooService interface and any
classes that implement it.

As it was you were only matching methods within the IFooService
interface.

HTH,

Fintan

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Jan
Sent: 28 November 2006 13:08
To: aspectj-users@xxxxxxxxxxx
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


* ** *** ** * ** *** ** * ** *** ** * 
This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they 
are addressed. 
Any views or opinions presented are solely those of the author, and do not necessarily  represent those of ESB. 
If you have received this email in error please notify the sender. 
 
Although ESB scans e-mail and attachments for viruses, it does not guarantee 
that either are virus-free and accepts no liability for any damage sustained 
as a result of viruses. 
 
* ** *** ** * ** *** ** * ** *** ** *



Back to the top