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

Hi Martin,

I'm not sure whether you want to bind the value of an Order argument, or
just to match method execution join points at least one argument must be an
order. In addition to Wes's suggestion of enumerating pointcuts to match
each position, you could use this pointcut to match the join points:

  pointcut orderReceiver() : execution(* *(.., Order, ..));

Then in your advice you could loop over thisJoinPoint.getArgs() to find any
order objects that were parameters, as an alternative to binding the value
with args.

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Martin Börlin
Sent: Monday, September 18, 2006 3:58 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [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
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users