com.netflix.discovery.shared.transport.jersey.EurekaJerseyClient Java Examples

The following examples show how to use com.netflix.discovery.shared.transport.jersey.EurekaJerseyClient. 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: ApiMediationClientImpl.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Create and initialize EurekaClient instance.
 *
 * @param applicationInfoManager
 * @param clientConfig
 * @param config
 * @return Initialized {@link DiscoveryClient} instance - an implementation of {@link EurekaClient}
 */
private EurekaClient initializeEurekaClient(
    ApplicationInfoManager applicationInfoManager, EurekaClientConfig clientConfig, ApiMediationServiceConfig config) {

    Ssl sslConfig = config.getSsl();

    HttpsConfig.HttpsConfigBuilder builder = HttpsConfig.builder();
    if (sslConfig != null) {
        builder.protocol(sslConfig.getProtocol());
        if (Boolean.TRUE.equals(sslConfig.getEnabled())) {
            builder.keyAlias(sslConfig.getKeyAlias())
                .keyStore(sslConfig.getKeyStore())
                .keyPassword(sslConfig.getKeyPassword())
                .keyStorePassword(sslConfig.getKeyStorePassword())
                .keyStoreType(sslConfig.getKeyStoreType());
        }

        builder.verifySslCertificatesOfServices(Boolean.TRUE.equals(sslConfig.getVerifySslCertificatesOfServices()));
        if (Boolean.TRUE.equals(sslConfig.getVerifySslCertificatesOfServices())) {
            builder.trustStore(sslConfig.getTrustStore())
                .trustStoreType(sslConfig.getTrustStoreType())
                .trustStorePassword(sslConfig.getTrustStorePassword());
        }
    }
    HttpsConfig httpsConfig = builder.build();

    HttpsFactory factory = new HttpsFactory(httpsConfig);
    EurekaJerseyClient eurekaJerseyClient = factory.createEurekaJerseyClientBuilder(
        config.getDiscoveryServiceUrls().get(0), config.getServiceId()).build();

    AbstractDiscoveryClientOptionalArgs args = new DiscoveryClient.DiscoveryClientOptionalArgs();
    args.setEurekaJerseyClient(eurekaJerseyClient);
    applicationInfoManager.setInstanceStatus(InstanceInfo.InstanceStatus.UP);
    return this.eurekaClientProvider.client(applicationInfoManager, clientConfig, args);
}
 
Example #2
Source File: HttpConfig.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@Bean
public EurekaJerseyClient eurekaJerseyClient() {
    return eurekaJerseyClientBuilder.build();
}
 
Example #3
Source File: RestTemplateTransportClientFactories.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Override
public TransportClientFactory newTransportClientFactory(
		Collection<Void> additionalFilters, EurekaJerseyClient providedJerseyClient) {
	throw new UnsupportedOperationException();
}
 
Example #4
Source File: WebClientTransportClientFactories.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Override
public TransportClientFactory newTransportClientFactory(
		Collection<Void> additionalFilters, EurekaJerseyClient providedJerseyClient) {
	throw new UnsupportedOperationException();
}
 
Example #5
Source File: EurekaClientAutoConfigurationTests.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Bean
public EurekaJerseyClient jerseyClient() {
	EurekaJerseyClient mock = Mockito.mock(EurekaJerseyClient.class);
	Mockito.when(mock.getClient()).thenReturn(apacheClient());
	return mock;
}