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

com.nepxion.discovery.plugin.framework.configuration.PluginParserAutoConfiguration Maven / Gradle / Ivy

Go to download

Nepxion Discovery is a solution for Spring Cloud with blue green, gray, weight, limitation, circuit breaker, degrade, isolation, monitor, tracing, dye, failover, async agent

The newest version!
package com.nepxion.discovery.plugin.framework.configuration;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import com.nepxion.discovery.common.constant.DiscoveryConstant; import com.nepxion.discovery.common.entity.ConfigFormatType; import com.nepxion.discovery.common.exception.DiscoveryException; import com.nepxion.discovery.plugin.framework.parser.PluginConfigDeparser; import com.nepxion.discovery.plugin.framework.parser.PluginConfigParser; import com.nepxion.discovery.plugin.framework.parser.json.JsonConfigDeparser; import com.nepxion.discovery.plugin.framework.parser.json.JsonConfigParser; import com.nepxion.discovery.plugin.framework.parser.xml.XmlConfigDeparser; import com.nepxion.discovery.plugin.framework.parser.xml.XmlConfigParser; @Configuration public class PluginParserAutoConfiguration { @Autowired private Environment environment; @Bean public PluginConfigParser pluginConfigParser() { String configFormat = environment.getProperty(DiscoveryConstant.SPRING_APPLICATION_CONFIG_FORMAT, String.class, DiscoveryConstant.XML_FORMAT); ConfigFormatType configFormatType = ConfigFormatType.fromString(configFormat); switch (configFormatType) { case XML_FORMAT: return new XmlConfigParser(); case JSON_FORMAT: return new JsonConfigParser(); } throw new DiscoveryException("Invalid config format for '" + configFormat + "'"); } @Bean public PluginConfigDeparser pluginDeconfigParser() { String configFormat = environment.getProperty(DiscoveryConstant.SPRING_APPLICATION_CONFIG_FORMAT, String.class, DiscoveryConstant.XML_FORMAT); ConfigFormatType configFormatType = ConfigFormatType.fromString(configFormat); switch (configFormatType) { case XML_FORMAT: return new XmlConfigDeparser(); case JSON_FORMAT: return new JsonConfigDeparser(); } throw new DiscoveryException("Invalid config format for '" + configFormat + "'"); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy