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

org.zeroturnaround.javarebel.integration.confluence.ConfluenceClassResourceSource Maven / Gradle / Ivy

The newest version!
package org.zeroturnaround.javarebel.integration.confluence;

import java.net.URL;
import org.zeroturnaround.javarebel.ClassResourceSource;
import org.zeroturnaround.javarebel.Resource;
import org.zeroturnaround.javarebel.integration.util.ResourceUtil;
import org.zeroturnaround.javarebel.support.URLResource;

public class ConfluenceClassResourceSource implements ClassResourceSource {  
  private ClassLoader classloader;
  
  public ConfluenceClassResourceSource(ClassLoader classloader) {
    this.classloader = classloader;
  }
  
  public Resource getLocalResource(String name) {
    URL url = ResourceUtil.findResource(classloader, name);
    
    if (url == null)
      return null;
    
    return new URLResource(url);
  }

  public Resource[] getLocalResources(String name) {
    URL[] urls = ResourceUtil.findResources(classloader, name);
    
    if (urls == null)
      return null;
    
    URLResource[] result = new URLResource[urls.length];
    for (int i = 0; i < urls.length; i++) {
      result[i] = new URLResource(urls[i]);
    }
    return result;
  }

  public Resource getClassResource(String className) {
    URL url = ResourceUtil.findResource(classloader, className.replace('.', '/') + ".class");
    
    if (url == null)
      return null;
    
    return new URLResource(url);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy