2007-01-09 20:58:05 +01:00
|
|
|
import java.lang.reflect.Proxy;
|
|
|
|
import java.lang.reflect.InvocationHandler;
|
|
|
|
import java.lang.reflect.Method;
|
2002-09-30 07:19:09 +02:00
|
|
|
import java.net.*;
|
|
|
|
|
|
|
|
public class TestProxy
|
|
|
|
{
|
2005-10-10 21:18:26 +02:00
|
|
|
public static class MyInvocationHandler implements InvocationHandler
|
2002-09-30 07:19:09 +02:00
|
|
|
{
|
|
|
|
public Object invoke (Object proxy,
|
|
|
|
Method method,
|
|
|
|
Object[] args)
|
|
|
|
throws Throwable
|
|
|
|
{
|
|
|
|
System.out.println (args[0]);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void main (String[] args)
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
InvocationHandler ih = new MyInvocationHandler();
|
|
|
|
|
|
|
|
SocketOptions c = (SocketOptions)
|
|
|
|
Proxy.newProxyInstance (SocketOptions.class.getClassLoader(),
|
|
|
|
new Class[]{SocketOptions.class},
|
|
|
|
ih);
|
|
|
|
|
|
|
|
c.getOption (555);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|