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


Java PrivateModule類代碼示例

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


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

示例1: module

import com.google.inject.PrivateModule; //導入依賴的package包/類
public static <C> PrivateModule module(final PropertyIdentifier propertyIdentifier, final ConfigDescriptor desc)
{
    return new PrivateModule()
    {
        @Override
        protected void configure()
        {
            // Alias the private module scoped bindings for the un-annotated ConstantValuePropertyAccessor and PropertyIdentifier to globally scoped and annotated ones.
            // Intent here is to make the implementation of this nice and guicified but support a number of different instances.
            bind(ConstantValuePropertyAccessor.class).to(Key.get(ConstantValuePropertyAccessor.class, propertyIdentifier));
            bind(PropertyIdentifier.class).to(Key.get(PropertyIdentifier.class, propertyIdentifier));

            TypeLiteral<PropertyAccessor<C>> accessorType = (TypeLiteral<PropertyAccessor<C>>) TypeLiteral.get(Types.newParameterizedType(PropertyAccessor.class, desc.getConfigType()));
            bind(Key.get(accessorType, propertyIdentifier)).to(accessorType).in(Scopes.SINGLETON);
            expose(Key.get(accessorType, propertyIdentifier));
        }
    };
}
 
開發者ID:kikinteractive,項目名稱:ice,代碼行數:19,代碼來源:PropertyAccessor.java

示例2: configure

