org.zeroturnaround.javarebel.integration.confluence.ConfluenceClassResourceSource Maven / Gradle / Ivy
package org.zeroturnaround.javarebel.integration.confluence;
import java.net.URL;
import org.zeroturnaround.javarebel.ClassResource;
import org.zeroturnaround.javarebel.ClassResourceSource;
import org.zeroturnaround.javarebel.LoggerFactory;
import org.zeroturnaround.javarebel.integration.util.ResourceUtil;
import org.zeroturnaround.javarebel.support.FallbackClassResource;
public class ConfluenceClassResourceSource implements ClassResourceSource {
private ClassLoader classloader;
public ConfluenceClassResourceSource(ClassLoader classloader) {
this.classloader = classloader;
}
public ClassResource getLocalResource(String name) {
URL url = ResourceUtil.findResource(classloader, name);
if (url == null)
return null;
LoggerFactory.getInstance().log("Found URL '" + url + "' for resource '" + name + "'.");
return new FallbackClassResource(url);
}
public ClassResource[] getLocalResources(String name) {
URL[] urls = ResourceUtil.findResources(classloader, name);
if (urls == null)
return null;
FallbackClassResource[] result = new FallbackClassResource[urls.length];
for (int i = 0; i < urls.length; i++) {
result[i] = new FallbackClassResource(urls[i]);
LoggerFactory.getInstance().log("Found URL '" + urls[i] + "' for resource '" + name + "'.");
}
return result;
}
public ClassResource getClassResource(String className) {
URL url = ResourceUtil.findResource(classloader, className.replace('.', '/') + ".class");
if (url == null)
return null;
LoggerFactory.getInstance().log("Found URL '" + url + "' for class '" + className + "'.");
return new FallbackClassResource(url);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy