com.pongsky.kit.config.property.InstancePropertySource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of config-core Show documentation
Show all versions of config-core Show documentation
Java 增强套件 之 config-core 模块
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();
}
}