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; } }