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


Java RibbonResourceFactory类代码示例

本文整理汇总了Java中com.netflix.ribbon.RibbonResourceFactory的典型用法代码示例。如果您正苦于以下问题:Java RibbonResourceFactory类的具体用法?Java RibbonResourceFactory怎么用?Java RibbonResourceFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RibbonResourceFactory类属于com.netflix.ribbon包,在下文中一共展示了RibbonResourceFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldBindCustomClientConfigFactory

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Test
public void shouldBindCustomClientConfigFactory() {
    ConfigurationManager.getConfigInstance().setProperty(MovieService.class.getSimpleName() + ".MyConfig.listOfServers", "localhost:" + port);

    Injector injector = Guice.createInjector(
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(RibbonResourceFactory.class).to(DefaultResourceFactory.class).in(Scopes.SINGLETON);
                    bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON);
                    bind(AnnotationProcessorsProvider.class).to(DefaultAnnotationProcessorsProvider.class).in(Scopes.SINGLETON);
                    bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON);
                }
            },
            new AbstractModule() {
                @Override
                protected void configure() {
                    bind(MovieService.class).toProvider(new RibbonResourceProvider<MovieService>(MovieService.class)).asEagerSingleton();
                }
            }
    );

    RxMovieProxyExample example = injector.getInstance(RxMovieProxyExample.class);
    assertTrue(example.runExample());
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:26,代码来源:RxMovieProxyExampleTest.java

