001    package biz.hammurapi.remoting;
002    
003    import java.lang.reflect.InvocationHandler;
004    import java.lang.reflect.Method;
005    import java.lang.reflect.Proxy;
006    
007    public interface Remoter {
008    
009            Object invoke(Invocation invocation) throws Exception;
010            
011            class ProxyFactory {
012                    
013                    public static Object createProxy(Class[] interfaces, final LocalDelegate localDelegate, final Remoter remoter) {
014                            InvocationHandler ih = new InvocationHandler() {
015    
016                                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
017                                            return localDelegate.invoke(proxy, method, args, remoter);
018                                    }
019                                    
020                            };
021                            return Proxy.newProxyInstance(ProxyFactory.class.getClassLoader(), interfaces, ih);                     
022                    }
023            }
024    }