All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nepxion.discovery.plugin.framework.context.EurekaApplicationContextInitializer Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
package com.nepxion.discovery.plugin.framework.context;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import java.util.Map; import org.springframework.beans.BeansException; import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean; import org.springframework.cloud.netflix.eureka.serviceregistry.EurekaServiceRegistry; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.ConfigurableEnvironment; import com.nepxion.discovery.plugin.framework.constant.EurekaConstant; import com.nepxion.discovery.plugin.framework.constant.PluginConstant; import com.nepxion.discovery.plugin.framework.decorator.EurekaServiceRegistryDecorator; public class EurekaApplicationContextInitializer extends PluginApplicationContextInitializer { @Override protected Object afterInitialization(ConfigurableApplicationContext applicationContext, Object bean, String beanName) throws BeansException { if (bean instanceof EurekaServiceRegistry) { EurekaServiceRegistry eurekaServiceRegistry = (EurekaServiceRegistry) bean; return new EurekaServiceRegistryDecorator(eurekaServiceRegistry, applicationContext); } else if (bean instanceof EurekaInstanceConfigBean) { ConfigurableEnvironment environment = applicationContext.getEnvironment(); EurekaInstanceConfigBean eurekaInstanceConfig = (EurekaInstanceConfigBean) bean; eurekaInstanceConfig.setPreferIpAddress(true); Map metadataMap = eurekaInstanceConfig.getMetadataMap(); metadataMap.put(PluginConstant.SPRING_APPLICATION_DISCOVERY_PLUGIN, EurekaConstant.DISCOVERY_PLUGIN); metadataMap.put(PluginConstant.SPRING_APPLICATION_REGISTER_CONTROL_ENABLED, PluginContextAware.isRegisterControlEnabled(environment).toString()); metadataMap.put(PluginConstant.SPRING_APPLICATION_DISCOVERY_CONTROL_ENABLED, PluginContextAware.isDiscoveryControlEnabled(environment).toString()); metadataMap.put(PluginConstant.SPRING_APPLICATION_CONFIG_REST_CONTROL_ENABLED, PluginContextAware.isConfigRestControlEnabled(environment).toString()); metadataMap.put(PluginConstant.SPRING_APPLICATION_GROUP_KEY, PluginContextAware.getGroupKey(environment)); return bean; } else { return bean; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy