Rom*_*man 3 java language-features proxy-classes
我有很多的记录,类似的方法logSomeAction,logAnotherAction等等.
现在我希望所有这些方法在打印消息(Thread.sleep)后暂停一小段时间.
如果我手动完成,我会做这样的事情:
//before:
public static void logSomeAction () {
System.out.println (msg(SOME_ACTION));
}
//after:
public static void logSomeAction () {
System.out.println (msg(SOME_ACTION));
try {
Thread.sleep (2000);
} catch (InterruptedException ignored) { }
}
Run Code Online (Sandbox Code Playgroud)
我记得Java有代理类和其他一些魔术制作工具.有没有办法避免将N个睡眠块复制粘贴到N个记录方法?
| 归档时间: |
|
| 查看次数: |
113 次 |
| 最近记录: |