public void validate(Errors errors) throws ErrorsException { @SuppressWarnings("unchecked") // the type of 'T' is a TypeLiteral<T> TypeLiteral<T> type = TypeLiteral.get((Class<T>) instance.getClass()); membersInjector = injector.membersInjectorStore.get(type, errors.withSource(source)); Preconditions.checkNotNull( membersInjector, "No membersInjector available for instance: %s, from key: %s", instance, key); state = InjectableReferenceState.VALIDATED; }
public void process(InjectorImpl injector, List<Element> elements) { Errors errorsAnyElement = this.errors; this.injector = injector; try { for (Iterator<Element> i = elements.iterator(); i.hasNext(); ) { Element element = i.next(); this.errors = errorsAnyElement.withSource(element.getSource()); Boolean allDone = element.acceptVisitor(this); if (allDone) { i.remove(); } } } finally { this.errors = errorsAnyElement; this.injector = null; } }
/** Returns parameter injectors, or {@code null} if there are no parameters. */ SingleParameterInjector<?>[] getParametersInjectors(List<Dependency<?>> parameters, Errors errors) throws ErrorsException { if (parameters.isEmpty()) { return null; } int numErrorsBefore = errors.size(); SingleParameterInjector<?>[] result = new SingleParameterInjector<?>[parameters.size()]; int i = 0; for (Dependency<?> parameter : parameters) { try { result[i++] = createParameterInjector(parameter, errors.withSource(parameter)); } catch (ErrorsException rethrownBelow) { // rethrown below } } errors.throwIfNewErrors(numErrorsBefore); return result; }
@Override public void notify(Errors errors) { try { providerFactory = injector.getInternalFactory( providerKey, errors.withSource(source), JitLimitation.NEW_OR_EXISTING_JIT); } catch (ErrorsException e) { errors.merge(e.getErrors()); } }
@Override public void notify(final Errors errors) { try { targetFactory = injector.getInternalFactory( targetKey, errors.withSource(source), JitLimitation.NEW_OR_EXISTING_JIT); } catch (ErrorsException e) { errors.merge(e.getErrors()); } }
/** * Adds an error if there is a misplaced annotations on {@code type}. Scoping annotations are not * allowed on abstract classes or interfaces. */ public static void checkForMisplacedScopeAnnotations( Class<?> type, Object source, Errors errors) { if (Classes.isConcrete(type)) { return; } Class<? extends Annotation> scopeAnnotation = findScopeAnnotation(errors, type); if (scopeAnnotation != null // We let Dagger Components through to aid migrations. && !containsComponentAnnotation(type.getAnnotations())) { errors.withSource(type).scopeAnnotationOnAbstractType(scopeAnnotation, type, source); } }
/** Returns the injectors for the specified injection points. */ ImmutableList<SingleMemberInjector> getInjectors( Set<InjectionPoint> injectionPoints, Errors errors) { List<SingleMemberInjector> injectors = Lists.newArrayList(); for (InjectionPoint injectionPoint : injectionPoints) { try { Errors errorsForMember = injectionPoint.isOptional() ? new Errors(injectionPoint) : errors.withSource(injectionPoint); SingleMemberInjector injector = injectionPoint.getMember() instanceof Field ? new SingleFieldInjector(this.injector, injectionPoint, errorsForMember) : new SingleMethodInjector(this.injector, injectionPoint, errorsForMember); injectors.add(injector); } catch (ErrorsException ignoredForNow) { // ignored for now } } return ImmutableList.copyOf(injectors); } }
@Override public void run() { try { binding.getInjector().initializeBinding(binding, errors.withSource(source)); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } };
@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; }
void validate() { Errors errorsForMember = errors.withSource(source); Set<InjectionPoint> injectionPoints; try { injectionPoints = request.getInjectionPoints(); } catch (ConfigurationException e) { errorsForMember.merge(e.getErrorMessages()); injectionPoints = e.getPartialValue(); } if (injectionPoints != null) { memberInjectors = injector.membersInjectorStore.getInjectors(injectionPoints, errorsForMember); } else { memberInjectors = ImmutableList.of(); } errors.merge(errorsForMember); }
binding.getInternalFactory().get(context, dependency, false); } catch (InternalProvisionException e) { errors.withSource(dependency).merge(e); } finally { context.popStateAndSetDependency(previous);
scoping = Scoping.makeInjectable( Scoping.forAnnotation(scopeAnnotation), injector, errors.withSource(rawType));
public void validate(Errors errors) throws ErrorsException { @SuppressWarnings("unchecked") // the type of 'T' is a TypeLiteral<T> TypeLiteral<T> type = TypeLiteral.get((Class<T>) instance.getClass()); membersInjector = injector.membersInjectorStore.get(type, errors.withSource(source)); Preconditions.checkNotNull( membersInjector, "No membersInjector available for instance: %s, from key: %s", instance, key); state = InjectableReferenceState.VALIDATED; }
public void validate(Errors errors) throws ErrorsException { @SuppressWarnings("unchecked") // the type of 'T' is a TypeLiteral<T> TypeLiteral<T> type = TypeLiteral.get((Class<T>) instance.getClass()); membersInjector = injector.membersInjectorStore.get(type, errors.withSource(source)); }
public T get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) throws ErrorsException { return targetBinding.getInternalFactory().get( errors.withSource(targetKey), context, dependency, true); } };
public T get(Errors errors, InternalContext context, Dependency<?> dependency, boolean linked) throws ErrorsException { // TODO(sameb): Does this need to push state into the context? try { return errors.checkForNull(provider.get(), source, dependency); } catch (RuntimeException userException) { throw errors.withSource(source).errorInProvider(userException).toException(); } }
@Override public void notify(Errors errors) { try { providerFactory = injector.getInternalFactory( providerKey, errors.withSource(source), JitLimitation.NEW_OR_EXISTING_JIT); } catch (ErrorsException e) { errors.merge(e.getErrors()); } }
@Override public void notify(final Errors errors) { try { targetFactory = injector.getInternalFactory( targetKey, errors.withSource(source), JitLimitation.NEW_OR_EXISTING_JIT); } catch (ErrorsException e) { errors.merge(e.getErrors()); } }
private T inject(Errors errors, InternalContext context) throws ErrorsException { Dependency previous = context.setDependency(dependency); try { return factory.get(errors.withSource(dependency), context, dependency, false); } finally { context.setDependency(previous); } }
@Override public void run() { try { binding.getInjector().initializeBinding(binding, errors.withSource(source)); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } };