Search in sources :

Example 1 with ChangeType

use of com.tencent.polaris.configuration.api.core.ChangeType in project polaris-java by polarismesh.

the class DefaultConfigFile method onChange.

@Override
public void onChange(ConfigFileMetadata configFileMetadata, String newContent) {
    String oldContent = this.content;
    this.content = newContent;
    ChangeType changeType = ChangeType.MODIFIED;
    if (oldContent == null) {
        changeType = ChangeType.ADDED;
    }
    if (newContent == null) {
        changeType = ChangeType.DELETED;
    }
    if (Objects.equals(oldContent, newContent)) {
        changeType = ChangeType.NOT_CHANGED;
    }
    if (objectCache != null) {
        objectCache.invalidateAll();
        cacheVersion.incrementAndGet();
    }
    fireChangeEvent(new ConfigFileChangeEvent(configFileMetadata, oldContent, newContent, changeType));
}
Also used : ChangeType(com.tencent.polaris.configuration.api.core.ChangeType) ConfigFileChangeEvent(com.tencent.polaris.configuration.api.core.ConfigFileChangeEvent)

Aggregations

ChangeType (com.tencent.polaris.configuration.api.core.ChangeType)1 ConfigFileChangeEvent (com.tencent.polaris.configuration.api.core.ConfigFileChangeEvent)1