本文整理汇总了Java中com.google.inject.util.Providers类的典型用法代码示例。如果您正苦于以下问题:Java Providers类的具体用法?Java Providers怎么用?Java Providers使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Providers类属于com.google.inject.util包,在下文中一共展示了Providers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newIsisWicketModule
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(ComponentFactoryRegistrar.class).to(MyComponentFactoryRegistrar.class);
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("RotaBuilder");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("RotaBuilder");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
// if uncommented, then overrides isis.appManifest in config file.
// bind(AppManifest.class).toInstance(new DomainAppAppManifest());
}
};
return Modules.override(isisDefaults).with(overrides);
}
示例2: newIsisWicketModule
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("SiGeSe");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/about/images/login.png");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("SiGeSe");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
};
return Modules.override(isisDefaults).with(overrides);
}
示例3: Formatter
import com.google.inject.util.Providers; //导入依赖的package包/类
Formatter(final String pattern) {
final List<String> patterns = Splitter.on(VAR_BEGIN).omitEmptyStrings().splitToList(pattern);
patterns.forEach(pt -> {
if (!pt.contains(VAR_END)) {
appenderList.add(Providers.of(pt));
} else {
StringTokenizer token = new StringTokenizer(pt, VAR_END);
String guiceKey = token.nextToken();
String rawString = null;
if (token.hasMoreTokens()) {
rawString = token.nextToken();
}
final KeyResolver resolver = new KeyResolver(guiceKey);
appenderList.add(resolver);
resolvers.add(resolver);
appenderList.add(Providers.of(rawString));
}
});
}
示例4: newIsisWicketModule
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Food App");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Food App");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
// if uncommented, then overrides isis.appManifest in config file.
// bind(AppManifest.class).toInstance(new DomainAppAppManifest());
}
};
return Modules.override(isisDefaults).with(overrides);
}
示例5: constructor_does_not_blow_up_if_metricsListener_is_null
import com.google.inject.util.Providers; //导入依赖的package包/类
@Test
public void constructor_does_not_blow_up_if_metricsListener_is_null() {
// given
AppServerConfig asc = new AppServerConfig(configForTesting) {
@Override
protected List<Module> getAppGuiceModules(Config appConfig) {
return Arrays.asList(
Modules.override(new AppGuiceModule(appConfig)).with(
binder -> binder
.bind(new TypeLiteral<CodahaleMetricsListener>() {})
.toProvider(Providers.of(null))),
new BackstopperRiposteConfigGuiceModule()
);
}
};
// expect
assertThat(asc.metricsListener()).isNull();
}
示例6: newIsisWicketModule
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("ECP CRM");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
// bind(String.class).annotatedWith(Names.named("brandLogoHeader")).toInstance("/images/domainapp-logo-header.png");
// bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/images/domainapp-logo-signin.png");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("ECP CRM");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
};
return Modules.override(isisDefaults).with(overrides);
}
示例7: configurePersistence
import com.google.inject.util.Providers; //导入依赖的package包/类
protected void configurePersistence() {
bind(String[].class).annotatedWith(Neo4j.class).toInstance(packages);
if (null != properties) {
bind(Properties.class).annotatedWith(Neo4j.class).toInstance(properties);
} else {
bind(Properties.class).annotatedWith(Neo4j.class).toProvider(Providers.of(null));
}
bind(Neo4jPersistService.class).in(Singleton.class);
bind(PersistService.class).to(Neo4jPersistService.class);
bind(UnitOfWork.class).to(Neo4jPersistService.class);
bind(Session.class).toProvider(Neo4jPersistService.class);
transactionInterceptor = new Neo4jLocalTxnInterceptor();
requestInjection(transactionInterceptor);
}
示例8: testGuicify330Provider
import com.google.inject.util.Providers; //导入依赖的package包/类
public void testGuicify330Provider() {
Provider<String> jsr330Provider = new Provider<String>() {
@Override
public String get() {
return "A";
}
@Override
public String toString() {
return "jsr330Provider";
}
};
com.google.inject.Provider<String> guicified = Providers
.guicify(jsr330Provider);
assertEquals("guicified(jsr330Provider)", guicified.toString());
assertEquals("A", guicified.get());
// when you guicify the Guice-friendly, it's a no-op
assertSame(guicified, Providers.guicify(guicified));
}
示例9: testBindToInjectorWithListeningGivesSaneException
import com.google.inject.util.Providers; //导入依赖的package包/类
public void testBindToInjectorWithListeningGivesSaneException() {
try {
Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bindListener(Matchers.any(), new Counter());
bind(Injector.class)
.toProvider(Providers.<Injector> of(null));
}
});
fail();
} catch (SaltaException ce) {
assertContains(ce.getMessage(),
"Binding to core guice framework type is not allowed: Injector.");
}
}
示例10: testBindingToProvider
import com.google.inject.util.Providers; //导入依赖的package包/类
@Test
public void testBindingToProvider() {
try {
Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bind(new TypeLiteral<Provider<String>>() {
}).toInstance(Providers.of("A"));
}
});
fail();
} catch (SaltaException expected) {
assertContains(expected.getMessage(),
"Binding to core guice framework type is not allowed: Provider.");
}
}
示例11: configure
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected void configure() {
bind(AbstractModule.class).annotatedWith(red)
.toProvider(Providers.<AbstractModule> of(null));
bind(Binder.class).annotatedWith(red)
.toProvider(Providers.<Binder> of(null));
bind(Binding.class).annotatedWith(red)
.toProvider(Providers.<Binding> of(null));
bind(Injector.class).annotatedWith(red)
.toProvider(Providers.<Injector> of(null));
bind(Key.class).annotatedWith(red)
.toProvider(Providers.<Key> of(null));
bind(Module.class).annotatedWith(red)
.toProvider(Providers.<Module> of(null));
bind(Provider.class).annotatedWith(red)
.toProvider(Providers.<Provider> of(null));
bind(Scope.class).annotatedWith(red)
.toProvider(Providers.<Scope> of(null));
bind(Stage.class).annotatedWith(red)
.toProvider(Providers.<Stage> of(null));
bind(TypeLiteral.class).annotatedWith(red)
.toProvider(Providers.<TypeLiteral> of(null));
bind(new TypeLiteral<Key<String>>() {
}).toProvider(Providers.<Key<String>> of(null));
}
示例12: configure
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override protected void configure() {
bind(CliConfiguration.class).toInstance(config);
bind(JCommander.class).annotatedWith(Names.named("ParentCommander"))
.toInstance(parentCommander);
if (commander == null) {
bind(JCommander.class).annotatedWith(Names.named("Commander"))
.toProvider(Providers.of((JCommander) null));
bind(String.class).annotatedWith(Names.named("Command"))
.toProvider(Providers.of((String) null));
} else {
bind(JCommander.class).annotatedWith(Names.named("Commander")).toInstance(commander);
bindConstant().annotatedWith(Names.named("Command")).to(command);
}
bind(Map.class).annotatedWith(Names.named("CommandMap")).toInstance(commands);
}
示例13: newIsisWicketModule
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Domain App");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("brandLogoHeader")).toInstance("/images/domainapp-logo-header.png");
bind(String.class).annotatedWith(Names.named("brandLogoSignin")).toInstance("/images/domainapp-logo-signin.png");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Domain App");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
};
return Modules.override(isisDefaults).with(overrides);
}
示例14: newIsisWicketModule
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Simple App");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Simple App");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
// if uncommented, then overrides isis.appManifest in config file.
// bind(AppManifest.class).toInstance(new DomainAppAppManifest());
}
};
return Modules.override(isisDefaults).with(overrides);
}
示例15: newIsisWicketModule
import com.google.inject.util.Providers; //导入依赖的package包/类
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance(" Mejorar ");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance(" Mejorar ");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
};
return Modules.override(isisDefaults).with(overrides);
}