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

com.nepxion.discovery.plugin.admincenter.resource.ConfigResourceImpl 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.admincenter.resource;

/**
 * 

Title: Nepxion Discovery

*

Description: Nepxion Discovery

*

Copyright: Copyright (c) 2017-2050

*

Company: Nepxion

* @author Haojun Ren * @version 1.0 */ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import com.nepxion.discovery.common.entity.ConfigType; import com.nepxion.discovery.common.entity.RuleEntity; import com.nepxion.discovery.common.entity.SubscriptionType; import com.nepxion.discovery.common.exception.DiscoveryException; import com.nepxion.discovery.plugin.framework.adapter.PluginAdapter; import com.nepxion.discovery.plugin.framework.adapter.PluginConfigAdapter; import com.nepxion.discovery.plugin.framework.event.PluginEventWapper; import com.nepxion.discovery.plugin.framework.event.RuleClearedEvent; import com.nepxion.discovery.plugin.framework.event.RuleUpdatedEvent; public class ConfigResourceImpl implements ConfigResource { private static final Logger LOG = LoggerFactory.getLogger(ConfigResourceImpl.class); @Autowired private PluginAdapter pluginAdapter; @Autowired(required = false) private PluginConfigAdapter pluginConfigAdapter; @Autowired private PluginEventWapper pluginEventWapper; @Override public ConfigType getConfigType() { if (pluginConfigAdapter == null) { LOG.error("Remote config adapter isn't provided"); throw new DiscoveryException("Remote config adapter isn't provided"); } return pluginConfigAdapter.getConfigType(); } @Override public void update(String config, boolean async) { pluginEventWapper.fireRuleUpdated(new RuleUpdatedEvent(SubscriptionType.PARTIAL, config), async); } @Override public void clear(boolean async) { pluginEventWapper.fireRuleCleared(new RuleClearedEvent(SubscriptionType.PARTIAL), async); } @Override public List view() { List ruleList = new ArrayList(3); String localRuleContent = StringUtils.EMPTY; RuleEntity localRuleEntity = pluginAdapter.getLocalRule(); if (localRuleEntity != null && StringUtils.isNotEmpty(localRuleEntity.getContent())) { localRuleContent = localRuleEntity.getContent(); } String dynamicGlobalRuleContent = StringUtils.EMPTY; RuleEntity dynamicGlobalRuleEntity = pluginAdapter.getDynamicGlobalRule(); if (dynamicGlobalRuleEntity != null && StringUtils.isNotEmpty(dynamicGlobalRuleEntity.getContent())) { dynamicGlobalRuleContent = dynamicGlobalRuleEntity.getContent(); } String dynamicPartialRuleContent = StringUtils.EMPTY; RuleEntity dynamicPartialRuleEntity = pluginAdapter.getDynamicPartialRule(); if (dynamicPartialRuleEntity != null && StringUtils.isNotEmpty(dynamicPartialRuleEntity.getContent())) { dynamicPartialRuleContent = dynamicPartialRuleEntity.getContent(); } ruleList.add(localRuleContent); ruleList.add(dynamicGlobalRuleContent); ruleList.add(dynamicPartialRuleContent); return ruleList; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy