hikeintroduction.java
来自「这个是j2eejava web 编程精要十五讲的全部源码。对学习java web」· Java 代码 · 共 32 行
JAVA
32 行
package test;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.IntroductionInterceptor;
public class HikeIntroduction
implements IntroductionInterceptor, IHiker {
// 是否实作自IHiker接口
public boolean implementsInterface(Class clazz) {
return clazz.isAssignableFrom(IHiker.class);
}
public Object invoke(MethodInvocation methodInvocation)
throws Throwable {
// 如果呼叫的方法来自IHiker接口的定义
if(implementsInterface(
methodInvocation.getMethod().getDeclaringClass())) {
// 呼叫执行额外加入的行为
return methodInvocation.getMethod().
invoke(this, methodInvocation.getArguments());
}
else {
return methodInvocation.proceed();
}
}
public void doHiking() {
System.out.println("还要到郊外远足。。。");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?