本文整理匯總了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));
}
};
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
};
}
示例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));
}
};
}
示例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);
}
};
}
示例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");
}
示例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");
}
示例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");
}
示例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");
}
示例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());
}
示例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);
}
};
}