本文整理汇总了Java中org.apache.curator.x.discovery.ServiceProviderBuilder类的典型用法代码示例。如果您正苦于以下问题:Java ServiceProviderBuilder类的具体用法?Java ServiceProviderBuilder怎么用?Java ServiceProviderBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServiceProviderBuilder类属于org.apache.curator.x.discovery包,在下文中一共展示了ServiceProviderBuilder类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createInjector_ServiceProviderBuilderBound_Succeeds
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void createInjector_ServiceProviderBuilderBound_Succeeds() {
Guice.createInjector(
new AbstractModule() {
@Override
protected void configure() {
bind(
(Key<ServiceProviderBuilder<Void>>) Key.get(
Types.newParameterizedType(ServiceProviderBuilder.class, Void.class),
Curator.class)).toInstance(providerBuilder);
}
},
ServiceProviderModuleBuilder.create(Void.class).discovery(Curator.class).annotation(Curator.class)
.name("test").build());
}
示例2: setUp
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Before
@SuppressWarnings("unchecked")
public void setUp() {
when(providerBuilder.build()).thenReturn(provider);
dependencies = new AbstractModule() {
@Override
protected void configure() {
bind(
(Key<ServiceProviderBuilder<Void>>) Key.get(
Types.newParameterizedType(ServiceProviderBuilder.class, Void.class), Curator.class))
.toInstance(providerBuilder);
}
};
inj = Guice.createInjector(
dependencies,
ServiceProviderModuleBuilder.create(Void.class).discovery(Curator.class)
.additionalFilter(instanceFilter1).additionalFilter(instanceFilter2)
.providerStrategy(providerStrategy).threadFactory(threadFactory)
.downInstancePolicy(downInstancePolicy).annotation(Curator.class).name("test").build());
}
示例3: serviceProviderBuilder
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
/**
* Allocate a new builder. {@link ServiceProviderBuilder#providerStrategy} is set to {@link RoundRobinStrategy}
*
* @return the builder
*/
@Override
public ServiceProviderBuilder<T> serviceProviderBuilder()
{
return new ServiceProviderBuilderImpl<T>(this)
.providerStrategy(new RoundRobinStrategy<T>())
.threadFactory(ThreadUtils.newThreadFactory("ServiceProvider"));
}
示例4: get
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Override
public ServiceProviderBuilder<T> get() {
return discovery.serviceProviderBuilder();
}
示例5: build
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Module build() {
checkState(serviceName != null, "name not set.");
checkState(discoveryAnnotation != null, "Annotation for discovery not set.");
checkState(targetAnnotation != null, "Target annotation not set.");
return new AbstractModule() {
@Override
protected void configure() {
requireBinding(discoveryAnnotation.generateKey(Types.newParameterizedType(ServiceProviderBuilder.class,
payloadClass)));
final Key<ServiceProviderManager<T>> manager = (Key<ServiceProviderManager<T>>) targetAnnotation
.generateKey(Types.newParameterizedType(ServiceProviderManager.class, payloadClass));
install(new PrivateModule() {
@Override
protected void configure() {
AnnotationHolder privateAnnotation = AnnotationHolder.create(Private.class);
Multibinder<InstanceFilter<T>> filters = Multibinder.newSetBinder(
binder(),
(TypeLiteral<InstanceFilter<T>>) Key.get(
Types.newParameterizedType(InstanceFilter.class, payloadClass))
.getTypeLiteral(), Private.class);
for (InstanceFilter<T> o : instanceFilters) {
filters.addBinding().toInstance(o);
}
if (strategy != null) {
bind(
(Key<ProviderStrategy<T>>) Key.get(
Types.newParameterizedType(ProviderStrategy.class, payloadClass),
Private.class)).toInstance(strategy);
}
if (threads != null) {
bind(ThreadFactory.class).annotatedWith(Private.class).toInstance(threads);
}
if (downInstancePolicy != null) {
bind(DownInstancePolicy.class).annotatedWith(Private.class).toInstance(downInstancePolicy);
}
bind(
(Key<ServiceProviderBuilder<T>>) privateAnnotation.generateKey(Types
.newParameterizedType(ServiceProviderBuilder.class, payloadClass))).to(
(Key<ServiceProviderBuilder<T>>) discoveryAnnotation.generateKey(Types
.newParameterizedType(ServiceProviderBuilder.class, payloadClass)));
bindConstant().annotatedWith(Private.class).to(serviceName);
Key<ServiceProvider<T>> target = (Key<ServiceProvider<T>>) targetAnnotation.generateKey(Types
.newParameterizedType(ServiceProvider.class, payloadClass));
bind(target).toProvider(
(Key<ServiceProviderProvider<T>>) Key.get(Types.newParameterizedType(
ServiceProviderProvider.class, payloadClass))).in(Singleton.class);
expose(target);
bind(
(Key<ServiceProvider<T>>) privateAnnotation.generateKey(Types.newParameterizedType(
ServiceProvider.class, payloadClass))).to(target).in(Singleton.class);
bind(manager).to(
(Key<ServiceProviderManager<T>>) Key.get(Types.newParameterizedType(
ServiceProviderManager.class, payloadClass))).in(Singleton.class);
expose(manager);
}
});
Multibinder.newSetBinder(binder(), CuratorService.class).addBinding().to(manager);
}
};
}
示例6: ServiceProviderProvider
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Inject
ServiceProviderProvider(@Private final ServiceProviderBuilder<T> builder) {
this.builder = builder;
}
示例7: getExistingBinding_ServiceProviderBuilder_Exists
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Test
public void getExistingBinding_ServiceProviderBuilder_Exists() {
assertNotNull(inj.getExistingBinding(Key.get(new TypeLiteral<ServiceProviderBuilder<Void>>() {
}, Curator.class)));
}
示例8: getBinding_ServiceProviderBuilder_NotSingleton
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Test
public void getBinding_ServiceProviderBuilder_NotSingleton() {
assertFalse(Scopes.isSingleton(inj.getBinding(Key.get(new TypeLiteral<ServiceProviderBuilder<Void>>() {
}, Curator.class))));
}
示例9: serviceProviderBuilder
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Override
public ServiceProviderBuilder<T> serviceProviderBuilder()
{
throw new UnsupportedOperationException();
}
示例10: additionalFilter
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Override
public ServiceProviderBuilder<T> additionalFilter(InstanceFilter<T> filter)
{
filters.add(filter);
return this;
}
示例11: ServiceProviderWrapper
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
ServiceProviderWrapper(final ServiceProviderBuilder<T> builder) {
this.builder = builder;
}
示例12: build
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
/**
* Build the module for Guice.
*/
public Module build() {
checkState(basePathValue != null, "basePath not set.");
checkState(annotation != null, "annotation not set.");
return new AbstractModule() {
@Override
protected void configure() {
requireBinding(Key.get(CuratorFramework.class, Curator.class));
final Key<ServiceDiscoveryManager<T>> manager = managerKey();
install(new PrivateModule() {
@Override
protected void configure() {
bind(builderKey()).toInstance(ServiceDiscoveryBuilder.builder(payloadClass));
bind(privateDiscoveryKey()).toProvider(providerKey()).in(Singleton.class);
bindConstant().annotatedWith(Names.named("Cultivar.private.basePath")).to(basePathValue);
if (serializerValue != null) {
bind(serializerKey()).toInstance(serializerValue);
}
bind(manager).to(blankManagerKey()).in(Singleton.class);
expose(manager);
Key<ServiceDiscovery<T>> discovery = discoveryKey();
bind(discovery).to(privateDiscoveryKey()).in(Singleton.class);
expose(discovery);
Key<ServiceProviderBuilder<T>> serviceProviderBuilder = serviceProviderBuilderKey();
bind(serviceProviderBuilder)
.toProvider(
(Key<ServiceProviderBuilderProvider<T>>) parameterizedKey(ServiceProviderBuilderProvider.class));
expose(serviceProviderBuilder);
}
});
Multibinder<CuratorService> services = Multibinder.newSetBinder(binder(), CuratorService.class);
services.addBinding().to(manager);
}
};
}
示例13: serviceProviderBuilderKey
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
private Key<ServiceProviderBuilder<T>> serviceProviderBuilderKey() {
return (Key<ServiceProviderBuilder<T>>) parameterizedAnnotatedKey(ServiceProviderBuilder.class);
}
示例14: build
import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
/**
* Build the module for Guice.
*/
public Module build() {
checkState(basePathValue != null, "basePath not set.");
checkState(annotation != null, "annotation not set.");
return new AbstractModule() {
@Override
protected void configure() {
requireBinding(Key.get(CuratorFramework.class, Curator.class));
final Key<ServiceDiscoveryManager<T>> manager = managerKey();
install(new PrivateModule() {
@Override
protected void configure() {
ServiceDiscoveryModuleBuilder.this.bindFramework(binder());
bind(builderKey()).toInstance(ServiceDiscoveryBuilder.builder(payloadClass));
bind(privateDiscoveryKey()).toProvider(providerKey()).in(Singleton.class);
bindConstant().annotatedWith(Names.named("Cultivar.private.basePath")).to(basePathValue);
if (serializerValue != null) {
bind(serializerKey()).toInstance(serializerValue);
}
bind(manager).to(blankManagerKey()).in(Singleton.class);
expose(manager);
Key<ServiceDiscovery<T>> discovery = discoveryKey();
bind(discovery).to(privateDiscoveryKey()).in(Singleton.class);
expose(discovery);
Key<ServiceProviderBuilder<T>> serviceProviderBuilder = serviceProviderBuilderKey();
bind(serviceProviderBuilder)
.toProvider(
(Key<ServiceProviderBuilderProvider<T>>) parameterizedKey(ServiceProviderBuilderProvider.class));
expose(serviceProviderBuilder);
}
});
Multibinder<CuratorService> services = Multibinder.newSetBinder(binder(), CuratorService.class);
services.addBinding().to(manager);
}
};
}