【发布时间】:2018-12-14 15:27:02
【问题描述】:
我有一个可用于注释的方面:
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface DumpToFile {
}
还有连接点:
@Aspect
@Component
public class DumpToFileAspect {
@Around("@annotation(DumpToFile)")
public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
...
// I likte to read out a parameter from the annotation...
Object proceed = joinPoint.proceed();
...
return proceed;
}
}
我可以在@DumpToFile 的方法上成功使用方面;但是,我想将参数传递给注释并在我的方面检索它的值。
例如。 @DumpToFile(fileName="mydump")。谁能告诉我怎么做?
【问题讨论】:
标签: java spring annotations aop aspectj