本文整理汇总了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());
}
示例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());
}
}
}
示例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());
}
示例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);
}
示例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();
}
示例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);
}
示例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)
);
}
示例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());
}
示例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);
}
示例10: initialize
import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Inject
@Toolable
protected void initialize(RibbonResourceFactory factory) {
this.factory = factory;
}
示例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;
}
示例12: process
import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
public void process(String groupName, HttpResourceGroup.Builder groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass) {
}
示例13: process
import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
public void process(String groupName, GroupBuilder groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass) {
}
示例14: process
import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
@Override
public void process(String groupName, GroupBuilder groupBuilder, RibbonResourceFactory factory, Class<?> interfaceClass) {
}
示例15: process
import com.netflix.ribbon.RibbonResourceFactory; //导入依赖的package包/类
void process(String groupName, T groupBuilder, RibbonResourceFactory resourceFactory, Class<?> interfaceClass);