示例2: process

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
public void process(String groupName, GroupBuilder groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass) {
    ClientProperties properties = interfaceClass.getAnnotation(ClientProperties.class);
    if (properties != null) {
        IClientConfig config = resourceFactory.getClientConfigFactory().newConfig();
        for (Property prop : properties.properties()) {
            String name = prop.name();
            config.set(CommonClientConfigKey.valueOf(name), prop.value());
        }
        ClientOptions options = ClientOptions.from(config);
        groupBuilder.withClientOptions(options);
        if (properties.exportToArchaius()) {
            exportPropertiesToArchaius(groupName, config, interfaceClass.getName());
        }
    }
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:ClientPropertiesProcessor.java

示例3: testAnnotation

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Test
public void testAnnotation() {
    MyTransportFactory transportFactory = new MyTransportFactory(ClientConfigFactory.DEFAULT);
    RibbonResourceFactory resourceFactory = new DefaultResourceFactory(ClientConfigFactory.DEFAULT, transportFactory);
    RibbonDynamicProxy.newInstance(SampleMovieService.class, resourceFactory, ClientConfigFactory.DEFAULT, transportFactory);
    IClientConfig clientConfig = transportFactory.getClientConfig();
    assertEquals(1000, clientConfig.get(Keys.ConnectTimeout).longValue());
    assertEquals(2000, clientConfig.get(Keys.ReadTimeout).longValue());

    Configuration config = ConfigurationManager.getConfigInstance();
    assertEquals("2000", config.getProperty("SampleMovieService.ribbon.ReadTimeout"));
    assertEquals("1000", config.getProperty("SampleMovieService.ribbon.ConnectTimeout"));

    config.setProperty("SampleMovieService.ribbon.ReadTimeout", "5000");
    assertEquals(5000, clientConfig.get(Keys.ReadTimeout).longValue());
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:17,代码来源:ClientPropertiesTest.java

示例4: configure

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
protected void configure() {
    bind(ClientConfigFactory.class).to(DefaultClientConfigFactory.class).in(Scopes.SINGLETON);
    bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON);
    bind(AnnotationProcessorsProvider.class).to(DefaultAnnotationProcessorsProvider.class).in(Scopes.SINGLETON);
    bind(RibbonResourceFactory.class).to(DefaultResourceFactory.class).in(Scopes.SINGLETON);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:8,代码来源:RibbonModule.java

示例5: MyService

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Inject
public MyService(RibbonResourceFactory factory) {
    httpResourceGroup = factory.createHttpResourceGroup("movieServiceClient",
            ClientOptions.create()
                    .withMaxAutoRetriesNextServer(3)
                    .withConfigurationBasedServerList("localhost:" + PORT));

    registerMovieTemplate = httpResourceGroup.newTemplateBuilder("registerMovie", ByteBuf.class)
            .withMethod("POST")
            .withUriTemplate("/movies")
            .withHeader("X-Platform-Version", "xyz")
            .withHeader("X-Auth-Token", "abc")
            .withResponseValidator(new RecommendationServiceResponseValidator()).build();

    updateRecommendationTemplate = httpResourceGroup.newTemplateBuilder("updateRecommendation", ByteBuf.class)
            .withMethod("POST")
            .withUriTemplate("/users/{userId}/recommendations")
            .withHeader("X-Platform-Version", "xyz")
            .withHeader("X-Auth-Token", "abc")
            .withResponseValidator(new RecommendationServiceResponseValidator()).build();

    recommendationsByUserIdTemplate = httpResourceGroup.newTemplateBuilder("recommendationsByUserId", ByteBuf.class)
            .withMethod("GET")
            .withUriTemplate("/users/{userId}/recommendations")
            .withHeader("X-Platform-Version", "xyz")
            .withHeader("X-Auth-Token", "abc")
            .withFallbackProvider(new RecommendationServiceFallbackHandler())
            .withResponseValidator(new RecommendationServiceResponseValidator()).build();

    recommendationsByTemplate = httpResourceGroup.newTemplateBuilder("recommendationsBy", ByteBuf.class)
            .withMethod("GET")
            .withUriTemplate("/recommendations?category={category}&ageGroup={ageGroup}")
            .withHeader("X-Platform-Version", "xyz")
            .withHeader("X-Auth-Token", "abc")
            .withFallbackProvider(new RecommendationServiceFallbackHandler())
            .withResponseValidator(new RecommendationServiceResponseValidator()).build();
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:38,代码来源:RibbonModuleTest.java

示例6: RibbonDynamicProxy

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
public RibbonDynamicProxy(Class<T> clientInterface, RibbonResourceFactory resourceGroupFactory, ClientConfigFactory configFactory,
                          RibbonTransportFactory transportFactory, AnnotationProcessorsProvider processors) {
    registerAnnotationProcessors(processors);
    ClassTemplate<T> classTemplate = ClassTemplate.from(clientInterface);
    HttpResourceGroup httpResourceGroup = new ProxyHttpResourceGroupFactory<T>(classTemplate, resourceGroupFactory, processors).createResourceGroup();
    templateExecutorMap = MethodTemplateExecutor.from(httpResourceGroup, clientInterface, processors);
    lifeCycle = new ProxyLifecycleImpl(httpResourceGroup);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:9,代码来源:RibbonDynamicProxy.java

示例7: newInstance

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static <T> T newInstance(Class<T> clientInterface, RibbonResourceFactory resourceGroupFactory,
                                ClientConfigFactory configFactory, RibbonTransportFactory transportFactory, AnnotationProcessorsProvider processors) {
    if (!clientInterface.isInterface()) {
        throw new IllegalArgumentException(clientInterface.getName() + " is a class not interface");
    }
    return (T) Proxy.newProxyInstance(
            Thread.currentThread().getContextClassLoader(),
            new Class[]{clientInterface, ProxyLifeCycle.class},
            new RibbonDynamicProxy<T>(clientInterface, resourceGroupFactory, configFactory, transportFactory, processors)
    );
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:13,代码来源:RibbonDynamicProxy.java

示例8: testNoExportToArchaius

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Test
public void testNoExportToArchaius() {
    MyTransportFactory transportFactory = new MyTransportFactory(ClientConfigFactory.DEFAULT);
    RibbonResourceFactory resourceFactory = new DefaultResourceFactory(ClientConfigFactory.DEFAULT, transportFactory);
    RibbonDynamicProxy.newInstance(MovieService.class, resourceFactory, ClientConfigFactory.DEFAULT, transportFactory);
    IClientConfig clientConfig = transportFactory.getClientConfig();
    assertEquals(1000, clientConfig.get(Keys.ConnectTimeout).longValue());
    assertEquals(3000, clientConfig.get(Keys.ReadTimeout).longValue());
    assertEquals(0, clientConfig.get(Keys.MaxAutoRetriesNextServer).longValue());

    Configuration config = ConfigurationManager.getConfigInstance();
    assertNull(config.getProperty("MovieService.ribbon.ReadTimeout"));
    config.setProperty("MovieService.ribbon.ReadTimeout", "5000");
    assertEquals(5000, clientConfig.get(Keys.ReadTimeout).longValue());
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:16,代码来源:ClientPropertiesTest.java

示例9: testSetupWithResourceGroupNameInAnnotation

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Test
public void testSetupWithResourceGroupNameInAnnotation() throws Exception {
    mockStatic(ProxyHttpResourceGroupFactory.class);
    expectNew(ProxyHttpResourceGroupFactory.class, new Class[]{ClassTemplate.class, 
        RibbonResourceFactory.class, AnnotationProcessorsProvider.class
        }, anyObject(), anyObject(), anyObject()).andReturn(httpResourceGroupFactoryMock);

    replayAll();

    RibbonDynamicProxy.newInstance(SampleMovieServiceWithResourceGroupNameAnnotation.class);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:12,代码来源:RibbonDynamicProxyTest.java

示例10: initialize

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Inject
@Toolable
protected void initialize(RibbonResourceFactory factory) {
    this.factory = factory;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:6,代码来源:RibbonResourceProvider.java

示例11: ProxyHttpResourceGroupFactory

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
ProxyHttpResourceGroupFactory(ClassTemplate<T> classTemplate, RibbonResourceFactory httpResourceGroupFactory,
                              AnnotationProcessorsProvider processors) {
    this.classTemplate = classTemplate;
    this.httpResourceGroupFactory = httpResourceGroupFactory;
    this.processors = processors;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:7,代码来源:ProxyHttpResourceGroupFactory.java

示例12: process

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
public void process(String groupName, HttpResourceGroup.Builder groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass) {
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:4,代码来源:HystrixAnnotationProcessor.java

示例13: process

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
public void process(String groupName, GroupBuilder groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass) {
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:4,代码来源:CacheProviderAnnotationProcessor.java

示例14: process

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
public void process(String groupName, GroupBuilder groupBuilder, RibbonResourceFactory factory, Class<?> interfaceClass) {
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:4,代码来源:EVCacheAnnotationProcessor.java

示例15: process

import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
void process(String groupName, T groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass); 
开发者ID:Netflix,项目名称:ribbon,代码行数:2,代码来源:AnnotationProcessor.java


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