com.google.inject.spi.Message.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中com.google.inject.spi.Message.<init>()方法的一些代码示例,展示了Message.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.<init>()方法的具体详情如下:
包路径:com.google.inject.spi.Message
类名称:Message
方法名:<init>

Message.<init>介绍

暂无

代码示例

代码示例来源:origin: com.google.inject/guice

  1. public ProvisionException(String message, Throwable cause) {
  2. super(cause);
  3. this.messages = ImmutableSet.of(new Message(message, cause));
  4. }

代码示例来源:origin: com.google.inject/guice

  1. public ProvisionException(String message) {
  2. this.messages = ImmutableSet.of(new Message(message));
  3. }

代码示例来源:origin: apache/incubator-druid

  1. @Override
  2. public Message apply(String input)
  3. {
  4. return new Message(StringUtils.format("%s%s", propertyBase, input));
  5. }
  6. }

代码示例来源:origin: com.google.inject/guice

  1. @Override
  2. public void addError(Throwable t) {
  3. String message = "An exception was caught and reported. Message: " + t.getMessage();
  4. elements.add(new Message(ImmutableList.of((Object) getElementSource()), message, t));
  5. }

代码示例来源:origin: com.google.inject/guice

  1. /**
  2. * Throws a ConfigurationException with an NullPointerExceptions as the cause if the given
  3. * reference is {@code null}.
  4. */
  5. static <T> T checkNotNull(T reference, String name) {
  6. if (reference != null) {
  7. return reference;
  8. }
  9. NullPointerException npe = new NullPointerException(name);
  10. throw new ConfigurationException(ImmutableSet.of(new Message(npe.toString(), npe)));
  11. }

代码示例来源:origin: com.google.inject/guice

  1. /**
  2. * Throws a ConfigurationException with a formatted {@link Message} if this condition is {@code
  3. * false}.
  4. */
  5. static void checkConfiguration(boolean condition, String format, Object... args) {
  6. if (condition) {
  7. return;
  8. }
  9. throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
  10. }

代码示例来源:origin: com.google.inject/guice

  1. /**
  2. * When serialized, we eagerly convert sources to strings. This hurts our formatting, but it
  3. * guarantees that the receiving end will be able to read the message.
  4. */
  5. private Object writeReplace() throws ObjectStreamException {
  6. Object[] sourcesAsStrings = sources.toArray();
  7. for (int i = 0; i < sourcesAsStrings.length; i++) {
  8. sourcesAsStrings[i] = Errors.convert(sourcesAsStrings[i]).toString();
  9. }
  10. return new Message(ImmutableList.copyOf(sourcesAsStrings), message, cause);
  11. }

代码示例来源:origin: com.google.inject/guice

  1. /**
  2. * Creates a new Message with the given cause and a binding source stack.
  3. *
  4. * @param cause The exception that caused the error
  5. * @param sources The binding sources for the source stack
  6. * @param messageFormat Format string
  7. * @param arguments format string arguments
  8. */
  9. public static Message create(
  10. Throwable cause, List<Object> sources, String messageFormat, Object... arguments) {
  11. String message = format(messageFormat, arguments);
  12. return new Message(sources, message, cause);
  13. }

代码示例来源:origin: com.google.inject/guice

  1. /** Prepends the list of sources to the given {@link Message} */
  2. static Message mergeSources(List<Object> sources, Message message) {
  3. List<Object> messageSources = message.getSources();
  4. // It is possible that the end of getSources() and the beginning of message.getSources() are
  5. // equivalent, in this case we should drop the repeated source when joining the lists. The
  6. // most likely scenario where this would happen is when a scoped binding throws an exception,
  7. // due to the fact that InternalFactoryToProviderAdapter applies the binding source when
  8. // merging errors.
  9. if (!sources.isEmpty()
  10. && !messageSources.isEmpty()
  11. && Objects.equal(messageSources.get(0), sources.get(sources.size() - 1))) {
  12. messageSources = messageSources.subList(1, messageSources.size());
  13. }
  14. return new Message(
  15. ImmutableList.builder().addAll(sources).addAll(messageSources).build(),
  16. message.getMessage(),
  17. message.getCause());
  18. }

代码示例来源:origin: com.google.inject/guice

  1. @Override
  2. public void addError(String message, Object... arguments) {
  3. elements.add(new Message(getElementSource(), Errors.format(message, arguments)));
  4. }

代码示例来源:origin: com.google.inject/guice

  1. return new Message(Thread.currentThread(), sb.toString());

代码示例来源:origin: apache/shiro

  1. @Test
  2. public void testPropertySetting() throws Exception {
  3. IMocksControl control = createControl();
  4. TypeEncounter<SomeInjectableBean> encounter = control.createMock(TypeEncounter.class);
  5. Provider<Injector> injectorProvider = control.createMock(Provider.class);
  6. Injector injector = control.createMock(Injector.class);
  7. expect(encounter.getProvider(Injector.class)).andReturn(injectorProvider);
  8. expect(injectorProvider.get()).andReturn(injector).anyTimes();
  9. Capture<MembersInjector<SomeInjectableBean>> capture = new Capture<MembersInjector<SomeInjectableBean>>();
  10. encounter.register(and(anyObject(MembersInjector.class), capture(capture)));
  11. SecurityManager securityManager = control.createMock(SecurityManager.class);
  12. String property = "myPropertyValue";
  13. expect(injector.getInstance(Key.get(SecurityManager.class))).andReturn(securityManager);
  14. expect(injector.getInstance(Key.get(String.class, Names.named("shiro.myProperty")))).andReturn(property);
  15. expect(injector.getInstance(Key.get(String.class, Names.named("shiro.unavailableProperty"))))
  16. .andThrow(new ConfigurationException(Collections.singleton(new Message("Not Available!"))));
  17. expect((Map)injector.getInstance(BeanTypeListener.MAP_KEY)).andReturn(Collections.EMPTY_MAP).anyTimes();
  18. control.replay();
  19. BeanTypeListener underTest = new BeanTypeListener();
  20. underTest.hear(TypeLiteral.get(SomeInjectableBean.class), encounter);
  21. SomeInjectableBean bean = new SomeInjectableBean();
  22. capture.getValue().injectMembers(bean);
  23. assertSame(securityManager, bean.securityManager);
  24. assertSame(property, bean.myProperty);
  25. assertNull(bean.unavailableProperty);
  26. control.verify();
  27. }

代码示例来源:origin: org.sonatype.sisu/sisu-guice

  1. /**
  2. * Throws a ConfigurationException with a formatted {@link Message} if this condition is {@code
  3. * false}.
  4. */
  5. static void checkConfiguration(boolean condition, String format, Object... args) {
  6. if (condition) {
  7. return;
  8. }
  9. throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
  10. }

代码示例来源:origin: io.airlift/configuration

  1. public void addError(Throwable e, String format, Object... params)
  2. {
  3. Message message = new Message(emptyList(), "Error: " + format(format, params), e);
  4. errors.add(message);
  5. monitor.onError(message);
  6. }

代码示例来源:origin: jclouds/legacy-jclouds

  1. @Test(expectedExceptions = AuthorizationException.class)
  2. public void testPropagateCreationExceptionAuthorizationException() throws Throwable {
  3. Exception e = new AuthorizationException();
  4. propagateIfPossible(
  5. new CreationException(ImmutableSet.of(new Message(ImmutableList.of(), "Error in custom provider", e))),
  6. ImmutableSet.<TypeToken<? extends Throwable>> of());
  7. }

代码示例来源:origin: jclouds/legacy-jclouds

  1. public void testGetCauseCreation() {
  2. AuthorizationException aex = createMock(AuthorizationException.class);
  3. Message message = new Message(ImmutableList.of(), "test", aex);
  4. CreationException pex = new CreationException(ImmutableSet.of(message));
  5. assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
  6. }

代码示例来源:origin: jclouds/legacy-jclouds

  1. public void testGetFirstThrowableOfTypeFailCreation() {
  2. TimeoutException aex = createMock(TimeoutException.class);
  3. Message message = new Message(ImmutableList.of(), "test", aex);
  4. CreationException pex = new CreationException(ImmutableSet.of(message));
  5. assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
  6. }

代码示例来源:origin: jclouds/legacy-jclouds

  1. public void testGetFirstThrowableOfTypeFail() {
  2. TimeoutException aex = createMock(TimeoutException.class);
  3. Message message = new Message(ImmutableList.of(), "test", aex);
  4. ProvisionException pex = new ProvisionException(ImmutableSet.of(message));
  5. assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
  6. }

代码示例来源:origin: jclouds/legacy-jclouds

  1. public void testGetFirstThrowableOfTypeWhenCauseIsNullCreation() {
  2. Message message = new Message(ImmutableList.of(), "test", null);
  3. CreationException pex = new CreationException(ImmutableSet.of(message));
  4. assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
  5. }

代码示例来源:origin: jclouds/legacy-jclouds

  1. public void testGetFirstThrowableOfTypeWhenCauseIsNull() {
  2. Message message = new Message(ImmutableList.of(), "test", null);
  3. ProvisionException pex = new ProvisionException(ImmutableSet.of(message));
  4. assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
  5. }

相关文章