be.atbash.config.source.AliasConfigSource Maven / Gradle / Ivy
/*
* Copyright 2017-2019 Rudy De Busscher
*
* 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 be.atbash.config.source;
import be.atbash.util.StringUtils;
import be.atbash.util.exception.AtbashUnexpectedException;
import be.atbash.util.resource.ResourceScanner;
import be.atbash.util.resource.ResourceUtil;
import org.eclipse.microprofile.config.ConfigProvider;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class AliasConfigSource implements ConfigSource {
private Logger logger = LoggerFactory.getLogger(AliasConfigSource.class);
private Map keyMapping;
private List usedOldKeys;
public AliasConfigSource() {
usedOldKeys = new ArrayList<>();
Set resources = ResourceScanner.getInstance().getResources("config/alias.*.properties");
keyMapping = new HashMap<>();
for (String resource : resources) {
keyMapping.putAll(readMapping(resource));
}
}
private Map readMapping(String resource) {
Map result = new HashMap<>();
try {
InputStream stream = ResourceUtil.getInstance().getStream(ResourceUtil.CLASSPATH_PREFIX + resource);
Properties properties = new Properties();
properties.load(stream);
stream.close();
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy