-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.java
30 lines (20 loc) · 1.15 KB
/
Test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package proxy;
import java.lang.reflect.Proxy;
import java.util.stream.Stream;
public class Test {
public static void main(String[] args){
ForumService target = new ForumServiceImpl();
PerformanceHandle handle = new PerformanceHandle(target);
ForumService proxy = (ForumService)Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), handle);
proxy.removeForum(12);
proxy.removeTopic(21);
System.out.println(proxy.getClass().getName());
System.out.println("--------------------------------------------------------------------------");
Stream.of(proxy.getClass().getMethods()).forEach(System.out::println);
System.out.println("--------------------------------------------------------------------------");
System.out.println(((PerformanceHandle)Proxy.getInvocationHandler(proxy)).getTarget().getClass().getName());
System.out.println("--------------------------------------------------------------------------");
System.out.println(((ForumServiceImpl)((PerformanceHandle)Proxy.getInvocationHandler(proxy)).getTarget()).test());
System.out.println(target);
}
}