-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameProxy.java
More file actions
28 lines (22 loc) · 844 Bytes
/
GameProxy.java
File metadata and controls
28 lines (22 loc) · 844 Bytes
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
package design.proxy;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class GameProxy implements InvocationHandler {
Object obj;
public GameProxy(Object obj){
this.obj=obj;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object value= method.invoke(obj,args);
return value;
}
public static void main(String[] args) throws Exception {
// IGamePlayer gamePlayer=new GamePlayer("zhang");
// GameProxy gameProxy=new GameProxy(gamePlayer);
// IGamePlayer proxy= (IGamePlayer) Proxy.newProxyInstance(gamePlayer.getClass().getClassLoader(),gamePlayer.getClass().getInterfaces(),
// gameProxy);
// proxy.login("zhang","111");
}
}