Package com.google.inject

Examples of com.google.inject.ConfigurationException


  private final Map<Key<?>, TypeLiteral<?>> bindings =
      new LinkedHashMap<Key<?>, TypeLiteral<?>>();

  public BindingCollector addBinding(Key<?> key, TypeLiteral<?> target) {
    if (bindings.containsKey(key)) {
      throw new ConfigurationException(Collections.singleton(
          new Message("Only one implementation can be specified for " + key)));
    }

    bindings.put(key, target);
View Full Code Here


  public void throwConfigurationExceptionIfErrorsExist() {
    if (!hasErrors()) {
      return;
    }

    throw new ConfigurationException(getMessages());
  }
View Full Code Here

        paramTypesBuilder.put(method, ImmutableList.copyOf(keys));
      }
      returnTypesByMethod = returnTypesBuilder.build();
      paramTypes = paramTypesBuilder.build();
    } catch (ErrorsException e) {
      throw new ConfigurationException(e.getErrors().getMessages());
    }

    factory = factoryRawType.cast(Proxy.newProxyInstance(factoryRawType.getClassLoader(),
        new Class[] { factoryRawType }, this));
  }
View Full Code Here

   * all factory methods will be able to build the target types.
   */
  @Inject
  void initialize(Injector injector) {
    if (this.injector != null) {
      throw new ConfigurationException(ImmutableList.of(new Message(FactoryProvider2.class,
          "Factories.create() factories may only be used in one Injector!")));
    }

    this.injector = injector;

View Full Code Here

    return factoryRawType.cast(Proxy.newProxyInstance(factoryRawType.getClassLoader(),
        new Class[] { factoryRawType }, invocationHandler));
  }

  private static ConfigurationException newConfigurationException(String format, Object... args) {
    return new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
  }
View Full Code Here

  static void checkConfiguration(boolean condition, String format, Object... args) {
    if (condition) {
      return;
    }

    throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
  }
View Full Code Here

    if (reference != null) {
      return reference;
    }

    NullPointerException npe = new NullPointerException(name);
    throw new ConfigurationException(ImmutableSet.of(
        new Message(ImmutableList.of(), npe.toString(), npe)));
  }
View Full Code Here

  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

  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

  public void throwConfigurationExceptionIfErrorsExist() {
    if (!hasErrors()) {
      return;
    }

    throw new ConfigurationException(getMessages());
  }
View Full Code Here

TOP

Related Classes of com.google.inject.ConfigurationException

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.