Package com.google.inject.spi

Examples of com.google.inject.spi.Message


    initCause(Errors.getOnlyCause(this.messages));
  }

  public ProvisionException(String message, Throwable cause) {
    super(cause);
    this.messages = ImmutableSet.of(new Message(ImmutableList.of(), message, cause));
  }
View Full Code Here


    super(cause);
    this.messages = ImmutableSet.of(new Message(ImmutableList.of(), message, cause));
  }

  public ProvisionException(String message) {
    this.messages = ImmutableSet.of(new Message(message));
  }
View Full Code Here

  private Message merge(Message message) {
    List<Object> sources = Lists.newArrayList();
    sources.addAll(getSources());
    sources.addAll(message.getSources());
    return new Message(sources, message.getMessage(), message.getCause());
  }
View Full Code Here

    return addMessage(null, messageFormat, arguments);
  }

  private Errors addMessage(Throwable cause, String messageFormat, Object... arguments) {
    String message = format(messageFormat, arguments);
    addMessage(new Message(getSources(), message, cause));
    return this;
  }
View Full Code Here

    {
        final List<Message> messages = Lists.newArrayList();


        for (String error : configurationFactory.getInitialErrors()) {
            final Message message = new Message(error);
            messages.add(message);
            configurationFactory.getMonitor().onError(message);
        }

        ElementsIterator elementsIterator = new ElementsIterator(modules);
        for (final Element element : elementsIterator) {
            element.acceptVisitor(new DefaultElementVisitor<Void>()
            {
                @Override
                public <T> Void visit(Binding<T> binding)
                {
                    // look for ConfigurationProviders...
                    if (binding instanceof ProviderInstanceBinding) {
                        ProviderInstanceBinding<?> providerInstanceBinding = (ProviderInstanceBinding<?>) binding;
                        Provider<?> provider = providerInstanceBinding.getProviderInstance();
                        if (provider instanceof ConfigurationAwareProvider) {
                            ConfigurationAwareProvider<?> configurationProvider = (ConfigurationAwareProvider<?>) provider;
                            // give the provider the configuration factory
                            configurationProvider.setConfigurationFactory(configurationFactory);
                            configurationProvider.setWarningsMonitor(warningsMonitor);
                            try {
                                // call the getter which will cause object creation
                                configurationProvider.get();
                            } catch (ConfigurationException e) {
                                // if we got errors, add them to the errors list
                                for (Message message : e.getErrorMessages()) {
                                    messages.add(new Message(singletonList(binding.getSource()), message.getMessage(), message.getCause()));
                                }
                            }
                        }

                    }

                    return null;
                }

                @Override
                public Void visit(PrivateElements privateElements)
                {
                    for (Element element : privateElements.getElements()) {
                        element.acceptVisitor(this);
                    }

                    return null;
                }
            });
        }

        for (String unusedProperty : configurationFactory.getUnusedProperties()) {
            final Message message = new Message(format("Configuration property '%s' was not used", unusedProperty));
            messages.add(message);
            configurationFactory.getMonitor().onError(message);
        }

        return messages;
View Full Code Here

        return ImmutableList.copyOf(errors);
    }

    public void addError(String format, Object... params)
    {
        Message message = new Message("Error: " + format(format, params));
        errors.add(message);
        monitor.onError(message);
    }
View Full Code Here

        monitor.onError(message);
    }

    public void addError(Throwable e, String format, Object... params)
    {
        Message message = new Message(emptyList(), "Error: " + format(format, params), e);
        errors.add(message);
        monitor.onError(message);
    }
View Full Code Here

        return ImmutableList.copyOf(warnings);
    }

    public void addWarning(String format, Object... params)
    {
        Message message = new Message("Warning: " + format(format, params));
        warnings.add(message);
        monitor.onWarning(message);
    }
View Full Code Here

      assertEquals(getFirstThrowableOfType(aex, AuthorizationException.class), aex);
   }

   public void testGetCause() {
      AuthorizationException aex = createMock(AuthorizationException.class);
      Message message = new Message(ImmutableList.of(), "test", aex);
      ProvisionException pex = new ProvisionException(ImmutableSet.of(message));
      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
   }
View Full Code Here

      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
   }

   public void testGetFirstThrowableOfTypeInner() {
      AuthorizationException aex = createMock(AuthorizationException.class);
      Message message = new Message(ImmutableList.of(), "test", aex);
      ProvisionException pex = new ProvisionException(ImmutableSet.of(message));
      assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
   }
View Full Code Here

TOP

Related Classes of com.google.inject.spi.Message

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.