@Override public T get(InternalContext context, Dependency<?> dependency, boolean linked) throws InternalProvisionException { // TODO(lukes): add a source to the thrown exception? return delegate.getInternalFactory().get(context, dependency, linked); } }
SingleParameterInjector(Dependency<T> dependency, BindingImpl<? extends T> binding) { this.dependency = dependency; this.source = binding.getSource(); this.factory = binding.getInternalFactory(); }
<T> InternalFactory<? extends T> getInternalFactory( Key<T> key, Errors errors, JitLimitation jitType) throws ErrorsException { return getBindingOrThrow(key, errors, jitType).getInternalFactory(); }
@Override void doInitialize() { if (bindingSelection.getBinding() != null) { target = bindingSelection.getBinding().getInternalFactory(); targetDependency = bindingSelection.getDependency(); } }
@Override void doInitialize() { if (bindingSelection.getBinding() != null) { delegate = bindingSelection.getBinding().getInternalFactory(); targetDependency = bindingSelection.getDependency(); } }
@Override void doInitialize() { BindingImpl<T> targetBinding = bindingSelection.getBinding(); // we only install this factory if they call setBinding()/setDefault() so we know that // targetBinding will be non-null. this.targetKey = targetBinding.getKey(); this.targetSource = targetBinding.getSource(); this.targetFactory = targetBinding.getInternalFactory(); }
@Override public void inject(InternalContext context, Object o) throws InternalProvisionException { Dependency previous = context.pushDependency(dependency, binding.getSource()); try { Object value = binding.getInternalFactory().get(context, dependency, false); field.set(o, value); } catch (InternalProvisionException e) { throw e.addSource(dependency); } catch (IllegalAccessException e) { throw new AssertionError(e); // a security manager is blocking us, we're hosed } finally { context.popStateAndSetDependency(previous); } } }
<T> Provider<T> getProviderOrThrow(final Dependency<T> dependency, Errors errors) throws ErrorsException { Key<T> key = dependency.getKey(); BindingImpl<? extends T> binding = getBindingOrThrow(key, errors, JitLimitation.NO_JIT); final InternalFactory<? extends T> internalFactory = binding.getInternalFactory(); final Object source = binding.getSource(); return new Provider<T>() { @Override public T get() { InternalContext currentContext = enterContext(); Dependency previous = currentContext.pushDependency(dependency, source); try { T t = internalFactory.get(currentContext, dependency, false); return t; } catch (InternalProvisionException e) { throw e.addSource(dependency).toProvisionException(); } finally { currentContext.popStateAndSetDependency(previous); currentContext.close(); } } @Override public String toString() { return internalFactory.toString(); } }; }
@Override public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }
@Override public T get(InternalContext context, Dependency<?> dependency, boolean linked) throws InternalProvisionException { BindingImpl<? extends Provider<T>> localProviderBinding = providerBinding; if (localProviderBinding == null) { throw new IllegalStateException("not initialized"); } Key<? extends Provider<T>> localProviderKey = providerKey; context.pushState(localProviderKey, localProviderBinding.getSource()); try { Provider<? extends T> provider = localProviderBinding.getInternalFactory().get(context, dependency, true); return circularGet(provider, context, dependency, provisionCallback); } catch (InternalProvisionException ipe) { throw ipe.addSource(localProviderKey); } finally { context.popState(); } }
binding.getInternalFactory().get(context, dependency, false); } catch (InternalProvisionException e) { errors.withSource(dependency).merge(e);
@Override public String toString() { return binding.getInternalFactory().toString(); } };
public T get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) throws ErrorsException { return delegate.getInternalFactory().get(errors, context, dependency, linked); } }
@Override public T get(InternalContext context, Dependency<?> dependency, boolean linked) throws InternalProvisionException { // TODO(lukes): add a source to the thrown exception? return delegate.getInternalFactory().get(context, dependency, linked); } }
public T get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) throws ErrorsException { return delegate.getInternalFactory().get(errors, context, dependency, linked); } }
public T get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) throws ErrorsException { return targetBinding.getInternalFactory().get( errors.withSource(targetKey), context, dependency, true); } };
@Override void doInitialize() { BindingImpl<T> targetBinding = bindingSelection.getBinding(); // we only install this factory if they call setBinding()/setDefault() so we know that // targetBinding will be non-null. this.targetKey = targetBinding.getKey(); this.targetSource = targetBinding.getSource(); this.targetFactory = targetBinding.getInternalFactory(); }
@Override void doInitialize() { BindingImpl<T> targetBinding = bindingSelection.getBinding(); // we only install this factory if they call setBinding()/setDefault() so we know that // targetBinding will be non-null. this.targetKey = targetBinding.getKey(); this.targetSource = targetBinding.getSource(); this.targetFactory = targetBinding.getInternalFactory(); }
@Override void doInitialize() { if (bindingSelection.getBinding() != null) { target = bindingSelection.getBinding().getInternalFactory(); targetDependency = bindingSelection.getDependency(); } }
public void notify(Errors errors) { InjectorImpl privateInjector = (InjectorImpl) privateElements.getInjector(); BindingImpl<T> explicitBinding = privateInjector.state.getExplicitBinding(key); // validate that the child injector has its own factory. If the getInternalFactory() returns // this, then that child injector doesn't have a factory (and getExplicitBinding has returned // its parent's binding instead if (explicitBinding.getInternalFactory() == this) { errors.withSource(explicitBinding.getSource()).exposedButNotBound(key); return; } this.delegate = explicitBinding; }