[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] pointcut to match a specific object in argument

All!

How do I create a pointcut that matches the joinpoint where a method 
is executed and has (at least) one specific argument, regardless of 
other arguments (their number and place) in the method. I.e. I want a 
pointcut that matches the execution of all methods with one argument 
Order. See some example methods at the end of this email.

My futile atemts to write this pointcut looks like this:

//seems to only match methods where the Order object argument is last, 
example 3), 4) and 5) 
  pointcut trackOrder(Order order) :
    execution(* *(.., Order, ..))
    && (args(.., order));

//seems to only match methods where the Order object argument is 
first, example 1), 4) and 5) 
  pointcut trackOrder(Order order) :
    execution(* *(.., Order, ..))
    && (args(order, ..));
    
//"Could" work but generates the error: "2	uses more than one .. in 
args (compiler limitation)"
  pointcut trackOrder(Order order) :
    execution(* *(.., Order, ..))
    && (args(.., order, ..));
    

1) public void m1(Order myOrder, String s1, String s2)

2) public String m2(String s1,  Order myOrder, int i1)

3) public boolean myMethod(int i1, String s1, Order myOrder)

4) public Order getOrderId(Order order)

5) public int compare(Order o1, Order o2) 


Regards Martin Börlin