【发布时间】:2011-12-10 18:56:39
【问题描述】:
我正在使用 spring aspectj 创建一个方面类,如下所示
@Aspect
public class AspectDemo {
@Pointcut("execution(* abc.execute(..))")
public void executeMethods() { }
@Around("executeMethods()")
public Object profile(ProceedingJoinPoint pjp) throws Throwable {
System.out.println("Going to call the method.");
Object output = pjp.proceed();
System.out.println("Method execution completed.");
return output;
}
}
现在我想访问 abc 类的属性名称,那么如何在方面类中访问它? 我想在 profile 方法中显示 abc 类的 name 属性
我的 abc 类如下
public class abc{
String name;
public void setName(String n){
name=n;
}
public String getName(){
return name;
}
public void execute(){
System.out.println("i am executing");
}
}
如何访问方面类中的名称?
【问题讨论】:
标签: java spring jakarta-ee aspectj spring-aop