com.netflix.discovery.AbstractDiscoveryClientOptionalArgs Java Examples

The following examples show how to use com.netflix.discovery.AbstractDiscoveryClientOptionalArgs. 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: ZuulSampleModule.java    From Sentinel with Apache License 2.0 5 votes vote down vote up
@Override
protected void configure() {
    // sample specific bindings
    bind(BaseServerStartup.class).to(SampleServerStartup.class);

    // use provided basic netty origin manager
    bind(OriginManager.class).to(BasicNettyOriginManager.class);

    // zuul filter loading
    install(new ZuulFiltersModule());
    bind(FilterFileManager.class).asEagerSingleton();

    install(new ZuulClasspathFiltersModule());
    // general server bindings
    // health/discovery status
    bind(ServerStatusManager.class);
    // decorate new sessions when requests come in
    bind(SessionContextDecorator.class).to(ZuulSessionContextDecorator.class);
    // atlas metrics registry
    bind(Registry.class).to(DefaultRegistry.class);
    // metrics post-request completion
    bind(RequestCompleteHandler.class).to(BasicRequestCompleteHandler.class);
    // discovery client
    bind(AbstractDiscoveryClientOptionalArgs.class).to(DiscoveryClient.DiscoveryClientOptionalArgs.class);
    // timings publisher
    bind(RequestMetricsPublisher.class).to(BasicRequestMetricsPublisher.class);

    // access logger, including request ID generator
    bind(AccessLogPublisher.class).toInstance(new AccessLogPublisher("ACCESS",
            (channel, httpRequest) -> ClientRequestReceiver.getRequestFromChannel(channel).getContext().getUUID()));
}
 
Example #2
Source File: ApimlDiscoveryClient.java    From api-layer with Eclipse Public License 2.0 5 votes vote down vote up
public ApimlDiscoveryClient(
    ApplicationInfoManager applicationInfoManager,
    EurekaClientConfig config,
    AbstractDiscoveryClientOptionalArgs<?> args,
    ApplicationEventPublisher publisher
) {
    super(applicationInfoManager, config, args, publisher);
    init();
}
 
Example #3
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 #4
Source File: EurekaStubsRegistrar.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
private AbstractDiscoveryClientOptionalArgs args() {
	try {
		return this.context.getBean(AbstractDiscoveryClientOptionalArgs.class);
	}
	catch (BeansException e) {
		return null;
	}
}
 
Example #5
Source File: CloudEurekaClient.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
public CloudEurekaClient(ApplicationInfoManager applicationInfoManager,
		EurekaClientConfig config, AbstractDiscoveryClientOptionalArgs<?> args,
		ApplicationEventPublisher publisher) {
	super(applicationInfoManager, config, args);
	this.applicationInfoManager = applicationInfoManager;
	this.publisher = publisher;
	this.eurekaTransportField = ReflectionUtils.findField(DiscoveryClient.class,
			"eurekaTransport");
	ReflectionUtils.makeAccessible(this.eurekaTransportField);
}
 
Example #6
Source File: DiscoveryClientOptionalArgsConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnClass(name = "org.springframework.web.client.RestTemplate")
@ConditionalOnMissingClass("com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnMissingBean(value = { AbstractDiscoveryClientOptionalArgs.class },
		search = SearchStrategy.CURRENT)
@ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled",
		matchIfMissing = true, havingValue = "false")
public RestTemplateDiscoveryClientOptionalArgs restTemplateDiscoveryClientOptionalArgs() {
	logger.info("Eureka HTTP Client uses RestTemplate.");
	return new RestTemplateDiscoveryClientOptionalArgs();
}
 
Example #7
Source File: DiscoveryClientOptionalArgsConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingClass("com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnClass(
		name = "org.springframework.web.reactive.function.client.WebClient")
@ConditionalOnMissingBean(
		value = { AbstractDiscoveryClientOptionalArgs.class,
				RestTemplateDiscoveryClientOptionalArgs.class },
		search = SearchStrategy.CURRENT)
@ConditionalOnProperty(prefix = "eureka.client", name = "webclient.enabled",
		havingValue = "true")
public WebClientDiscoveryClientOptionalArgs webClientDiscoveryClientOptionalArgs() {
	logger.info("Eureka HTTP Client uses WebClient.");
	return new WebClientDiscoveryClientOptionalArgs();
}
 
Example #8
Source File: DiscoveryClientOptionalArgsConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnClass(name = "com.sun.jersey.api.client.filter.ClientFilter")
@ConditionalOnMissingBean(value = AbstractDiscoveryClientOptionalArgs.class,
		search = SearchStrategy.CURRENT)
public MutableDiscoveryClientOptionalArgs discoveryClientOptionalArgs() {
	logger.info("Eureka Client uses Jersey");
	return new MutableDiscoveryClientOptionalArgs();
}
 
Example #9
Source File: ApimlDiscoveryClientStub.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
public ApimlDiscoveryClientStub(ApplicationInfoManager applicationInfoManager, EurekaClientConfig config, AbstractDiscoveryClientOptionalArgs<?> args, ApplicationEventPublisher publisher, ApplicationRegistry applicationRegistry) {
    super(applicationInfoManager, config, args, publisher);

    this.applicationRegistry = applicationRegistry;
}
 
Example #10
Source File: DiscoveryClientProvider.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public EurekaClient client(ApplicationInfoManager applicationInfoManager, EurekaClientConfig clientConfig, AbstractDiscoveryClientOptionalArgs args) {
    return new DiscoveryClient(applicationInfoManager, clientConfig, args);
}
 
Example #11
Source File: EurekaClientProvider.java    From api-layer with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Provide a Eureka Client based on the provided configuration parameters.
 * @param applicationInfoManager Information about the running application
 * @param config Configuration for the Eureka
 * @param args Relevant filters for Eureka
 * @return Valid client for the Discovery service
 */
EurekaClient client(ApplicationInfoManager applicationInfoManager, final EurekaClientConfig config, AbstractDiscoveryClientOptionalArgs args);