Package com.google.inject.internal

Examples of com.google.inject.internal.Errors


  }

  public static InjectionPoint forConstructor(Constructor paramConstructor, TypeLiteral paramTypeLiteral)
  {
    if (paramTypeLiteral.getRawType() != paramConstructor.getDeclaringClass())
      new Errors(paramTypeLiteral).constructorNotDefinedByType(paramConstructor, paramTypeLiteral).throwConfigurationExceptionIfErrorsExist();
    return new InjectionPoint(paramTypeLiteral, paramConstructor);
  }
View Full Code Here


    return forConstructorOf(TypeLiteral.get(paramClass));
  }

  public static Set forStaticMethodsAndFields(TypeLiteral paramTypeLiteral)
  {
    Errors localErrors = new Errors();
    Set localSet = getInjectionPoints(paramTypeLiteral, true, localErrors);
    if (localErrors.hasErrors())
      throw new ConfigurationException(localErrors.getMessages()).withPartialValue(localSet);
    return localSet;
  }
View Full Code Here

    return forStaticMethodsAndFields(TypeLiteral.get(paramClass));
  }

  public static Set forInstanceMethodsAndFields(TypeLiteral paramTypeLiteral)
  {
    Errors localErrors = new Errors();
    Set localSet = getInjectionPoints(paramTypeLiteral, false, localErrors);
    if (localErrors.hasErrors())
      throw new ConfigurationException(localErrors.getMessages()).withPartialValue(localSet);
    return localSet;
  }
View Full Code Here

            for (Method method : currentClass.getDeclaredMethods()) {
                if (method.isAnnotationPresent(Test.class)
                        || method.isAnnotationPresent(Before.class)
                        || method.isAnnotationPresent(After.class)) {

                    Errors errors = new Errors(method);
                    List<Key<?>> keys = GuiceUtils.getMethodKeys(method, errors);

                    for (Key<?> key : keys) {
                        // Skip keys annotated with @All
                        if (!All.class.equals(key.getAnnotationType())) {
                            Key<?> keyNeeded = GuiceUtils.ensureProvidedKey(key, errors);
                            addNeededKey(keysObserved, keysNeeded, keyNeeded, true);
                        }
                    }
                    errors.throwConfigurationExceptionIfErrorsExist();
                }
            }
            currentClass = currentClass.getSuperclass();
        }

        // Preempt JIT binding by looking through the test class looking for
        // fields and methods annotated with @Inject.
        // Concrete classes bound in this way are bound in @TestSingleton.
        if (testClass != null) {
            Set<InjectionPoint> injectionPoints = InjectionPoint.forInstanceMethodsAndFields(testClass);

            for (InjectionPoint injectionPoint : injectionPoints) {
                Errors errors = new Errors(injectionPoint);
                List<Dependency<?>> dependencies = injectionPoint.getDependencies();
                for (Dependency<?> dependency : dependencies) {
                    Key<?> keyNeeded = GuiceUtils.ensureProvidedKey(dependency.getKey(),
                            errors);
                    addNeededKey(keysObserved, keysNeeded, keyNeeded, true);
                }
                errors.throwConfigurationExceptionIfErrorsExist();
            }
        }

        // Recursively add the dependencies of all the bindings observed. Warning, we can't use for each here
        // since it would result into concurrency issues.
View Full Code Here

                }
            };
            methodInjector = Guice.createInjector(jukitoModule);
        }

        Errors errors = new Errors(javaMethod);
        List<Key<?>> keys = GuiceUtils.getMethodKeys(javaMethod, errors);
        errors.throwConfigurationExceptionIfErrorsExist();

        Iterator<Binding<?>> bindingIter;
        if (InjectedFrameworkMethod.class.isAssignableFrom(method.getClass())) {
            bindingIter = ((InjectedFrameworkMethod) method).getBindingsToUseForParameters().iterator();
        } else {
View Full Code Here

        }
        List<FrameworkMethod> testMethods = getTestClass().getAnnotatedMethods(Test.class);
        List<FrameworkMethod> result = new ArrayList<FrameworkMethod>(testMethods.size());
        for (FrameworkMethod method : testMethods) {
            Method javaMethod = method.getMethod();
            Errors errors = new Errors(javaMethod);
            List<Key<?>> keys = GuiceUtils.getMethodKeys(javaMethod, errors);
            errors.throwConfigurationExceptionIfErrorsExist();

            List<List<Binding<?>>> bindingsToUseForParameters = new ArrayList<List<Binding<?>>>();
            for (Key<?> key : keys) {
                if (All.class.equals(key.getAnnotationType())) {
                    All allAnnotation = (All) key.getAnnotation();
View Full Code Here

  {
    this.member = paramField;
    this.declaringType = paramTypeLiteral;
    this.optional = paramBoolean;
    Annotation[] arrayOfAnnotation = paramField.getAnnotations();
    Errors localErrors = new Errors(paramField);
    Key localKey = null;
    try
    {
      localKey = Annotations.getKey(paramTypeLiteral.getFieldType(paramField), paramField, arrayOfAnnotation, localErrors);
    }
    catch (ConfigurationException localConfigurationException)
    {
      localErrors.merge(localConfigurationException.getErrorMessages());
    }
    catch (ErrorsException localErrorsException)
    {
      localErrors.merge(localErrorsException.getErrors());
    }
    localErrors.throwConfigurationExceptionIfErrorsExist();
    this.dependencies = $ImmutableList.of(newDependency(localKey, Nullability.allowsNull(arrayOfAnnotation), -1));
  }
View Full Code Here

  }

  public static InjectionPoint forConstructor(Constructor paramConstructor, TypeLiteral paramTypeLiteral)
  {
    if (paramTypeLiteral.getRawType() != paramConstructor.getDeclaringClass())
      new Errors(paramTypeLiteral).constructorNotDefinedByType(paramConstructor, paramTypeLiteral).throwConfigurationExceptionIfErrorsExist();
    return new InjectionPoint(paramTypeLiteral, paramConstructor);
  }
View Full Code Here

    return forConstructorOf(TypeLiteral.get(paramClass));
  }

  public static Set forStaticMethodsAndFields(TypeLiteral paramTypeLiteral)
  {
    Errors localErrors = new Errors();
    Set localSet = getInjectionPoints(paramTypeLiteral, true, localErrors);
    if (localErrors.hasErrors())
      throw new ConfigurationException(localErrors.getMessages()).withPartialValue(localSet);
    return localSet;
  }
View Full Code Here

    return forStaticMethodsAndFields(TypeLiteral.get(paramClass));
  }

  public static Set forInstanceMethodsAndFields(TypeLiteral paramTypeLiteral)
  {
    Errors localErrors = new Errors();
    Set localSet = getInjectionPoints(paramTypeLiteral, false, localErrors);
    if (localErrors.hasErrors())
      throw new ConfigurationException(localErrors.getMessages()).withPartialValue(localSet);
    return localSet;
  }
View Full Code Here

TOP

Related Classes of com.google.inject.internal.Errors

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.