/** Wrap the given service call with the {@link RequestCounter} * to count the number of calls made. * @param r the {@link Runnable} to attempt * * @throws Exception if <code>c</code> throws one during * execution */ public void invoke(Runnable r) throws Exception { try { r.run(); succeed(); } catch (Exception e) { fail(); throw e; } }
/** Wrap the given service call with the {@link RequestCounter} * to count the number of calls made. * @param c the {@link Callable} to attempt * * @return whatever c would return on success * * @throws Exception if <code>c</code> throws one during * execution */ public <T> T invoke(Callable<T> c) throws Exception { try { T result = c.call(); succeed(); return result; } catch (Exception e) { fail(); throw e; } }
/** Wrap the given service call with the {@link RequestCounter} * to count the number of calls made. * @param r the {@link Runnable} to attempt * @param result what to return after <code>r</code> succeeds * * @return result * * @throws Exception if <code>c</code> throws one during * execution */ public <T> T invoke(Runnable r, T result) throws Exception { try { r.run(); succeed(); return result; } catch (Exception e) { fail(); throw e; } }