當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。