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

org.cattleframework.cloud.discovery.nacos.NacosCloudDiscoveryProperties Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.cattleframework.cloud.discovery.nacos;

import org.cattleframework.cloud.discovery.BaseCloudDiscoveryProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.env.Environment;

import com.alibaba.cloud.commons.lang.StringUtils;

/**
 * Nacos服务发现属性配置
 * 
 * @author orange
 *
 */
@ConfigurationProperties("cattle.cloud.discovery.nacos")
public class NacosCloudDiscoveryProperties extends BaseCloudDiscoveryProperties {

    @Value("${spring.cloud.nacos.discovery.namespace:public}")
    private String namespace;

    @Value("${spring.cloud.nacos.username:}")
    private String username;

    @Value("${spring.cloud.nacos.password:}")
    private String password;

    @Value("${spring.cloud.nacos.discovery.group:DEFAULT_GROUP}")
    private String group;

    public String getNamespace() {
	return namespace;
    }

    public void setNamespace(String namespace) {
	this.namespace = namespace;
    }

    public String getUsername() {
	return username;
    }

    public void setUsername(String username) {
	this.username = username;
    }

    public String getPassword() {
	return password;
    }

    public void setPassword(String password) {
	this.password = password;
    }

    public String getGroup() {
	return group;
    }

    public void setGroup(String group) {
	this.group = group;
    }

    @Override
    protected void overrideFromEnv(Environment environment) {
	if (StringUtils.isBlank(getAddress())) {
	    String serverAddr = environment.resolvePlaceholders("${spring.cloud.nacos.discovery.server-addr:}");
	    if (StringUtils.isBlank(serverAddr)) {
		serverAddr = environment.resolvePlaceholders("${spring.cloud.nacos.server-addr:127.0.0.1:8848}");
	    }
	    setAddress(serverAddr);
	}
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy