📄 lockintroduction.java
字号:
package onlyfun.caterpillar;
import org.springframework.aop.
support.DelegatingIntroductionInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.
framework.AopConfigException;
public class LockIntroduction
extends DelegatingIntroductionInterceptor
implements ILockable {
private boolean locked;
public Object invoke(MethodInvocation invocation)
throws Throwable {
// locked为true下不能调用set方法
if (isLocked() &&
invocation.getMethod().
getName().indexOf("set") == 0) {
throw new AopConfigException(
"对象被锁定!!");
}
return super.invoke(invocation);
}
public void lock() {
locked = true;
}
public void unlock() {
locked = false;
}
public boolean isLocked() {
return locked;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -