com.nepxion.discovery.plugin.configcenter.configuration.ConfigAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of discovery-plugin-config-center Show documentation
Show all versions of discovery-plugin-config-center Show documentation
Nepxion Discovery is an enhancement for Spring Cloud Discovery
package com.nepxion.discovery.plugin.configcenter.configuration;
/**
* Title: Nepxion Discovery
* Description: Nepxion Discovery
* Copyright: Copyright (c) 2017-2050
* Company: Nepxion
* @author Haojun Ren
* @version 1.0
*/
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.nepxion.discovery.common.constant.DiscoveryConstant;
import com.nepxion.discovery.common.exception.DiscoveryException;
import com.nepxion.discovery.plugin.configcenter.ConfigInitializer;
import com.nepxion.discovery.plugin.configcenter.loader.LocalConfigLoader;
import com.nepxion.discovery.plugin.configcenter.parser.json.JsonConfigParser;
import com.nepxion.discovery.plugin.configcenter.parser.xml.XmlConfigParser;
import com.nepxion.discovery.plugin.framework.config.PluginConfigParser;
import com.nepxion.discovery.plugin.framework.context.PluginContextAware;
@Configuration
public class ConfigAutoConfiguration {
@Autowired
private PluginContextAware pluginContextAware;
@Bean
public PluginConfigParser pluginConfigParser() {
String configFormat = pluginContextAware.getConfigFormat();
if (StringUtils.equals(configFormat, DiscoveryConstant.XML_FORMAT)) {
return new XmlConfigParser();
} else if (StringUtils.equals(configFormat, DiscoveryConstant.JSON_FORMAT)) {
return new JsonConfigParser();
}
throw new DiscoveryException("Invalid config format for '" + configFormat + "'");
}
@Bean
public LocalConfigLoader localConfigLoader() {
return new LocalConfigLoader() {
@Override
protected String getPath() {
return pluginContextAware.getConfigPath();
}
};
}
@Bean
public ConfigInitializer configInitializer() {
return new ConfigInitializer();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy