
org.snapscript.common.store.ClassPathLoader Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap-all Show documentation
Show all versions of snap-all Show documentation
Dynamic scripting for the JVM
package org.snapscript.common.store;
import java.io.InputStream;
public class ClassPathLoader {
private final Class type;
public ClassPathLoader(Class type) {
this.type = type;
}
public InputStream loadResource(String path) {
Thread thread = Thread.currentThread();
ClassLoader context = thread.getContextClassLoader();
InputStream source = context.getResourceAsStream(path);
if(source == null) {
ClassLoader caller = type.getClassLoader();
if(caller != context) {
return caller.getResourceAsStream(path);
}
}
return source;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy