/** * 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; }
instantiationGuard.setGuardedContainer(container); instantiationGuard.observe(getComponentImplementation(), null); } finally { if (i_Instantiated) { instantiationGuard.remove(); instantiationGuard = null;
instantiationGuard.setGuardedContainer(container); inst = instantiationGuard.observe(getComponentImplementation(), null); decorate(inst, container); } finally { if (i_Instantiated) { instantiationGuard.remove(); instantiationGuard = null;
instantiationGuard.setGuardedContainer(container); result = (T) instantiationGuard.observe(getComponentImplementation(), null); } finally { if (i_Instantiated) { instantiationGuard.remove(); instantiationGuard = null;
instantiationGuard.setGuardedContainer(container); result = (T) instantiationGuard.observe(getComponentImplementation(), null); } finally { if (i_Instantiated) { instantiationGuard.remove(); instantiationGuard = null;
instantiationGuard.setGuardedContainer(container); inst = instantiationGuard.observe(getComponentImplementation(), null); decorate(inst, container); } finally { if (i_Instantiated) { instantiationGuard.remove(); instantiationGuard = null;
instantiationGuard.setGuardedContainer(container); o = instantiationGuard.observe(getComponentImplementation(), instance); } finally { if (iInstantiated) { instantiationGuard.remove(); instantiationGuard = null;
instantiationGuard.setGuardedContainer(container); o = instantiationGuard.observe(getComponentImplementation(), instance); } finally { if (iInstantiated) { instantiationGuard.remove(); instantiationGuard = null;
verifyingGuard.setGuardedContainer(container); verifyingGuard.observe(getComponentImplementation(), null); } finally { if (i_created) { verifyingGuard.remove(); verifyingGuard = null;
verifyingGuard.setGuardedContainer(container); verifyingGuard.observe(getComponentImplementation(), null); } finally { if (i_created) { verifyingGuard.remove(); verifyingGuard = null;
verifyingGuard.setGuardedContainer(container); verifyingGuard.observe(getComponentImplementation(), null); verifyingGuard.remove(); verifyingGuard = null;
public void injectStatics(final PicoContainer container, final Type into, final StaticsInitializedReferenceSet initializedReferenceSet) { this.initializedReferenceSet = initializedReferenceSet; if (!isStaticInjection) { throw new PicoCompositionException(Arrays.deepToString(fieldsToInject) + " are non static fields, injectStatics should not be called."); } boolean iInstantiated = false; try { if (instantiationGuard == null) { iInstantiated = true; instantiationGuard = new ThreadLocalCyclicDependencyGuard<T>() { @Override public T run(final Object instance) { final ParameterToAccessibleObjectPair[] matchingParameters = getMatchingParameterListForMembers(guardedContainer); //Funky call where the instance we're decorating //happens to be null for static injection. return decorateComponentInstance(matchingParameters, currentMonitor(), null, container, guardedContainer, into, null); } }; } instantiationGuard.setGuardedContainer(container); instantiationGuard.observe(getComponentImplementation(), null); } finally { if (iInstantiated) { instantiationGuard.remove(); instantiationGuard = null; } this.initializedReferenceSet = null; } }
public void injectStatics(final PicoContainer container, final Type into, final StaticsInitializedReferenceSet initializedReferenceSet) { this.initializedReferenceSet = initializedReferenceSet; if (!isStaticInjection) { throw new PicoCompositionException(Arrays.deepToString(fieldsToInject) + " are non static fields, injectStatics should not be called."); } boolean iInstantiated = false; try { if (instantiationGuard == null) { iInstantiated = true; instantiationGuard = new ThreadLocalCyclicDependencyGuard<T>() { @Override public T run(final Object instance) { final ParameterToAccessibleObjectPair[] matchingParameters = getMatchingParameterListForMembers(guardedContainer); //Funky call where the instance we're decorating //happens to be null for static injection. return decorateComponentInstance(matchingParameters, currentMonitor(), null, container, guardedContainer, into, null); } }; } instantiationGuard.setGuardedContainer(container); instantiationGuard.observe(getComponentImplementation(), null); } finally { if (iInstantiated) { instantiationGuard.remove(); instantiationGuard = null; } this.initializedReferenceSet = null; } }
instantiationGuard.setGuardedContainer(container); instantiationGuard.observe(getComponentImplementation(), null); } finally { if (i_Instantiated) { instantiationGuard.remove(); instantiationGuard = null;
@Override @SuppressWarnings("unchecked") public void verify(final PicoContainer container) throws PicoCompositionException { boolean i_Instantiated = false; try { if (verifyingGuard == null) { i_Instantiated = true; verifyingGuard = new ThreadLocalCyclicDependencyGuard<T>() { @Override public T run(final Object inst) { final ParameterToAccessibleObjectPair[] currentParameters = getMatchingParameterListForMembers(guardedContainer); for (int i = 0; i < currentParameters.length; i++) { currentParameters[i].getAccessibleObjectParameters().getParams()[0].verify(container, IterativeInjector.this, injectionTypes[i], makeParameterNameImpl(currentParameters[i].getAccessibleObject()), useNames(), bindings[i]); } return null; } }; } verifyingGuard.setGuardedContainer(container); verifyingGuard.observe(getComponentImplementation(), null); } finally { if (i_Instantiated) { verifyingGuard.remove(); verifyingGuard = null; } } }
@Override public T getComponentInstance(final PicoContainer container, final Type into) throws PicoCompositionException { final Constructor<?> constructor = getConstructor(); boolean iInstantiated = false; T result; try { if (instantiationGuard == null) { iInstantiated = true; instantiationGuard = new ThreadLocalCyclicDependencyGuard<T>() { @Override public T run(final Object instance) { final ParameterToAccessibleObjectPair[] matchingParameters = getMatchingParameterListForMembers(guardedContainer); Object componentInstance = makeInstance(container, constructor, currentMonitor()); return decorateComponentInstance(matchingParameters, currentMonitor(), componentInstance, container, guardedContainer, into, null); } }; } instantiationGuard.setGuardedContainer(container); result = instantiationGuard.observe(getComponentImplementation(), null); } finally { if (iInstantiated) { instantiationGuard.remove(); instantiationGuard = null; } } return result; }
verifyingGuard.setGuardedContainer(container); verifyingGuard.observe(getComponentImplementation(), null); verifyingGuard.remove(); verifyingGuard = null;
@Override public T getComponentInstance(final PicoContainer container, final Type into) throws PicoCompositionException { final Constructor<?> constructor = getConstructor(); boolean iInstantiated = false; T result; try { if (instantiationGuard == null) { iInstantiated = true; instantiationGuard = new ThreadLocalCyclicDependencyGuard<T>() { @Override public T run(final Object instance) { final ParameterToAccessibleObjectPair[] matchingParameters = getMatchingParameterListForMembers(guardedContainer); Object componentInstance = makeInstance(container, constructor, currentMonitor()); return decorateComponentInstance(matchingParameters, currentMonitor(), componentInstance, container, guardedContainer, into, null); } }; } instantiationGuard.setGuardedContainer(container); result = instantiationGuard.observe(getComponentImplementation(), null); } finally { if (iInstantiated) { instantiationGuard.remove(); instantiationGuard = null; } } return result; }
@Override @SuppressWarnings("unchecked") public void verify(final PicoContainer container) throws PicoCompositionException { boolean i_Instantiated = false; try { if (verifyingGuard == null) { i_Instantiated = true; verifyingGuard = new ThreadLocalCyclicDependencyGuard<T>() { @Override public T run(final Object inst) { final ParameterToAccessibleObjectPair[] currentParameters = getMatchingParameterListForMembers(guardedContainer); for (int i = 0; i < currentParameters.length; i++) { currentParameters[i].getAccessibleObjectParameters().getParams()[0].verify(container, IterativeInjector.this, injectionTypes[i], makeParameterNameImpl(currentParameters[i].getAccessibleObject()), useNames(), bindings[i]); } return null; } }; } verifyingGuard.setGuardedContainer(container); verifyingGuard.observe(getComponentImplementation(), null); } finally { if (i_Instantiated) { verifyingGuard.remove(); verifyingGuard = null; } } }
@Override public Object partiallyDecorateComponentInstance(final PicoContainer container, final Type into, final T instance, final Class<?> superclassPortion) { boolean iInstantiated = false; T result; try { if (instantiationGuard == null) { iInstantiated = true; instantiationGuard = new ThreadLocalCyclicDependencyGuard<T>() { @Override public T run(final Object inst) { final ParameterToAccessibleObjectPair[] matchingParameters = getMatchingParameterListForMembers(guardedContainer); return decorateComponentInstance(matchingParameters, currentMonitor(), inst, container, guardedContainer, into, superclassPortion); } }; } instantiationGuard.setGuardedContainer(container); result = instantiationGuard.observe(getComponentImplementation(), instance); } finally { if (iInstantiated) { instantiationGuard.remove(); instantiationGuard = null; } } return result; }