Refine search
@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()); } }
public ErrorsException toException() { return new ErrorsException(this); }
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); }
Errors errors = new Errors(); throw errors.addMessage("%s must be an interface.", factoryRawType).toException(); method, returnType, implementation, immutableParamList); } catch (ErrorsException ee) { errors.merge(ee.getErrors()); continue; methodHandleByMethod = methodHandleBuilder.build(); } catch (ErrorsException e) { throw new ConfigurationException(e.getErrors().getMessages());
@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()); } }
/** * 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()); } } }
@SuppressWarnings("unchecked") public static <T> Key<T> ensureProvidedKey(Key<T> key, Errors errors) { try { return isProvider(key) ? getProvidedKey((Key<Provider<T>>) key, errors) : key; } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } return null; }
@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; }
private Key<?> getKey(ParameterInfo parameter) { try { // Get TypeLiteral for this parameter TypeLiteral<?> declaringType = TypeLiteral.get(parameter.getDeclaringClass()); List<TypeLiteral<?>> parameterTypes = declaringType.getParameterTypes(parameter.getConstructor()); TypeLiteral<?> parameterType = parameterTypes.get(parameter.getParameterIndex()); // Create Key object for this parameter Errors errors = new Errors(parameter.getConstructor()); return Annotations.getKey( parameterType, parameter.getConstructor(), parameter.getParameterAnnotations(), errors); } catch (ErrorsException e) { throw new MgnlInstantiationException(e.getMessage(), e); } } }
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)); }
Errors errors = new Errors(); throw errors.addMessage("%s must be an interface.", factoryRawType).toException(); findMatchingConstructorInjectionPoint(method, returnType, implementation, immutableParamList); } catch (ErrorsException ee) { errors.merge(ee.getErrors()); continue; methodHandleByMethod = methodHandleBuilder.build(); } catch (ErrorsException e) { throw new ConfigurationException(e.getErrors().getMessages());
@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 <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; }
@SuppressWarnings("unchecked") public static <T> Key<T> ensureProvidedKey(Key<T> key, Errors errors) { try { return isProvider(key) ? getProvidedKey((Key<Provider<T>>) key, errors) : key; } catch (ConfigurationException e) { errors.merge(e.getErrorMessages()); } catch (ErrorsException e) { errors.merge(e.getErrors()); } return null; }
/** 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)); }
Errors errors = new Errors(); throw errors.addMessage("%s must be an interface.", factoryRawType).toException(); findMatchingConstructorInjectionPoint(method, returnType, implementation, immutableParamList); } catch(ErrorsException ee) { errors.merge(ee.getErrors()); continue; throw new ConfigurationException(e.getErrors().getMessages());
@Override public void run() { try { binding.getInjector().initializeBinding(binding, errors.withSource(source)); } catch (ErrorsException e) { errors.merge(e.getErrors()); } } };