com.netflix.client.config.ClientConfigFactory Java Examples
The following examples show how to use
com.netflix.client.config.ClientConfigFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RxMovieProxyExampleTest.java From ribbon with Apache License 2.0 | 6 votes |
@Test public void testTransportFactoryWithInjection() { Injector injector = Guice.createInjector( new AbstractModule() { @Override protected void configure() { bind(ClientConfigFactory.class).to(MyClientConfigFactory.class).in(Scopes.SINGLETON); bind(RibbonTransportFactory.class).to(DefaultRibbonTransportFactory.class).in(Scopes.SINGLETON); } } ); RibbonTransportFactory transportFactory = injector.getInstance(RibbonTransportFactory.class); HttpClient<ByteBuf, ByteBuf> client = transportFactory.newHttpClient("myClient"); IClientConfig config = ((LoadBalancingHttpClient) client).getClientConfig(); assertEquals("MyConfig", config.getNameSpace()); }
Example #2
Source File: ClientPropertiesTest.java From ribbon with Apache License 2.0 | 6 votes |
@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()); }
Example #3
Source File: RxMovieProxyExampleTest.java From ribbon with Apache License 2.0 | 6 votes |
@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()); }
Example #4
Source File: ResourceGroup.java From ribbon with Apache License 2.0 | 5 votes |
protected ResourceGroup(String name, ClientOptions options, ClientConfigFactory configFactory, RibbonTransportFactory transportFactory) { this.name = name; clientConfig = configFactory.newConfig(); clientConfig.loadProperties(name); if (options != null) { for (IClientConfigKey key: options.getOptions().keySet()) { clientConfig.set(key, options.getOptions().get(key)); } } this.configFactory = configFactory; this.transportFactory = transportFactory; }
Example #5
Source File: RibbonDynamicProxy.java From ribbon with Apache License 2.0 | 5 votes |
@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) ); }
Example #6
Source File: RibbonDynamicProxy.java From ribbon with Apache License 2.0 | 5 votes |
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); }
Example #7
Source File: RibbonModule.java From ribbon with Apache License 2.0 | 5 votes |
@Override protected void configure() { bind(ClientConfigFactory.class).toInstance(ClientConfigFactory.DEFAULT); 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); }
Example #8
Source File: ClientPropertiesTest.java From ribbon with Apache License 2.0 | 5 votes |
@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()); }
Example #9
Source File: HttpResourceGroupFactoryTest.java From ribbon with Apache License 2.0 | 4 votes |
@Test public void testResourceGroupAnnotationMissing() throws Exception { ClassTemplate<SampleMovieService> classTemplate = new ClassTemplate<SampleMovieService>(SampleMovieService.class); new ProxyHttpResourceGroupFactory<SampleMovieService>(classTemplate, new DefaultResourceFactory(ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT, AnnotationProcessorsProvider.DEFAULT), AnnotationProcessorsProvider.DEFAULT).createResourceGroup(); }
Example #10
Source File: ClientPropertiesTest.java From ribbon with Apache License 2.0 | 4 votes |
public MyTransportFactory(ClientConfigFactory clientConfigFactory) { super(clientConfigFactory); }
Example #11
Source File: RibbonTransportFactory.java From ribbon with Apache License 2.0 | 4 votes |
protected RibbonTransportFactory(ClientConfigFactory clientConfigFactory) { this.clientConfigFactory = clientConfigFactory; }
Example #12
Source File: ResourceGroup.java From ribbon with Apache License 2.0 | 4 votes |
protected ResourceGroup(String name) { this(name, ClientOptions.create(), ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT); }
Example #13
Source File: RibbonResourceFactory.java From ribbon with Apache License 2.0 | 4 votes |
public final ClientConfigFactory getClientConfigFactory() { return clientConfigFactory; }
Example #14
Source File: RibbonResourceFactory.java From ribbon with Apache License 2.0 | 4 votes |
public RibbonResourceFactory(ClientConfigFactory configFactory, RibbonTransportFactory transportFactory, AnnotationProcessorsProvider processors) { this.clientConfigFactory = configFactory; this.transportFactory = transportFactory; this.annotationProcessors = processors; }
Example #15
Source File: HttpResourceGroup.java From ribbon with Apache License 2.0 | 4 votes |
protected HttpResourceGroup(String groupName, ClientOptions options, ClientConfigFactory configFactory, RibbonTransportFactory transportFactory, HttpHeaders headers) { super(groupName, options, configFactory, transportFactory); client = transportFactory.newHttpClient(getClientConfig()); this.headers = headers; }
Example #16
Source File: HttpResourceGroup.java From ribbon with Apache License 2.0 | 4 votes |
protected HttpResourceGroup(String groupName) { super(groupName, ClientOptions.create(), ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT); client = transportFactory.newHttpClient(getClientConfig()); headers = HttpHeaders.EMPTY_HEADERS; }
Example #17
Source File: HttpResourceGroup.java From ribbon with Apache License 2.0 | 4 votes |
public static Builder newBuilder(String groupName, ClientConfigFactory configFactory, RibbonTransportFactory transportFactory) { return new Builder(groupName, configFactory, transportFactory); }
Example #18
Source File: RibbonTransportFactory.java From ribbon with Apache License 2.0 | 4 votes |
@Inject public DefaultRibbonTransportFactory(ClientConfigFactory clientConfigFactory) { super(clientConfigFactory); }
Example #19
Source File: HttpResourceGroup.java From ribbon with Apache License 2.0 | 4 votes |
private Builder(String name, ClientConfigFactory configFactory, RibbonTransportFactory transportFactory) { this.name = name; this.clientConfigFactory = configFactory; this.transportFactory = transportFactory; }
Example #20
Source File: SecuredRibbonResourceFactory.java From thorntail with Apache License 2.0 | 4 votes |
public SecuredRibbonResourceFactory(final int maxChunkSize) { this(ClientConfigFactory.DEFAULT, new SecuredTransportFactory(maxChunkSize), AnnotationProcessorsProvider.DEFAULT); }
Example #21
Source File: RibbonDynamicProxy.java From ribbon with Apache License 2.0 | 4 votes |
public static <T> T newInstance(Class<T> clientInterface, RibbonResourceFactory resourceGroupFactory, ClientConfigFactory configFactory, RibbonTransportFactory transportFactory) { return newInstance(clientInterface, resourceGroupFactory, configFactory, transportFactory, AnnotationProcessorsProvider.DEFAULT); }
Example #22
Source File: RibbonDynamicProxy.java From ribbon with Apache License 2.0 | 4 votes |
public static <T> T newInstance(Class<T> clientInterface) { return newInstance(clientInterface, new DefaultResourceFactory(ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT, AnnotationProcessorsProvider.DEFAULT), ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT, AnnotationProcessorsProvider.DEFAULT); }
Example #23
Source File: ProxyHttpResourceGroupFactory.java From ribbon with Apache License 2.0 | 4 votes |
ProxyHttpResourceGroupFactory(ClassTemplate<T> classTemplate) { this(classTemplate, new DefaultResourceFactory(ClientConfigFactory.DEFAULT, RibbonTransportFactory.DEFAULT, AnnotationProcessorsProvider.DEFAULT), AnnotationProcessorsProvider.DEFAULT); }
Example #24
Source File: DefaultResourceFactory.java From ribbon with Apache License 2.0 | 4 votes |
public DefaultResourceFactory(ClientConfigFactory clientConfigFactory, RibbonTransportFactory transportFactory) { super(clientConfigFactory, transportFactory, AnnotationProcessorsProvider.DEFAULT); }
Example #25
Source File: DefaultResourceFactory.java From ribbon with Apache License 2.0 | 4 votes |
@Inject public DefaultResourceFactory(ClientConfigFactory clientConfigFactory, RibbonTransportFactory transportFactory, AnnotationProcessorsProvider annotationProcessorsProvider) { super(clientConfigFactory, transportFactory, annotationProcessorsProvider); }
Example #26
Source File: NFHttpClient.java From ribbon with Apache License 2.0 | 4 votes |
private static IClientConfig createDefaultConfig() { IClientConfig config = ClientConfigFactory.DEFAULT.newConfig(); config.loadProperties("default"); return config; }
Example #27
Source File: NFHttpClientFactory.java From ribbon with Apache License 2.0 | 4 votes |
public static NFHttpClient getNamedNFHttpClient(String name, boolean registerMonitor) { IClientConfig config = ClientConfigFactory.DEFAULT.newConfig(); config.loadProperties(name); return getNamedNFHttpClient(name, config, registerMonitor); }
Example #28
Source File: NFHttpClientFactory.java From ribbon with Apache License 2.0 | 4 votes |
public static NFHttpClient getNamedNFHttpClient(String name) { IClientConfig config = ClientConfigFactory.DEFAULT.newConfig(); config.loadProperties(name); return getNamedNFHttpClient(name, config, true); }
Example #29
Source File: DiscoveryEnabledNIWSServerList.java From ribbon with Apache License 2.0 | 4 votes |
private static IClientConfig createClientConfig(String vipAddresses) { IClientConfig clientConfig = ClientConfigFactory.DEFAULT.newConfig(); clientConfig.set(Keys.DeploymentContextBasedVipAddresses, vipAddresses); return clientConfig; }
Example #30
Source File: SecuredTransportFactory.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 4 votes |
protected SecuredTransportFactory(final int maxChunkSize) { super(ClientConfigFactory.DEFAULT); this.maxChunkSize = maxChunkSize; }