本文整理了Java中com.google.inject.spi.Message.<init>()
方法的一些代码示例,展示了Message.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.<init>()
方法的具体详情如下:
包路径:com.google.inject.spi.Message
类名称:Message
方法名:<init>
暂无
代码示例来源:origin: com.google.inject/guice
public ProvisionException(String message, Throwable cause) {
super(cause);
this.messages = ImmutableSet.of(new Message(message, cause));
}
代码示例来源:origin: com.google.inject/guice
public ProvisionException(String message) {
this.messages = ImmutableSet.of(new Message(message));
}
代码示例来源:origin: apache/incubator-druid
@Override
public Message apply(String input)
{
return new Message(StringUtils.format("%s%s", propertyBase, input));
}
}
代码示例来源:origin: com.google.inject/guice
@Override
public void addError(Throwable t) {
String message = "An exception was caught and reported. Message: " + t.getMessage();
elements.add(new Message(ImmutableList.of((Object) getElementSource()), message, t));
}
代码示例来源:origin: com.google.inject/guice
/**
* Throws a ConfigurationException with an NullPointerExceptions as the cause if the given
* reference is {@code null}.
*/
static <T> T checkNotNull(T reference, String name) {
if (reference != null) {
return reference;
}
NullPointerException npe = new NullPointerException(name);
throw new ConfigurationException(ImmutableSet.of(new Message(npe.toString(), npe)));
}
代码示例来源:origin: com.google.inject/guice
/**
* Throws a ConfigurationException with a formatted {@link Message} if this condition is {@code
* false}.
*/
static void checkConfiguration(boolean condition, String format, Object... args) {
if (condition) {
return;
}
throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
}
代码示例来源:origin: com.google.inject/guice
/**
* When serialized, we eagerly convert sources to strings. This hurts our formatting, but it
* guarantees that the receiving end will be able to read the message.
*/
private Object writeReplace() throws ObjectStreamException {
Object[] sourcesAsStrings = sources.toArray();
for (int i = 0; i < sourcesAsStrings.length; i++) {
sourcesAsStrings[i] = Errors.convert(sourcesAsStrings[i]).toString();
}
return new Message(ImmutableList.copyOf(sourcesAsStrings), message, cause);
}
代码示例来源:origin: com.google.inject/guice
/**
* Creates a new Message with the given cause and a binding source stack.
*
* @param cause The exception that caused the error
* @param sources The binding sources for the source stack
* @param messageFormat Format string
* @param arguments format string arguments
*/
public static Message create(
Throwable cause, List<Object> sources, String messageFormat, Object... arguments) {
String message = format(messageFormat, arguments);
return new Message(sources, message, cause);
}
代码示例来源:origin: com.google.inject/guice
/** Prepends the list of sources to the given {@link Message} */
static Message mergeSources(List<Object> sources, Message message) {
List<Object> messageSources = message.getSources();
// It is possible that the end of getSources() and the beginning of message.getSources() are
// equivalent, in this case we should drop the repeated source when joining the lists. The
// most likely scenario where this would happen is when a scoped binding throws an exception,
// due to the fact that InternalFactoryToProviderAdapter applies the binding source when
// merging errors.
if (!sources.isEmpty()
&& !messageSources.isEmpty()
&& Objects.equal(messageSources.get(0), sources.get(sources.size() - 1))) {
messageSources = messageSources.subList(1, messageSources.size());
}
return new Message(
ImmutableList.builder().addAll(sources).addAll(messageSources).build(),
message.getMessage(),
message.getCause());
}
代码示例来源:origin: com.google.inject/guice
@Override
public void addError(String message, Object... arguments) {
elements.add(new Message(getElementSource(), Errors.format(message, arguments)));
}
代码示例来源:origin: com.google.inject/guice
return new Message(Thread.currentThread(), sb.toString());
代码示例来源:origin: apache/shiro
@Test
public void testPropertySetting() throws Exception {
IMocksControl control = createControl();
TypeEncounter<SomeInjectableBean> encounter = control.createMock(TypeEncounter.class);
Provider<Injector> injectorProvider = control.createMock(Provider.class);
Injector injector = control.createMock(Injector.class);
expect(encounter.getProvider(Injector.class)).andReturn(injectorProvider);
expect(injectorProvider.get()).andReturn(injector).anyTimes();
Capture<MembersInjector<SomeInjectableBean>> capture = new Capture<MembersInjector<SomeInjectableBean>>();
encounter.register(and(anyObject(MembersInjector.class), capture(capture)));
SecurityManager securityManager = control.createMock(SecurityManager.class);
String property = "myPropertyValue";
expect(injector.getInstance(Key.get(SecurityManager.class))).andReturn(securityManager);
expect(injector.getInstance(Key.get(String.class, Names.named("shiro.myProperty")))).andReturn(property);
expect(injector.getInstance(Key.get(String.class, Names.named("shiro.unavailableProperty"))))
.andThrow(new ConfigurationException(Collections.singleton(new Message("Not Available!"))));
expect((Map)injector.getInstance(BeanTypeListener.MAP_KEY)).andReturn(Collections.EMPTY_MAP).anyTimes();
control.replay();
BeanTypeListener underTest = new BeanTypeListener();
underTest.hear(TypeLiteral.get(SomeInjectableBean.class), encounter);
SomeInjectableBean bean = new SomeInjectableBean();
capture.getValue().injectMembers(bean);
assertSame(securityManager, bean.securityManager);
assertSame(property, bean.myProperty);
assertNull(bean.unavailableProperty);
control.verify();
}
代码示例来源:origin: org.sonatype.sisu/sisu-guice
/**
* Throws a ConfigurationException with a formatted {@link Message} if this condition is {@code
* false}.
*/
static void checkConfiguration(boolean condition, String format, Object... args) {
if (condition) {
return;
}
throw new ConfigurationException(ImmutableSet.of(new Message(Errors.format(format, args))));
}
代码示例来源:origin: io.airlift/configuration
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);
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test(expectedExceptions = AuthorizationException.class)
public void testPropagateCreationExceptionAuthorizationException() throws Throwable {
Exception e = new AuthorizationException();
propagateIfPossible(
new CreationException(ImmutableSet.of(new Message(ImmutableList.of(), "Error in custom provider", e))),
ImmutableSet.<TypeToken<? extends Throwable>> of());
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGetCauseCreation() {
AuthorizationException aex = createMock(AuthorizationException.class);
Message message = new Message(ImmutableList.of(), "test", aex);
CreationException pex = new CreationException(ImmutableSet.of(message));
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), aex);
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGetFirstThrowableOfTypeFailCreation() {
TimeoutException aex = createMock(TimeoutException.class);
Message message = new Message(ImmutableList.of(), "test", aex);
CreationException pex = new CreationException(ImmutableSet.of(message));
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGetFirstThrowableOfTypeFail() {
TimeoutException aex = createMock(TimeoutException.class);
Message message = new Message(ImmutableList.of(), "test", aex);
ProvisionException pex = new ProvisionException(ImmutableSet.of(message));
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGetFirstThrowableOfTypeWhenCauseIsNullCreation() {
Message message = new Message(ImmutableList.of(), "test", null);
CreationException pex = new CreationException(ImmutableSet.of(message));
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGetFirstThrowableOfTypeWhenCauseIsNull() {
Message message = new Message(ImmutableList.of(), "test", null);
ProvisionException pex = new ProvisionException(ImmutableSet.of(message));
assertEquals(getFirstThrowableOfType(pex, AuthorizationException.class), null);
}
内容来源于网络,如有侵权,请联系作者删除!