我想创建一个 Inter-Type 声明,在每个类中声明一个(静态最终)Logger 实例。
构造函数应该传递封闭类Klazz.class
值:
@Aspect
public class LoggerAspect {
public interface Logger {
}
public static class LoggerImpl implements Logger {
private static final Logger logger =
new Logger(thisJoinPoint.getTarget().getClass()/*.getName()*/);
}
@DeclareParents(value="com.my.api..*",defaultImpl=LoggerImpl.class)
private Logger implementedInterface;
}
我编写了上述解决方案,但是我无法在thisJoinPoint
AspectJ 之外使用advice
。
如果将 Logger 默认实现应用于某些类 Klazz,如何修改上述代码以成功将 Klazz.class 传递给 Logger 构造函数?