@Test public void testCreateProxyWithRetryMechanism2() { TempClassForTest target = new TempClassForTest(); target.c = "test"; TempClassForTest proxyTarget = ProxyUtil.createMongoDaoProxyWithRetryMechanism(target, 1000); try { proxyTarget.getB(); Assert.fail(); } catch (RuntimeException e) { } }
@SuppressWarnings("unchecked") public static <T> T createMongoDaoProxyWithRetryMechanism(T targetClass, long retryIntervalWhenException) { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(targetClass.getClass()); enhancer.setCallback(new RetryMethodInterceptor(targetClass, retryIntervalWhenException, MongoException.class)); return (T) enhancer.create(); }
ProxyUtil { @SuppressWarnings("unchecked") public static <T> T createMongoDaoProxyWithRetryMechanism(T targetClass, long retryIntervalWhenException) { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(targetClass.getClass()); enhancer.setCallback(new RetryMethodInterceptor(targetClass, retryIntervalWhenException, MongoException.class)); return (T) enhancer.create(); } }
ProxyUtil { @SuppressWarnings("unchecked") public static <T> T createMongoDaoProxyWithRetryMechanism(T targetClass, long retryIntervalWhenException) { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(targetClass.getClass()); enhancer.setCallback(new RetryMethodInterceptor(targetClass, retryIntervalWhenException, MongoException.class)); return (T) enhancer.create(); } private  ProxyUtil(); }
ProxyUtil { @SuppressWarnings("unchecked") public static <T> T createMongoDaoProxyWithRetryMechanism(T targetClass, long retryIntervalWhenException) { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(targetClass.getClass()); enhancer.setCallback(new RetryMethodInterceptor(targetClass, retryIntervalWhenException, MongoException.class)); return (T) enhancer.create(); } private  ProxyUtil(); @SuppressWarnings("unchecked") static T createMongoDaoProxyWithRetryMechanism(T targetClass, long retryIntervalWhenException); }
ProxyUtil { @SuppressWarnings("unchecked") public static <T> T createMongoDaoProxyWithRetryMechanism(T targetClass, long retryIntervalWhenException) { Enhancer enhancer = new Enhancer(); enhancer.setSuperclass(targetClass.getClass()); enhancer.setCallback(new RetryMethodInterceptor(targetClass, retryIntervalWhenException, MongoException.class)); return (T) enhancer.create(); } private  ProxyUtil(); @SuppressWarnings("unchecked") static T createMongoDaoProxyWithRetryMechanism(T targetClass, long retryIntervalWhenException);  }