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

com.pongsky.kit.config.property.InstancePropertySource Maven / Gradle / Ivy

There is a newer version: 3.10.1-2.4.13
Show newest version
package com.pongsky.kit.config.property;

import org.springframework.core.env.PropertySource;
import org.springframework.core.log.LogMessage;

import javax.annotation.Nonnull;

/**
 * 应用实例ID属性配置信息
 *
 * @author pengsenhao
 */
public class InstancePropertySource extends PropertySource {

    /**
     * 自定义属性 key
     */
    private static final String BROKER_ID_PROPERTY_SOURCE_NAME = "brokerId";

    public InstancePropertySource() {
        super(BROKER_ID_PROPERTY_SOURCE_NAME, new Instance());
    }

    @Override
    public Object getProperty(@Nonnull String name) {
        if (!BROKER_ID_PROPERTY_SOURCE_NAME.equals(name)) {
            return null;
        }
        logger.trace(LogMessage.format("Generating brokerId property for '%s'", name));
        return getSource().getId();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy