/** * Call the observing function. The provided guard will hold the {@link Boolean} value. * If the guard is already <code>Boolean.TRUE</code> a {@link CyclicDependencyException} * will be thrown. * * @param stackFrame the current stack frame * @return the result of the <code>run</code> method */ public final T observe(final Class<?> stackFrame, final Object instance) { if (Boolean.TRUE.equals(get())) { throw new CyclicDependencyException(stackFrame); } T result = null; try { set(Boolean.TRUE); result = run(instance); } catch (final CyclicDependencyException e) { e.push(stackFrame); throw e; } finally { set(Boolean.FALSE); } return result; }
/** * Call the observing function. The provided guard will hold the {@link Boolean} value. * If the guard is already <code>Boolean.TRUE</code> a {@link CyclicDependencyException} * will be thrown. * * @param stackFrame the current stack frame * @return the result of the <code>run</code> method */ public final T observe(final Class<?> stackFrame, final Object instance) { if (Boolean.TRUE.equals(get())) { throw new CyclicDependencyException(stackFrame); } T result = null; try { set(Boolean.TRUE); result = run(instance); } catch (final CyclicDependencyException e) { e.push(stackFrame); throw e; } finally { set(Boolean.FALSE); } return result; }