import com.google.inject.PrivateModule; //導入依賴的package包/類
@Override
protected void configure() {
  install(new PrivateModule() {
    @Override
    protected void configure() {
      bind(ScheduledExecutorService.class).toInstance(executor);
      bind(UpdateFactory.class).to(UpdateFactory.UpdateFactoryImpl.class);
      bind(UpdateFactory.UpdateFactoryImpl.class).in(Singleton.class);
      bind(JobUpdateController.class).to(JobUpdateControllerImpl.class);
      bind(JobUpdateControllerImpl.class).in(Singleton.class);
      expose(JobUpdateController.class);
      bind(JobUpdateEventSubscriber.class);
      expose(JobUpdateEventSubscriber.class);
    }
  });

  PubsubEventModule.bindSubscriber(binder(), JobUpdateEventSubscriber.class);
  SchedulerServicesModule.addSchedulerActiveServiceBinding(binder())
      .to(JobUpdateEventSubscriber.class);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:21,代碼來源:UpdaterModule.java

示例3: configure

import com.google.inject.PrivateModule; //導入依賴的package包/類
@Override
protected void configure() {
  install(new PrivateModule() {
    @Override
    protected void configure() {
      bind(Driver.class).to(SchedulerDriverService.class);
      bind(SchedulerDriverService.class).in(Singleton.class);
      expose(Driver.class);

      bind(Scheduler.class).to(MesosSchedulerImpl.class);
      bind(MesosSchedulerImpl.class).in(Singleton.class);
      expose(Scheduler.class);

      // TODO(zmanji): Create singleThreadedExecutor (non-scheduled) variant.
      bind(Executor.class).annotatedWith(MesosSchedulerImpl.SchedulerExecutor.class)
          .toInstance(AsyncUtil.singleThreadLoggingScheduledExecutor("SchedulerImpl-%d", LOG));
    }
  });

  PubsubEventModule.bindSubscriber(binder(), TaskStatusStats.class);
  bind(TaskStatusStats.class).in(Singleton.class);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:23,代碼來源:SchedulerDriverModule.java

示例4: configure

import com.google.inject.PrivateModule; //導入依賴的package包/類
@Override
protected void configure() {
  install(new PrivateModule() {
    @Override
    protected void configure() {
      bind(OfferManager.OfferReturnDelay.class).toInstance(
          new RandomJitterReturnDelay(
              MIN_OFFER_HOLD_TIME.get().as(Time.MILLISECONDS),
              OFFER_HOLD_JITTER_WINDOW.get().as(Time.MILLISECONDS),
              Random.Util.newDefaultRandom()));
      bind(OfferManager.class).to(OfferManager.OfferManagerImpl.class);
      bind(OfferManager.OfferManagerImpl.class).in(Singleton.class);
      expose(OfferManager.class);
    }
  });
  PubsubEventModule.bindSubscriber(binder(), OfferManager.class);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:18,代碼來源:OffersModule.java

示例5: configure

import com.google.inject.PrivateModule; //導入依賴的package包/類
@Override
protected void configure() {
  install(new PrivateModule() {
    @Override
    protected void configure() {
      bind(RowGarbageCollector.class).in(Singleton.class);
      bind(AbstractScheduledService.Scheduler.class).toInstance(
          AbstractScheduledService.Scheduler.newFixedRateSchedule(
              0L,
              DB_ROW_GC_INTERVAL.get().getValue(),
              DB_ROW_GC_INTERVAL.get().getUnit().getTimeUnit()));
      expose(RowGarbageCollector.class);
    }
  });
  SchedulerServicesModule.addSchedulerActiveServiceBinding(binder())
      .to(RowGarbageCollector.class);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:18,代碼來源:DbModule.java

示例6: configure

import com.google.inject.PrivateModule; //導入依賴的package包/類
@Override
protected void configure() {
  install(new PrivateModule() {
    @Override
    protected void configure() {
      bind(ScheduledThreadPoolExecutor.class).toInstance(afterTransaction);
      bind(ScheduledExecutorService.class).toInstance(afterTransaction);

      bind(GatingDelayExecutor.class).in(Singleton.class);
      expose(GatingDelayExecutor.class);

      bind(RegisterGauges.class).in(Singleton.class);
      expose(RegisterGauges.class);
    }
  });
  SchedulerServicesModule.addAppStartupServiceBinding(binder()).to(RegisterGauges.class);

  bind(Executor.class).annotatedWith(AsyncExecutor.class).to(GatingDelayExecutor.class);
  bind(DelayExecutor.class).annotatedWith(AsyncExecutor.class).to(GatingDelayExecutor.class);
  bind(GatedWorkQueue.class).annotatedWith(AsyncExecutor.class).to(GatingDelayExecutor.class);
}
 
開發者ID:PacktPublishing,項目名稱:Mastering-Mesos,代碼行數:22,代碼來源:AsyncModule.java

示例7: module

import com.google.inject.PrivateModule; //導入依賴的package包/類
@Override
public Module module(final Key<PluginSource> key, final String id) {
    return new PrivateModule() {
        @Override
        protected void configure() {
            bind(ProtocolServer.class).to(protocolServer).in(Scopes.SINGLETON);
            bind(Protocol.class).toInstance(protocol);

            bind(RiemannFrameDecoder.class);
            bind(RiemannResponder.class).in(Scopes.SINGLETON);
            bind(RiemannDatagramDecoder.class).in(Scopes.SINGLETON);
            bind(RiemannMessageDecoder.class).in(Scopes.SINGLETON);
            bind(Logger.class).toInstance(log);

            bind(RetryPolicy.class).toInstance(retry);

            bind(key).to(ProtocolPluginSource.class).in(Scopes.SINGLETON);
            expose(key);
        }
    };
}
 
開發者ID:spotify,項目名稱:ffwd,代碼行數:22,代碼來源:RiemannInputPlugin.java

示例8: getModule

import com.google.inject.PrivateModule; //導入依賴的package包/類
@Override
public Module getModule(Configuration configuration)
{
    return new PrivateModule()
    {
        @Override
        protected void configure()
        {
            bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class);
            bind(HttpClient.class).toInstance(new JettyHttpClient());
        }

        @Inject
        @Provides
        @Exposed
        @Singleton
        QueryStatsClient getQueryStatsClient(HttpClient httpClient, ObjectMapper objectMapper, @Named("presto_rest.base_uri") String prestoRestInterfaceBaseUri)
        {
            return new HttpQueryStatsClient(httpClient, objectMapper, URI.create(prestoRestInterfaceBaseUri));
        }
    };
}
 
開發者ID:y-lan,項目名稱:presto,代碼行數:23,代碼來源:QueryStatsClientModuleProvider.java

示例9: build

import com.google.inject.PrivateModule; //導入依賴的package包/類
public Module build() {

        checkState(implementation != null, "No implementation set for %s", key);

        return new AbstractModule() {
            @Override
            protected void configure() {
                install(new PrivateModule() {
                    @Override
                    protected void configure() {
                        install(dependencies);

                        bind(key).to(implementation).in(Singleton.class);
                        expose(key);
                    }
                });

                Multibinder<CuratorService> curatorServices = Multibinder.newSetBinder(binder(), CuratorService.class);

                curatorServices.addBinding().to(key);
            }
        };
    }
 
開發者ID:dclements,項目名稱:cultivar_old,代碼行數:24,代碼來源:LeaderServiceModuleBuilder.java

示例10: testPrivateModuleInheritScanner_usingPrivateModule

import com.google.inject.PrivateModule; //導入依賴的package包/類
public void testPrivateModuleInheritScanner_usingPrivateModule() {
  Injector injector =
      Guice.createInjector(
          NamedMunger.module(),
          new PrivateModule() {
            @Override
            protected void configure() {}

            @Exposed
            @TestProvides
            @Named("foo")
            String foo() {
              return "foo";
            }
          });
  assertMungedBinding(injector, String.class, "foo", "foo");
}
 
開發者ID:google,項目名稱:guice,代碼行數:18,代碼來源:ModuleAnnotatedMethodScannerTest.java

示例11: testPrivateModule_skipSourcesWithinPrivateModule

import com.google.inject.PrivateModule; //導入依賴的package包/類
public void testPrivateModule_skipSourcesWithinPrivateModule() {
  Injector injector =
      Guice.createInjector(
          NamedMunger.module(),
          new PrivateModule() {
            @Override
            protected void configure() {
              binder()
                  .skipSources(getClass())
                  .install(
                      new AbstractModule() {

                        @Exposed
                        @TestProvides
                        @Named("foo")
                        String foo() {
                          return "foo";
                        }
                      });
            }
          });
  assertMungedBinding(injector, String.class, "foo", "foo");
}
 
開發者ID:google,項目名稱:guice,代碼行數:24,代碼來源:ModuleAnnotatedMethodScannerTest.java

示例12: testPrivateModule_skipSourcesForPrivateModule

import com.google.inject.PrivateModule; //導入依賴的package包/類
public void testPrivateModule_skipSourcesForPrivateModule() {
  Injector injector =
      Guice.createInjector(
          NamedMunger.module(),
          new AbstractModule() {
            @Override
            protected void configure() {
              binder()
                  .skipSources(getClass())
                  .install(
                      new PrivateModule() {
                        @Override
                        protected void configure() {}

                        @Exposed
                        @TestProvides
                        @Named("foo")
                        String foo() {
                          return "foo";
                        }
                      });
            }
          });
  assertMungedBinding(injector, String.class, "foo", "foo");
}
 
開發者ID:google,項目名稱:guice,代碼行數:26,代碼來源:ModuleAnnotatedMethodScannerTest.java

示例13: testPrivateModuleWithinPrivateModule

import com.google.inject.PrivateModule; //導入依賴的package包/類
public void testPrivateModuleWithinPrivateModule() {
  Injector injector =
      Guice.createInjector(
          NamedMunger.module(),
          new PrivateModule() {
            @Override
            protected void configure() {
              expose(Key.get(String.class, named("foo-munged")));
              install(
                  new PrivateModule() {
                    @Override
                    protected void configure() {}

                    @Exposed
                    @TestProvides
                    @Named("foo")
                    String foo() {
                      return "foo";
                    }
                  });
            }
          });
  assertMungedBinding(injector, String.class, "foo", "foo");
}
 
開發者ID:google,項目名稱:guice,代碼行數:25,代碼來源:ModuleAnnotatedMethodScannerTest.java

示例14: testOverrideModuleAndPrivateModule

import com.google.inject.PrivateModule; //導入依賴的package包/類
public void testOverrideModuleAndPrivateModule() {
  Module exposes5 =
      new PrivateModule() {
        @Override
        protected void configure() {
          bind(Integer.class).toInstance(5);
          expose(Integer.class);
        }
      };

  Module binds15 =
      new AbstractModule() {
        @Override
        protected void configure() {
          bind(Integer.class).toInstance(15);
        }
      };

  Injector injector = Guice.createInjector(Modules.override(exposes5).with(binds15));
  assertEquals(15, injector.getInstance(Integer.class).intValue());

  Injector reverse = Guice.createInjector(Modules.override(binds15).with(exposes5));
  assertEquals(5, reverse.getInstance(Integer.class).intValue());
}
 
開發者ID:google,項目名稱:guice,代碼行數:25,代碼來源:OverrideModuleTest.java

示例15: build

import com.google.inject.PrivateModule; //導入依賴的package包/類
public Module build() {
    checkState(namespaceValue != null, "Namespace not provided.");
    checkState(annotationHolder != null, "Target annotation not provided.");

    return new PrivateModule() {
        @Override
        protected void configure() {
            bind(CuratorFramework.class).annotatedWith(Private.class).to(
                    Key.get(CuratorFramework.class, Curator.class));

            bind(String.class).annotatedWith(Private.class).toProvider(Providers.of(namespaceValue.orNull()));

            Key<CuratorFramework> frameworkKey = annotationHolder.generateKey(CuratorFramework.class);

            bind(frameworkKey).to(NamespacedCuratorFramework.class).in(Scopes.SINGLETON);

            expose(frameworkKey);
        }
    };
}
 
開發者ID:ReadyTalk,項目名稱:cultivar,代碼行數:21,代碼來源:NamespaceModuleBuilder.java


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