@SuppressWarnings("unchecked") public <I> I createRmiInstance(Class<I> type) { CallSiteBuilder classSite = baseSite.createChild(false); classSite.decorateFromClass(type); log.trace("Class call site for {} is {}", classSite, classSite); Map<Method, CallSiteBuilder> sites = new HashMap<>(); for (Method method : type.getMethods()) { if (method.getDeclaringClass() == Object.class || Modifier.isStatic(method.getModifiers())) { continue; } CallSiteBuilder methodSite = classSite.createChild(false); methodSite.decorateFromMethod(binder, method); log.trace("Method call site for {} is {}", method, methodSite); sites.put(method, methodSite); } InvocationHandler invocationHandler = (proxy, method, args) -> { CallSiteBuilder site = sites.get(method); if (site == null) { // todo: Object methods assert false; } site = site.createChild(true); site.decorateFromCall(args); return site.submit(executor); }; return (I) Proxy.newProxyInstance( RmiFactory.class.getClassLoader(), new Class[] {type}, invocationHandler); }
public void addValidator(ResponseValidator validator) { baseSite.addValidator(validator); }