@Test public void newJdkProxy() throws Exception { WikipediaServiceJapiMock target = new WikipediaServiceJapiMock(); WikipediaServiceJapi wikipediaServiceJapi = DelayProxy.newJdkProxy(target, DelayFunction.staticDelay(1000)); String article = wikipediaServiceJapi.getArticle("42"); assertThat(article, startsWith("{{Dieser Artikel|behandelt das Jahr 42")); assertThat(wikipediaServiceJapi, not(instanceOf(target.getClass()))); }
public static <T> T newJdkProxy(Object obj, DelayFunction delayFunction) { Class<?> clazz = obj.getClass(); List<Class<?>> interfaces = ClassUtils.getAllInterfaces(clazz); return (T) java.lang.reflect.Proxy.newProxyInstance( clazz.getClassLoader(), interfaces.toArray(new Class[interfaces.size()]), new DelayProxy(obj, delayFunction)); }
DelayProxy extends DefaultProxyBehavior { public static <T> T newJdkProxy(Object obj, DelayFunction delayFunction) { Class<?> clazz = obj.getClass(); List<Class<?>> interfaces = ClassUtils.getAllInterfaces(clazz); return (T) java.lang.reflect.Proxy.newProxyInstance( clazz.getClassLoader(), interfaces.toArray(new Class[interfaces.size()]), new DelayProxy(obj, delayFunction)); } }
DelayProxy extends DefaultProxyBehavior { public static <T> T newJdkProxy(Object obj, DelayFunction delayFunction) { Class<?> clazz = obj.getClass(); List<Class<?>> interfaces = ClassUtils.getAllInterfaces(clazz); return (T) java.lang.reflect.Proxy.newProxyInstance( clazz.getClassLoader(), interfaces.toArray(new Class[interfaces.size()]), new DelayProxy(obj, delayFunction)); } private  DelayProxy(Object obj, DelayFunction delayFunction); }
DelayProxy extends DefaultProxyBehavior { public static <T> T newJdkProxy(Object obj, DelayFunction delayFunction) { Class<?> clazz = obj.getClass(); List<Class<?>> interfaces = ClassUtils.getAllInterfaces(clazz); return (T) java.lang.reflect.Proxy.newProxyInstance( clazz.getClassLoader(), interfaces.toArray(new Class[interfaces.size()]), new DelayProxy(obj, delayFunction)); } private  DelayProxy(Object obj, DelayFunction delayFunction); static T newJdkProxy(Object obj, DelayFunction delayFunction); }
DelayProxy extends DefaultProxyBehavior { public static <T> T newJdkProxy(Object obj, DelayFunction delayFunction) { Class<?> clazz = obj.getClass(); List<Class<?>> interfaces = ClassUtils.getAllInterfaces(clazz); return (T) java.lang.reflect.Proxy.newProxyInstance( clazz.getClassLoader(), interfaces.toArray(new Class[interfaces.size()]), new DelayProxy(obj, delayFunction)); } private  DelayProxy(Object obj, DelayFunction delayFunction); static T newJdkProxy(Object obj, DelayFunction delayFunction);  }