當前位置: 首頁>>代碼示例>>Java>>正文


Java LinkedBindingBuilder類代碼示例

本文整理匯總了Java中com.google.inject.binder.LinkedBindingBuilder的典型用法代碼示例。如果您正苦於以下問題:Java LinkedBindingBuilder類的具體用法?Java LinkedBindingBuilder怎麽用?Java LinkedBindingBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


LinkedBindingBuilder類屬於com.google.inject.binder包,在下文中一共展示了LinkedBindingBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configure

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@Override
protected void configure() {
  LinkedBindingBuilder<Iterable<InetSocketAddress>> clusterBinder =
      bind(ServiceDiscoveryBindings.ZOO_KEEPER_CLUSTER_KEY);

  if (zooKeeperConfig.isInProcess()) {
    requireBinding(ShutdownRegistry.class);
    File tempDir = Files.createTempDir();
    bind(ZooKeeperTestServer.class).toInstance(new ZooKeeperTestServer(tempDir, tempDir));
    SchedulerServicesModule.addAppStartupServiceBinding(binder()).to(TestServerService.class);

    clusterBinder.toProvider(LocalZooKeeperClusterProvider.class);
  } else {
    clusterBinder.toInstance(zooKeeperConfig.getServers());
  }

  install(discoveryModule());
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:19,代碼來源:ServiceDiscoveryModule.java

示例2: configure

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@Override
protected void configure() {
    install(new ServletModule() {
        @Override
        protected void configureServlets() {
            serve("/private/healthcheck/live").with(Key.get(AbstractDaemonCheckReportServlet.class, Live.class));
            serve("/private/healthcheck").with(Key.get(AbstractDaemonCheckReportServlet.class, Background.class));
        }
    });
    bind(RuistDependencyManager.class).annotatedWith(Live.class).to(RuistDependencyManager.class).asEagerSingleton();
    bind(RuistDependencyManager.class).annotatedWith(Background.class).to(RuistDependencyManager.class).asEagerSingleton();

    final LinkedBindingBuilder<Dependency> builder = Multibinder.newSetBinder(binder(), Dependency.class).addBinding();
    for (final Class<? extends Dependency> dep : deps) {
        builder.to(dep);
    }
}
 
開發者ID:a86c6f7964,項目名稱:ruist,代碼行數:18,代碼來源:StatusWebModule.java

示例3: fileeventoptions

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings({"rawtypes", "unchecked" })
private Block fileeventoptions(final Object handler) {
  return unit -> {
    Binder binder = unit.get(Binder.class);

    FileEventOptions options;
    if (handler instanceof FileEventHandler) {
      options = unit.constructor(FileEventOptions.class)
          .args(Path.class, FileEventHandler.class)
          .build(unit.get(Path.class), handler);
    } else {
      options = unit.constructor(FileEventOptions.class)
          .args(Path.class, Class.class)
          .build(unit.get(Path.class), handler);
    }
    unit.registerMock(FileEventOptions.class, options);

    LinkedBindingBuilder lbb = unit.mock(LinkedBindingBuilder.class);
    lbb.toInstance(options);

    Multibinder mbinder = unit.mock(Multibinder.class);
    unit.mockStatic(Multibinder.class);
    expect(Multibinder.newSetBinder(binder, FileEventOptions.class)).andReturn(mbinder);
    expect(mbinder.addBinding()).andReturn(lbb);
  };
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:27,代碼來源:FileWatcherTest.java

示例4: withWPPInstance

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void withWPPInstance() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class, WebPageProvider.class)
      .expect(confWithSiteMapUrl)
      .expect(unit -> {
        LinkedBindingBuilder<WebPageProvider> lbb = unit.mock(LinkedBindingBuilder.class);
        lbb.toInstance(unit.get(WebPageProvider.class));

        Binder binder = unit.get(Binder.class);
        expect(binder.bind(Key.get(WebPageProvider.class, Names.named("/sitemap.xml"))))
            .andReturn(lbb);
      })
      .expect(handler)
      .expect(route)
      .run(unit -> {
        new Sitemap()
            .with(unit.get(WebPageProvider.class))
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:22,代碼來源:SitemapTest.java

示例5: withWPPType

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings("unchecked")
@Test
public void withWPPType() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class)
      .expect(confWithSiteMapUrl)
      .expect(unit -> {
        LinkedBindingBuilder<WebPageProvider> lbb = unit.mock(LinkedBindingBuilder.class);
        expect(lbb.to(WebPageProvider.class)).andReturn(null);

        Binder binder = unit.get(Binder.class);
        expect(binder.bind(Key.get(WebPageProvider.class, Names.named("/sitemap.xml"))))
            .andReturn(lbb);
      })
      .expect(handler)
      .expect(route)
      .run(unit -> {
        new Sitemap()
            .with(WebPageProvider.class)
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:22,代碼來源:SitemapTest.java

示例6: embeddedAccess

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings({"unchecked", "rawtypes"})
private Block embeddedAccess(final String dbkey) {
  return unit -> {
    EmbeddedDBAccess db = unit.constructor(EmbeddedDBAccess.class)
        .build();
    unit.registerMock(IDBAccess.class, db);
    db.initialize(unit.get(Properties.class));

    LinkedBindingBuilder lbb = unit.mock(LinkedBindingBuilder.class);
    lbb.toInstance(db);
    lbb.toInstance(db);

    Binder binder = unit.get(Binder.class);
    expect(binder.bind(Key.get(IDBAccess.class))).andReturn(lbb);
    expect(binder.bind(Key.get(db.getClass()))).andReturn(lbb);

    ServiceKey keys = unit.get(ServiceKey.class);
    keys.generate(eq(IDBAccess.class), eq(dbkey), unit.capture(Consumer.class));
    keys.generate(eq(db.getClass()), eq(dbkey), unit.capture(Consumer.class));
  };
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:22,代碼來源:Neo4jTest.java

示例7: dbFactory

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings("unchecked")
private Block dbFactory(final Path dbdir, final String dbkey) {
  return unit -> {
    GraphDatabaseService dbservice = unit.registerMock(GraphDatabaseService.class);
    // unit.mockStatic(RuntimeRegistry.class);
    // expect(RuntimeRegistry.getStartedRuntime(dbservice)).andReturn(null);

    LinkedBindingBuilder<GraphDatabaseService> lbb = unit.mock(LinkedBindingBuilder.class);
    lbb.toInstance(dbservice);

    Binder binder = unit.get(Binder.class);
    expect(binder.bind(Key.get(GraphDatabaseService.class))).andReturn(lbb);

    ServiceKey keys = unit.get(ServiceKey.class);
    keys.generate(eq(GraphDatabaseService.class), eq(dbkey), unit.capture(Consumer.class));

    GraphDatabaseBuilder dbbuilder = unit.registerMock(GraphDatabaseBuilder.class);
    expect(dbbuilder.newGraphDatabase()).andReturn(dbservice);

    GraphDatabaseFactory factory = unit.constructor(GraphDatabaseFactory.class)
        .build();
    expect(factory.setUserLogProvider(isA(Slf4jLogProvider.class))).andReturn(factory);
    expect(factory.newEmbeddedDatabaseBuilder(dbdir.toFile())).andReturn(dbbuilder);
  };
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:26,代碼來源:Neo4jTest.java

示例8: defaultUse

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings({"unchecked" })
@Test
public void defaultUse() throws Exception {
  Map<JobDetail, Trigger> jobs = Collections.emptyMap();
  new MockUnit(Env.class, Config.class, Binder.class, LinkedBindingBuilder.class)
      .expect(unit -> {
        unit.mockStatic(JobExpander.class);
        expect(JobExpander.jobs(unit.get(Config.class), Arrays.asList(Job.class)))
            .andReturn(jobs);
      })
      .expect(scheduler)
      .expect(jobUnit)
      .expect(unit -> {
        LinkedBindingBuilder<Map<JobDetail, Trigger>> namedJobsBB = unit
            .get(LinkedBindingBuilder.class);
        namedJobsBB.toInstance(jobs);
      })
      .expect(onManaged)
      .run(unit -> {
        new Quartz(Job.class)
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:24,代碼來源:QuartzTest.java

示例9: withJob

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings({"unchecked" })
@Test
public void withJob() throws Exception {
  Map<JobDetail, Trigger> jobs = Collections.emptyMap();
  new MockUnit(Env.class, Config.class, Binder.class, LinkedBindingBuilder.class)
      .expect(unit -> {
        unit.mockStatic(JobExpander.class);
        expect(JobExpander.jobs(unit.get(Config.class), Arrays.asList(Job.class)))
            .andReturn(jobs);
      })
      .expect(scheduler)
      .expect(jobUnit)
      .expect(unit -> {
        LinkedBindingBuilder<Map<JobDetail, Trigger>> namedJobsBB = unit
            .get(LinkedBindingBuilder.class);
        namedJobsBB.toInstance(jobs);
      })
      .expect(onManaged)
      .run(unit -> {
        new Quartz()
            .with(Job.class)
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:25,代碼來源:QuartzTest.java

示例10: bindEntityStore

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void bindEntityStore() throws Exception {
  Key k = Key.get(Object.class);
  new MockUnit(Env.class, Config.class, Binder.class, EntityModel.class)
      .expect(newDataSource(true))
      .expect(keys)
      .expect(zeroModels)
      .expect(store(EntityStore.class, "DEFAULT"))
      .expect(onStart)
      .expect(unit -> {
        LinkedBindingBuilder lbb = unit.mock(LinkedBindingBuilder.class);
        lbb.toInstance(isA(EntityStore.class));
        Binder binder = unit.get(Binder.class);
        expect(binder.bind(k)).andReturn(lbb);
      })
      .run(unit -> {
        new Requery(unit.get(EntityModel.class))
            .configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
      }, unit -> {
        unit.captured(Consumer.class).iterator().next().accept(k);
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:24,代碼來源:RequeryTest.java

示例11: newInstance

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
@SuppressWarnings({"rawtypes", "unchecked" })
@Test
public void newInstance() throws Exception {
  new MockUnit(Env.class, Config.class, Binder.class)
      .expect(unit -> {
        RockerRenderer renderer = unit.constructor(RockerRenderer.class)
            .build("", ".rocker.html");
        Binder binder = unit.get(Binder.class);
        unit.mockStatic(Multibinder.class);
        Multibinder mb = unit.mock(Multibinder.class);
        LinkedBindingBuilder lbb = unit.mock(LinkedBindingBuilder.class);
        lbb.toInstance(renderer);
        expect(mb.addBinding()).andReturn(lbb);
        expect(Multibinder.newSetBinder(binder, Renderer.class)).andReturn(mb);
      })
      .run(unit -> {
        new Rockerby().configure(unit.get(Env.class), unit.get(Config.class),
            unit.get(Binder.class));
      });
}
 
開發者ID:jooby-project,項目名稱:jooby,代碼行數:21,代碼來源:RockerbyTest.java

示例12: bindRootElementParser

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
/**
 * Bind the given key to an {@link ElementParser<T>}, which will be applied to
 * the root {@link Element} of the {@link Document} at parse-time, and the
 * result bound in {@link MapScoped}.
 */
default <T> LinkedBindingBuilder<ElementParser<T>> bindRootElementParser(Key<T> key) {
    install(new ProvisionAtParseTime<>(key));
    bind(key).toProvider(new ResolvableType<RootElementParsingProvider<T>>(){}
                             .with(new TypeArgument<T>(key.getTypeLiteral()){}))
             .in(MapScoped.class);
    return bindElementParser(key);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:13,代碼來源:MapBinders.java

示例13: setupBullshit

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
private static void setupBullshit()
{
	Injector injector = Guice.createInjector(new Module()
	{
		@SuppressWarnings({"unchecked", "nls"})
		@Override
		public void configure(Binder arg0)
		{
			arg0.bind(PluginService.class).toInstance(new FakePluginService());
			ParameterizedType type = Types.newParameterizedType(PluginTracker.class, SectionsConverter.class);
			TrackerProvider<SectionsConverter> trackerProvider = new TrackerProvider<SectionsConverter>(
				"", "", "")
			{
				@Override
				public PluginTracker<SectionsConverter> get()
				{
					return new FakePluginTracker();
				}
			};

			TypeLiteral<PluginTracker<SectionsConverter>> typeLiteral = (TypeLiteral<PluginTracker<SectionsConverter>>) TypeLiteral
				.get(type);
			LinkedBindingBuilder<PluginTracker<SectionsConverter>> bindingBuilder = arg0.bind(typeLiteral);
			bindingBuilder.toProvider(trackerProvider).in(Scopes.SINGLETON);
		}
	});
	injector.getInstance(Conversion.class);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:29,代碼來源:ObjectExpressionDeserialiserTest.java

示例14: bindTracker

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的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

示例15: bindConfigProperties

import com.google.inject.binder.LinkedBindingBuilder; //導入依賴的package包/類
/**
 * Binds individual flattened key-value properties in the configuration yml
 * file. So one can directly inject something like this:
 *
 * @Named("Hibernate.hibernate.jdbcDriver") String jdbcDriver OR
 * @Named("Dashboard.service.port") int port
 */
@SuppressWarnings({"rawtypes", "unchecked"})
private void bindConfigProperties() {
    bind(YamlConfiguration.class).toInstance(yamlConfiguration);
    Iterator<String> propertyKeys = yamlConfiguration.getKeys();
    while (propertyKeys.hasNext()) {
        String propertyKey = propertyKeys.next();
        Object propertyValue = yamlConfiguration.getProperty(propertyKey);
        LinkedBindingBuilder annotatedWith = bind(propertyValue.getClass()).annotatedWith(Names.named(propertyKey));
        annotatedWith.toInstance(propertyValue);
    }
}
 
開發者ID:flipkart-incubator,項目名稱:flux,代碼行數:19,代碼來源:ConfigModule.java


注:本文中的com.google.inject.binder.LinkedBindingBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。