pl.allegro.tech.hermes.common.ssl.provided.ResourceLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hermes-common Show documentation
Show all versions of hermes-common Show documentation
Fast and reliable message broker built on top of Kafka.
package pl.allegro.tech.hermes.common.ssl.provided;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.net.URI;
import static com.google.common.base.Strings.isNullOrEmpty;
interface ResourceLoader {
default InputStream getResourceAsInputStream(URI location) throws FileNotFoundException {
if ("classpath".equalsIgnoreCase(location.getScheme())) {
return getClass().getClassLoader().getResourceAsStream(location.getSchemeSpecificPart());
}
return new FileInputStream(isNullOrEmpty(location.getPath()) ? location.getSchemeSpecificPart() : location.getPath());
}
}