📄 aopmain.java
字号:
package test.aop;
import java.lang.reflect.*;
import test.aop.frame.ProxyFactory;
public class AopMain {
public static void main(String[] args) {
Hello hello = new HelloAOP();
//使用封装的代理类对象,来是将AOP,是startMethod ,endMethod被封装到数据戴劳力类中
HelloAOPImpl handle = new HelloAOPImpl(hello);
Hello test2 = (Hello) handle.getProxy();
System.out.println(hello.say("Old"));
System.out.println("The Result String is: "+test2.say("John"));
//使用代理类获取接口对象
Hello s = (Hello)Proxy.newProxyInstance(hello.getClass().getClassLoader(), new Class[]{Hello.class}, handle);
System.out.println(s.say("Tome"));
System.out.println("------- AOP Factory -------------");
ProxyFactory fac = ProxyFactory.createFactory();
Hello test = (Hello)fac.proxyDefaultConvert(new HelloAOP());
System.out.println(test.say("Factory!"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -