我正在使用带有 aspectJ 的java自定义注释
自定义注释
@Documented
@Target(ElementType.METHOD)
@Inherited
@Retention(RetentionPolicy.RUNTIME)
public @interface TrxLogger {
String author() default "Shahid Ghafoor";
String comments() default "I am Fan of JAVA";
}
服务
public class Service {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@TrxLogger
public String sayHello(String fn, String ln) {
this.name=fn;
String localVariable="Before System.out.println";
System.out.println("Welcome!" + fn + " " + ln);
return "The Transaction return Value";
}
}
方面
@Around(value="pcSample(tl)", argNames="tl")
public Object runMethod(ProceedingJoinPoint pjp, TrxLogger tl) throws Throwable {
return null;
}
是否可以在String localVariable="Before System.out.println";
方面获取 sayHello() 方法的局部变量 value()?