简体   繁体   中英

How to target aspect to method with argument of certain type?

If I write my aspect

@Before("args(data)")
public void beforeMethod( MyParam data ) {
    // ...
}

it will handle on method

public void m1(MyParam param){};

If I write aspect as

@Before("args(data,..)")
public void beforeMethod( MyParam data ) {
    // ...
}

it will handle on method

public void m2(MyParam param, OtherParam param2, Object smthElse){};

But MyParam param should be first.

The question is: how to configurate @Before("args(?)") to match methods where MyParam param will be not first parameter like here?

@Before("args(?)")
public void m3(OtherParam param2, MyParam param, Object smthElse){};

无法测试,但这可能是这样做的一种方法-

args(*, param, ..) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM