@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()); } }
/** * Prepares member injectors for all injected instances. This prompts Guice to do static analysis * on the injected instances. */ void validateOustandingInjections(Errors errors) { validationStarted = true; initializablesCache.clear(); for (InjectableReference<?> reference : pendingInjections) { try { reference.validate(errors); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } }
@Override public void run() { try { binding.getInjector().initializeBinding(binding, errors.withSource(source)); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } };
@Override public Object load(K key) { Errors errors = new Errors(); V result = null; try { result = FailableCache.this.create(key, errors); } catch (ErrorsException e) { errors.merge(e.getErrors()); } return errors.hasErrors() ? errors : result; } });
@Override public <T> Boolean visit(ProviderLookup<T> lookup) { // ensure the provider can be created try { Provider<T> provider = injector.getProviderOrThrow(lookup.getDependency(), errors); lookup.initializeDelegate(provider); } catch (ErrorsException e) { errors.merge(e.getErrors()); // TODO: source } return true; } }
@Override public <T> Boolean visit(MembersInjectorLookup<T> lookup) { try { MembersInjector<T> membersInjector = injector.membersInjectorStore.get(lookup.getType(), errors); lookup.initializeDelegate(membersInjector); } catch (ErrorsException e) { errors.merge(e.getErrors()); // TODO: source } return true; }
@Override public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral) { Errors errors = new Errors(typeLiteral); try { return membersInjectorStore.get(typeLiteral, errors); } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } }
private ImmutableList<Dependency<?>> forMember( Member member, TypeLiteral<?> type, Annotation[][] paramterAnnotations) { Errors errors = new Errors(member); List<Dependency<?>> dependencies = Lists.newArrayList(); int index = 0; for (TypeLiteral<?> parameterType : type.getParameterTypes(member)) { try { Annotation[] parameterAnnotations = paramterAnnotations[index]; Key<?> key = Annotations.getKey(parameterType, member, parameterAnnotations, errors); dependencies.add(newDependency(key, Nullability.allowsNull(parameterAnnotations), index)); index++; } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } errors.throwConfigurationExceptionIfErrorsExist(); return ImmutableList.copyOf(dependencies); }
/** Returns the binding for {@code key} */ @Override public <T> BindingImpl<T> getBinding(Key<T> key) { Errors errors = new Errors(key); try { BindingImpl<T> result = getBindingOrThrow(key, errors, JitLimitation.EXISTING_JIT); errors.throwConfigurationExceptionIfErrorsExist(); return result; } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } }
InjectionPoint(TypeLiteral<?> declaringType, Field field, boolean optional) { this.member = field; this.declaringType = declaringType; this.optional = optional; Annotation[] annotations = field.getAnnotations(); Errors errors = new Errors(field); Key<?> key = null; try { key = Annotations.getKey(declaringType.getFieldType(field), field, annotations, errors); } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } errors.throwConfigurationExceptionIfErrorsExist(); this.dependencies = ImmutableList.<Dependency<?>>of( newDependency(key, Nullability.allowsNull(annotations), -1)); }
@Override public <T> Provider<T> getProvider(final Key<T> key) { Errors errors = new Errors(key); try { Provider<T> result = getProviderOrThrow(Dependency.get(key), errors); errors.throwIfNewErrors(0); return result; } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } }
throw new ConfigurationException(e.getErrors().getMessages());
@Override public Boolean visit(ConstructorBinding<? extends T> binding) { prepareBinding(); try { ConstructorBindingImpl<T> onInjector = ConstructorBindingImpl.create( injector, key, binding.getConstructor(), source, scoping, errors, false, false); scheduleInitialization(onInjector); putBinding(onInjector); } catch (ErrorsException e) { errors.merge(e.getErrors()); putBinding(invalidBinding(injector, key, source)); } return true; }
@Override public Boolean visit(UntargettedBinding<? extends T> untargetted) { prepareBinding(); // Error: Missing implementation. // Example: bind(Date.class).annotatedWith(Red.class); // We can't assume abstract types aren't injectable. They may have an // @ImplementedBy annotation or something. if (key.getAnnotationType() != null) { errors.missingImplementationWithHint(key, injector); putBinding(invalidBinding(injector, key, source)); return true; } // This cast is safe after the preceeding check. try { BindingImpl<T> binding = injector.createUninitializedBinding(key, scoping, source, errors, false); scheduleInitialization(binding); putBinding(binding); } catch (ErrorsException e) { errors.merge(e.getErrors()); putBinding(invalidBinding(injector, key, source)); } return true; }
@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()); } }
@Override public void run() { try { binding.getInjector().initializeBinding(binding, errors.withSource(source)); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } };
@Override public <T> MembersInjector<T> getMembersInjector(TypeLiteral<T> typeLiteral) { Errors errors = new Errors(typeLiteral); try { return membersInjectorStore.get(typeLiteral, errors); } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } }
/** Returns the binding for {@code key} */ @Override public <T> BindingImpl<T> getBinding(Key<T> key) { Errors errors = new Errors(key); try { BindingImpl<T> result = getBindingOrThrow(key, errors, JitLimitation.EXISTING_JIT); errors.throwConfigurationExceptionIfErrorsExist(); return result; } catch (ErrorsException e) { throw new ConfigurationException(errors.merge(e.getErrors()).getMessages()); } }