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

io.tracee.configuration.TraceePropertiesFileLoader Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package io.tracee.configuration;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;

public final class TraceePropertiesFileLoader {

	public static final String TRACEE_PROPERTIES_FILE = "META-INF/tracee.properties";
	public static final String TRACEE_DEFAULT_PROPERTIES_FILE = "META-INF/tracee.default.properties";

	public Properties loadTraceeProperties(String traceePropertiesFile) throws IOException {
		final Properties propertiesFromFile = new Properties();
		final ClassLoader loader = Thread.currentThread().getContextClassLoader();
		final Enumeration traceePropertyFiles = loader.getResources(traceePropertiesFile);

		while (traceePropertyFiles.hasMoreElements()) {
			final URL url = traceePropertyFiles.nextElement();
			InputStream stream = null;
			try {
				stream = url.openStream();
				propertiesFromFile.load(stream);
			} finally {
				try {
					if (stream != null)
						stream.close();
				} catch (IOException ignored) { }
			}
		}

		return propertiesFromFile;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy