package org.apache.logging.log4j.core.util;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.osgi.framework.Bundle;

public final class BundleResourceLoader implements ResourceLoader {
   private final Bundle bundle;

   public BundleResourceLoader(Bundle bundle) {
      this.bundle = bundle;
   }

   public Class<?> loadClass(String name) throws ClassNotFoundException {
      return this.bundle.loadClass(name);
   }

   public URL getResource(String name) {
      return this.bundle.getResource(name);
   }

   public Enumeration<URL> getResources(String name) throws IOException {
      Enumeration<URL> enumeration = this.bundle.getResources(name);
      return enumeration;
   }

   public String toString() {
      return this.getClass().getCanonicalName() + ": " + this.bundle.getSymbolicName();
   }
}
