1
從標註的方法獲取局部變量值
我用java 定製標註使用AspectJ在AspectJ
定製標註
@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";
}
}
ASPECT
@Around(value="pcSample(tl)", argNames="tl")
public Object runMethod(ProceedingJoinPoint pjp, TrxLogger tl) throws Throwable {
return null;
}
是有可能得到的方面sayHello()方法的局部變量值(String localVariable="Before System.out.println";
)?
pjp.proceed()之後我們能找不到嗎? –