当前位置: 首页>>代码示例>>Java>>正文


Java AnnotatedBindingBuilder类代码示例

本文整理汇总了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));
}
 
开发者ID:Twister915,项目名称:pl,代码行数:17,代码来源:BukkitModule.java

示例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;
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:23,代码来源:ExtendTestGuiceModule.java

示例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;
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:19,代码来源:TestDriver.java

示例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);
    }
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:17,代码来源:CouchbaseTest.java

示例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);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:24,代码来源:Pac4jTest.java

示例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);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:17,代码来源:HbmTest.java

示例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);
    }
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:22,代码来源:JdbcTest.java

示例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);
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:8,代码来源:AbstractTestModule.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:16,代码来源:PluginTrackerModule.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:AbstractAntlrXtendGeneratorFragment.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:DefaultGeneratorModule.java

示例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);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:13,代码来源:WebSecurityModule.java

示例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);
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:9,代码来源:WebSecurityModule.java

示例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);
}
 
开发者ID:gitblit,项目名称:fathom,代码行数:12,代码来源:ServletsModule.java

示例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);
    }
}
 
开发者ID:CIDARLAB,项目名称:clotho3crud,代码行数:10,代码来源:NoSecurityModule.java


注:本文中的com.google.inject.binder.AnnotatedBindingBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。