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


Java Binder类代码示例

本文整理汇总了Java中com.google.inject.Binder的典型用法代码示例。如果您正苦于以下问题:Java Binder类的具体用法?Java Binder怎么用?Java Binder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Binder类属于com.google.inject包,在下文中一共展示了Binder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beanBind

import com.google.inject.Binder; //导入依赖的package包/类
/**
 * auto bind interface impl
 *
 * @param binder
 */
private void beanBind(Binder binder) {

    List<Class> classes = ClassScanner.scanClassByAnnotation(Bean.class, true);
    for (Class impl : classes) {
        Class<?>[] interfaceClasses = impl.getInterfaces();
        Bean bean = (Bean) impl.getAnnotation(Bean.class);
        String name = bean.name();
        for (Class interfaceClass : interfaceClasses) {
            if (interfaceClass == Serializable.class) {
                continue;
            }
            try {
                if (StringUtils.isBlank(name)) {
                    binder.bind(interfaceClass).to(impl);
                } else {
                    binder.bind(interfaceClass).annotatedWith(Names.named(name)).to(impl);
                }
            } catch (Throwable ex) {
                System.err.println(String.format("can not bind [%s] to [%s]", interfaceClass, impl));
            }
        }
    }
}
 
开发者ID:yangfuhai,项目名称:jboot,代码行数:29,代码来源:JbootInjectManager.java

示例2: configurePanoptes

import com.google.inject.Binder; //导入依赖的package包/类
private void configurePanoptes(Binder binder) {
    String endpoint = config.getString("panoptes.service.url");
    String clientSecret = config.getString("panoptes.service.client.secret");
    Duration timeout = config.getDuration("panoptes.service.timeout");
    PanoptesWebServiceFactory factory = new PanoptesWebServiceFactory(endpoint, timeout);
    RetrofitServiceFactory authFactory = new BasicJWTAuthServiceFactorySC(endpoint, timeout);
    AuthService authService = new BasicJWTAuthService(authFactory,
            new Authorization("APIKEY", clientSecret));
    binder.bind(String.class)
            .annotatedWith(Names.named("PANOPTES_ENDPOINT"))
            .toInstance(endpoint);
    binder.bind(AuthService.class)
            .annotatedWith(Names.named("PANOPTES_AUTH"))
            .toInstance(authService);
    PanoptesService service = new PanoptesService(factory, authService);
    binder.bind(Long.class)
            .annotatedWith(Names.named("PANOPTES_TIMEOUT"))
            .toInstance(timeout.toMillis());
    binder.bind(PanoptesWebServiceFactory.class).toInstance(factory);
    binder.bind(ImageArchiveService.class).toInstance(service);

}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:23,代码来源:MBARIInjectorModule.java

示例3: setUp

import com.google.inject.Binder; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
  final RMContext mockRMContext =
      TestRMWebApp.mockRMContext(3, numberOfRacks, numberOfNodesPerRack,
        8 * TestRMWebApp.GiB);
  injector =
      WebAppTests.createMockInjector(RMContext.class, mockRMContext,
        new Module() {
          @Override
          public void configure(Binder binder) {
            try {
              binder.bind(ResourceManager.class).toInstance(
                TestRMWebApp.mockRm(mockRMContext));
            } catch (IOException e) {
              throw new IllegalStateException(e);
            }
          }
        });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestNodesPage.java

示例4: DynamicAnnouncementBinder

import com.google.inject.Binder; //导入依赖的package包/类
protected DynamicAnnouncementBinder(Binder binder)
{
    keyBinder = newSetBinder(binder,
            SERVICE_PROPERTY_TYPE,
            ForDynamicAnnouncements.class);
    getterBinder = newMapBinder(binder,
            SERVICE_PROPERTY_TYPE,
            new TypeLiteral<Function<Object, String>>() {},
            ForDynamicAnnouncements.class);
    objectBinder = newMapBinder(binder,
            SERVICE_PROPERTY_TYPE,
            new TypeLiteral<Object>() {},
            ForDynamicAnnouncements.class);
}
 
开发者ID:prestodb,项目名称:presto-manager,代码行数:15,代码来源:DynamicAnnouncementBinder.java

示例5: configure

import com.google.inject.Binder; //导入依赖的package包/类
@Override
public void configure(Binder binder)
{
    binder.bind(ThriftCodecFactory.class).to(CompilerThriftCodecFactory.class).in(Scopes.SINGLETON);
    binder.bind(ThriftCatalog.class).in(Scopes.SINGLETON);
    binder.bind(ThriftCodecManager.class).in(Scopes.SINGLETON);
    newSetBinder(binder, new TypeLiteral<ThriftCodec<?>>() {}, InternalThriftCodec.class).permitDuplicates();

    binder.bind(ClassLoader.class)
            .annotatedWith(ForCompiler.class)
            .toInstance(parent);
}
 
开发者ID:airlift,项目名称:drift,代码行数:13,代码来源:ThriftCodecModule.java

示例6: configure

import com.google.inject.Binder; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
  try (InputStream is1 = ClassLoader
      .getSystemResourceAsStream("test-config.xml")) {
    WxXmlCpInMemoryConfigStorage config = fromXml(
        WxXmlCpInMemoryConfigStorage.class, is1);
    WxCpServiceImpl wxService = new WxCpServiceImpl();
    wxService.setWxCpConfigStorage(config);

    binder.bind(WxCpServiceImpl.class).toInstance(wxService);
    binder.bind(WxCpConfigStorage.class).toInstance(config);
  } catch (IOException e) {
    e.printStackTrace();
  }
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:16,代码来源:ApiTestModule.java

示例7: create

