当前位置: 首页>>代码示例>>Java>>正文


Java ServiceProviderBuilder类代码示例

本文整理汇总了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());
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:19,代码来源:ServiceProviderModuleBuilderTest.java

示例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());
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:24,代码来源:ServiceProviderModuleBuilderTest.java

示例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"));
}
 
开发者ID:apache,项目名称:curator,代码行数:13,代码来源:ServiceDiscoveryImpl.java

示例4: get

import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Override
public ServiceProviderBuilder<T> get() {
    return discovery.serviceProviderBuilder();
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:5,代码来源:ServiceProviderBuilderProvider.java

示例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);
        }
    };
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:80,代码来源:ServiceProviderModuleBuilder.java

示例6: ServiceProviderProvider

import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Inject
ServiceProviderProvider(@Private final ServiceProviderBuilder<T> builder) {
    this.builder = builder;
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:5,代码来源:ServiceProviderProvider.java

示例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)));
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:6,代码来源:ServiceDiscoveryModuleBuilderTest.java

示例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))));
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:6,代码来源:ServiceDiscoveryModuleBuilderTest.java

示例9: serviceProviderBuilder

import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Override
public ServiceProviderBuilder<T> serviceProviderBuilder()
{
    throw new UnsupportedOperationException();
}
 
开发者ID:apache,项目名称:curator,代码行数:6,代码来源:MockServiceDiscovery.java

示例10: additionalFilter

import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
@Override
public ServiceProviderBuilder<T> additionalFilter(InstanceFilter<T> filter)
{
    filters.add(filter);
    return this;
}
 
开发者ID:apache,项目名称:curator,代码行数:7,代码来源:ServiceProviderBuilderImpl.java

示例11: ServiceProviderWrapper

import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
ServiceProviderWrapper(final ServiceProviderBuilder<T> builder) {
    this.builder = builder;
}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:4,代码来源:ServiceProviderWrapper.java

示例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);

        }

    };
}
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:59,代码来源:ServiceDiscoveryModuleBuilder.java

示例13: serviceProviderBuilderKey

import org.apache.curator.x.discovery.ServiceProviderBuilder; //导入依赖的package包/类
private Key<ServiceProviderBuilder<T>> serviceProviderBuilderKey() {

        return (Key<ServiceProviderBuilder<T>>) parameterizedAnnotatedKey(ServiceProviderBuilder.class);
    }
 
开发者ID:dclements,项目名称:cultivar_old,代码行数:5,代码来源:ServiceDiscoveryModuleBuilder.java

示例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);

        }

    };
}
 
开发者ID:ReadyTalk,项目名称:cultivar,代码行数:61,代码来源:ServiceDiscoveryModuleBuilder.java


注:本文中的org.apache.curator.x.discovery.ServiceProviderBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。