本文整理汇总了Java中com.google.inject.binder.AnnotatedBindingBuilder类的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedBindingBuilder类的具体用法?Java AnnotatedBindingBuilder怎么用?Java AnnotatedBindingBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnnotatedBindingBuilder类属于com.google.inject.binder包,在下文中一共展示了AnnotatedBindingBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configure
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void configure() {
install(new CloseableModule());
install(new Jsr250Module());
install(new ParserModule());
install(new RxAccessorModule());
install(new RxBukkitSchedulerModule());
install(new ParserModule());
bind(JPl.class).toInstance(plugin);
bind(Plugin.class).toInstance(plugin);
((AnnotatedBindingBuilder) bind(plugin.getClass())).toInstance(plugin);
install(binder -> plugin.configure(binder::install));
}
示例2: bind
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
protected void bind(BindDescriptor bindDescriptor, BindType bindType) {
switch (bindType) {
case SIMPLE:
AnnotatedBindingBuilder<?> builder = null;
if (bindDescriptor.getBind() != null) {
builder = bind(bindDescriptor.getBind());
if (bindDescriptor.getTo() != null) {
builder.to(bindDescriptor.getTo());
}
if (bindDescriptor.getIn() != null) {
builder.in(bindDescriptor.getIn());
}
}
break;
case MOCK:
bindToMock(bindDescriptor);
break;
case SPY:
bindToSpy(bindDescriptor);
break;
}
}
示例3: newModuleList
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
private static List<Module> newModuleList(final Application app, final Class<? extends Application> appClass,
Module... guiceModules) {
List<Module> lst = new LinkedList<>();
lst.addAll(Arrays.asList(guiceModules));
lst.add(new AbstractModule() {
@Override
public void configure() {
AnnotatedBindingBuilder<Application> builder = bind(Application.class);
if (app != null) {
builder.toInstance(app);
} else {
builder.to(appClass);
}
}
});
return lst;
}
示例4: bind
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
private Block bind(final String name, final Class type) {
return unit -> {
Object value = unit.get(type);
AnnotatedBindingBuilder abbce = unit.mock(AnnotatedBindingBuilder.class);
abbce.toInstance(value);
Binder binder = unit.get(Binder.class);
if (name == null) {
expect(binder.bind(Key.get(type))).andReturn(abbce);
} else {
expect(binder.bind(Key.get(type, Names.named(name)))).andReturn(abbce);
}
};
}
示例5: sessionStore
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
private MockUnit.Block sessionStore(SessionStore<WebContext> ss) {
return unit -> {
org.pac4j.core.config.Config config = unit.get(org.pac4j.core.config.Config.class);
expect(config.getSessionStore()).andReturn(ss);
if (ss != null) {
config.setSessionStore(ss);
}
AnnotatedBindingBuilder aab = unit.mock(AnnotatedBindingBuilder.class);
if (ss == null) {
expect(aab.to(Pac4jSessionStore.class)).andReturn(aab);
expect(aab.to(Pac4jSessionStore.class)).andReturn(aab);
} else {
aab.toInstance(ss);
aab.toInstance(ss);
}
Binder binder = unit.get(Binder.class);
expect(binder.bind(SSTORE)).andReturn(aab);
expect(binder.bind(SessionStore.class)).andReturn(aab);
};
}
示例6: serviceKey
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Block serviceKey(final String db) {
return unit -> {
Env env = unit.get(Env.class);
ServiceKey skey = new Env.ServiceKey();
expect(env.serviceKey()).andReturn(skey).times(2);
AnnotatedBindingBuilder<DataSource> binding = unit.mock(AnnotatedBindingBuilder.class);
binding.toInstance(unit.get(HikariDataSource.class));
binding.toInstance(unit.get(HikariDataSource.class));
Binder binder = unit.get(Binder.class);
expect(binder.bind(Key.get(DataSource.class))).andReturn(binding);
expect(binder.bind(Key.get(DataSource.class, Names.named(db)))).andReturn(binding);
};
}
示例7: serviceKey
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Block serviceKey(final String db, String dbtype) {
return unit -> {
Env env = unit.get(Env.class);
expect(env.serviceKey()).andReturn(new Env.ServiceKey());
AnnotatedBindingBuilder<DataSource> binding = unit.mock(AnnotatedBindingBuilder.class);
binding.toInstance(unit.get(HikariDataSource.class));
binding.toInstance(unit.get(HikariDataSource.class));
Binder binder = unit.get(Binder.class);
expect(binder.bind(Key.get(DataSource.class))).andReturn(binding);
expect(binder.bind(Key.get(DataSource.class, Names.named(db)))).andReturn(binding);
expect(env.set(Key.get(DataSource.class), unit.get(HikariDataSource.class))).andReturn(env);
expect(env.set(Key.get(DataSource.class, Names.named(db)), unit.get(HikariDataSource.class)))
.andReturn(env);
if (dbtype != null) {
expect(env.set(Key.get(String.class, Names.named(db + ".dbtype")), dbtype)).andReturn(env);
}
};
}
示例8: bind
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
public <T> AnnotatedBindingBuilder<T> bind(final Class<T> clazz) {
if (isIgnoreClass(clazz)) {
return new NullAnnotatedBindingBuilder<T>();
} else {
return binder.bind(clazz);
}
}
示例9: bindTracker
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
protected <T> TrackerProvider<T> bindTracker(java.lang.reflect.Type typeParam, Annotation annotatedWith,
String extensionPoint, String beanParameter)
{
ParameterizedType type = Types.newParameterizedType(PluginTracker.class, typeParam);
TrackerProvider<T> trackerProvider = new TrackerProvider<T>(getPluginId(), extensionPoint, beanParameter);
@SuppressWarnings("unchecked")
TypeLiteral<PluginTracker<T>> typeLiteral = (TypeLiteral<PluginTracker<T>>) TypeLiteral.get(type);
LinkedBindingBuilder<PluginTracker<T>> bindingBuilder = bind(typeLiteral);
if( annotatedWith != null )
{
bindingBuilder = ((AnnotatedBindingBuilder<PluginTracker<T>>) bindingBuilder).annotatedWith(annotatedWith);
}
bindingBuilder.toProvider(trackerProvider).in(Scopes.SINGLETON);
return trackerProvider;
}
示例10: createModule
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
protected com.google.inject.Module createModule(final Grammar grammar) {
final com.google.inject.Module _function = (Binder binder) -> {
binder.<Grammar>bind(Grammar.class).toInstance(grammar);
binder.<Naming>bind(Naming.class).toInstance(this.getNaming());
AnnotatedBindingBuilder<IGrammarAccess> _bind = binder.<IGrammarAccess>bind(IGrammarAccess.class);
Xtend2GeneratorFragment.GenericGrammarAccess _genericGrammarAccess = new Xtend2GeneratorFragment.GenericGrammarAccess(grammar);
_bind.toInstance(_genericGrammarAccess);
this.addLocalBindings(binder);
};
return _function;
}
示例11: configureIEncodingProvider
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
public void configureIEncodingProvider(final Binder binder) {
AnnotatedBindingBuilder<IEncodingProvider> _bind = binder.<IEncodingProvider>bind(IEncodingProvider.class);
IEncodingProvider.Runtime _runtime = new IEncodingProvider.Runtime();
final Procedure1<IEncodingProvider.Runtime> _function = (IEncodingProvider.Runtime it) -> {
it.setDefaultEncoding(this.code.getEncoding());
};
IEncodingProvider.Runtime _doubleArrow = ObjectExtensions.<IEncodingProvider.Runtime>operator_doubleArrow(_runtime, _function);
_bind.toInstance(_doubleArrow);
}
示例12: bindWebSecurityManager
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
@Override
protected void bindWebSecurityManager(final AnnotatedBindingBuilder<? super WebSecurityManager> bind) {
bind(NexusWebSecurityManager.class).asEagerSingleton();
// bind RealmSecurityManager and WebSecurityManager to _same_ component
bind(RealmSecurityManager.class).to(NexusWebSecurityManager.class);
bind.to(NexusWebSecurityManager.class);
// bindings used by external modules
expose(RealmSecurityManager.class);
expose(WebSecurityManager.class);
}
示例13: bindSessionManager
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
@Override
protected void bindSessionManager(final AnnotatedBindingBuilder<SessionManager> bind) {
// use native web session management instead of delegating to servlet container
// workaround for NEXUS-5727, see NexusDefaultWebSessionManager javadoc for clues
bind.to(NexusWebSessionManager.class).asEagerSingleton();
// this is a PrivateModule, so explicitly binding the NexusDefaultSessionManager class
bind(NexusWebSessionManager.class);
}
示例14: bind
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
/**
* @see com.google.inject.Binder#bind(Class)
*/
@Override
protected <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz) {
if (Service.class.isAssignableFrom(clazz)) {
Class<? extends Service> serviceClass = (Class<? extends Service>) clazz;
services.register(serviceClass);
}
return binder().bind(clazz);
}
示例15: bindWebSecurityManager
import com.google.inject.binder.AnnotatedBindingBuilder; //导入依赖的package包/类
@Override
protected void bindWebSecurityManager(AnnotatedBindingBuilder<? super WebSecurityManager> bind) {
try {
// bind.toConstructor(PermissiveSecurityManager.class.getConstructor(Collection.class)).asEagerSingleton();
bind.toConstructor(PermissiveSecurityManager.class.getConstructor(Collection.class)).asEagerSingleton();
} catch (NoSuchMethodException e) {
throw new ConfigurationException("This really shouldn't happen. Either something has changed in Shiro, or there's a bug in ShiroModule.", e);
}
}