import com.google.inject.Binder; //导入依赖的package包/类
/**
 * Creates a new duplex binder.
 *
 * @param binder the enclosing (public) binder
 * @return a new duplex binder
 */
@NonNull
static DuplexBinder create(@NonNull final Binder binder) {
  if(binder instanceof DuplexBinder) {
    return (DuplexBinder) binder;
  }
  return new DuplexBinderImpl(binder, binder.newPrivateBinder());
}
 
开发者ID:KyoriPowered,项目名称:violet,代码行数:14,代码来源:DuplexBinder.java

示例8: configure

import com.google.inject.Binder; //导入依赖的package包/类
@Override
public void configure(Binder binder)
{
    httpClientBinder(binder).addGlobalFilterBinding()
            .to(DynamicAnnouncementFilter.class)
            .asEagerSingleton();

    jsonCodecBinder(binder).bindJsonCodec(JsonAnnouncement.class);

    // Initialize various multibinders
    DynamicAnnouncementBinder.dynamicAnnouncementBinder(binder);
}
 
开发者ID:prestodb,项目名称:presto-manager,代码行数:13,代码来源:DynamicAnnouncementModule.java

示例9: configure

import com.google.inject.Binder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void configure(Binder binder) {
	try {
		// try to instantiate platform specific implementation
		// will fail currently on Mac, thus the binding does not happen there
		Class<? extends ISolidityCompiler> solidityCompilerClass = (Class<? extends ISolidityCompiler>) Class
				.forName("com.yakindu.solidity.compiler.builder.SolidityCompiler");
		binder.bind(ISolidityCompiler.class).to(solidityCompilerClass);
	} catch (ClassNotFoundException e) {
		System.err.println("SolidityCompilerModule: " + e.getMessage());
	}
	binder.bind(IPreferenceStore.class)
			.toInstance((IPreferenceStore) SolidityActivator.getInstance().getPreferenceStore());
}
 
开发者ID:Yakindu,项目名称:solidity-ide,代码行数:16,代码来源:SolidityCompilerModule.java

示例10: configure

import com.google.inject.Binder; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
    binder.bind(ActionMapping.class).toInstance(new ActionMapping());
    binder.bind(ActionHandler.class).toInstance(new ActionHandler());

    binder.bind(ViewFactory.class).to(DefaultViewFactory.class).in(Singleton.class);
    binder.bind(ViewResolver.class).to(DefaultViewResolver.class).in(Singleton.class);

    configureCaptcha(binder);
}
 
开发者ID:Xlongshu,项目名称:EasyController,代码行数:11,代码来源:ActionModule.java

示例11: ListProvider

import com.google.inject.Binder; //导入依赖的package包/类
public ListProvider(Binder binder, List<Class<? extends T>> clazzes)
{
	this.binder = binder;
	this.clazzes.addAll(clazzes);
	for( Class<? extends T> clazz : clazzes )
	{
		binder.bind(clazz);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:ListProvider.java

示例12: configureContentProposalLabelProvider

import com.google.inject.Binder; //导入依赖的package包/类
/**
 * Binds a specific label provider for the content assist use case.
 */
@Override
public void configureContentProposalLabelProvider(com.google.inject.Binder binder) {
	binder.bind(org.eclipse.jface.viewers.ILabelProvider.class)
			.annotatedWith(org.eclipse.xtext.ui.editor.contentassist.ContentProposalLabelProvider.class)
			.to(N4JSContentAssistLabelProvider.class);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:N4JSUiModule.java

示例13: SetBinder

import com.google.inject.Binder; //导入依赖的package包/类
protected SetBinder(Binder binder, @Nullable Key<T> key) {
    if(key == null) {
        key = Key.get(new ResolvableType<T>(){}.in(getClass()));
    }

    this.binder = binder.skipSources(SetBinder.class);
    this.elementType = key.getTypeLiteral();
    this.collectionType = new ResolvableType<Set<T>>(){}.with(new TypeArgument<T>(this.elementType){});
    this.multibinder = Multibinder.newSetBinder(binder, key);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:SetBinder.java

示例14: configure

import com.google.inject.Binder; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
    binder.bind(EthereumConnector.class).in(Scopes.SINGLETON);
    binder.bind(EthereumMetadata.class).in(Scopes.SINGLETON);
    binder.bind(EthereumWeb3jProvider.class).in(Scopes.SINGLETON);

    binder.bind(EthereumSplitManager.class).in(Scopes.SINGLETON);
    binder.bind(EthereumRecordSetProvider.class).in(Scopes.SINGLETON);

    configBinder(binder).bindConfig(EthereumConnectorConfig.class);
    jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
}
 
开发者ID:xiaoyao1991,项目名称:presto-ethereum,代码行数:13,代码来源:EthereumConnectorModule.java

示例15: configureConceptService

import com.google.inject.Binder; //导入依赖的package包/类
private void configureConceptService(Binder binder) {
    String endpoint = config.getString("concept.service.url");
    Duration timeout = config.getDuration("concept.service.timeout");
    KBWebServiceFactory factory = new KBWebServiceFactory(endpoint, timeout, defaultExecutor);
    KBConceptService service = new KBConceptService(factory);
    // --- Using a local cache
    CachedConceptService cachedService = new CachedConceptService(service);
    List<String> cachedConceptTemplates = config.getStringList("app.annotation.details.cache");
    cachedService.prefetch(cachedConceptTemplates);
    binder.bind(String.class)
            .annotatedWith(Names.named("CONCEPT_ENDPOINT"))
            .toInstance(endpoint);
    binder.bind(KBWebServiceFactory.class).toInstance(factory);
    binder.bind(ConceptService.class).toInstance(cachedService);
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:16,代码来源:MBARIInjectorModule.java


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