gpt4 book ai didi

java - 覆盖 AspectJ 中的方法参数

转载 作者:行者123 更新时间:2023-11-30 07:10:38 24 4
gpt4 key购买 nike

我有一个方面拦截日志记录方法。该日志记录方法是一种以一个对象作为参数的简单方法:

logMessage(Object message)

如何在我的方面修改该对象并记录一个新对象?以下不起作用:

void around() : execution(* com.test.logMessage(..)) {
String message = thisJoinPoint.getArgs()[0].toString();
String pattern = "abc";
String replacement = "xyz";

message = message.replaceAll(pattern, replacement);
proceed(message);
}

我收到ajc:太多参数无法继续,预计 0 错误。

最佳答案

proceed 方法采用对象数组作为参数。您应该能够通过这样的调用来解决您的问题:

Object[] args = new Object[] { message };
proceed(args);

关于java - 覆盖 AspectJ 中的方法参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39289736/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com