package proxytest; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public class TokenInvocationHandler implements InvocationHandler { private Object _instance; /** * * @param anInstance is the object you get from serialization */ public TokenInvocationHandler(Object anInstance) { _instance = anInstance; } public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { try { Method meth = _instance.getClass().getMethod(method.getName(), method.getParameterTypes()); if (null != meth) { return meth.invoke(_instance, args); } else { throw new UnsupportedOperationException(method.getName() + " not found in the serialized Token"); } } catch (InvocationTargetException e) { throw e; } catch (Exception e) { // TODO traitement des exceptions propre au proxy.. e.printStackTrace(); } return null; } }