1 57 58 package org.apache.commons.discovery; 59 60 import java.io.IOException ; 61 import java.io.InputStream ; 62 import java.net.URL ; 63 64 import org.apache.commons.discovery.log.DiscoveryLogFactory; 65 import org.apache.commons.discovery.resource.DiscoverResources; 66 import org.apache.commons.logging.Log; 67 68 69 80 public class Resource 81 { 82 private static Log log = DiscoveryLogFactory.newLog(DiscoverResources.class); 83 public static void setLog(Log _log) { 84 log = _log; 85 } 86 protected final String name; 87 protected final URL resource; 88 protected final ClassLoader loader; 89 90 public Resource(String resourceName, URL resource, ClassLoader loader) { 91 this.name = resourceName; 92 this.resource = resource; 93 this.loader = loader; 94 95 if (log.isDebugEnabled()) 96 log.debug("new " + this); 97 } 98 99 103 public String getName() { 104 return name; 105 } 106 107 111 public URL getResource() { 112 return resource; 113 } 114 115 119 public InputStream getResourceAsStream() { 120 try { 121 return resource.openStream(); 122 } catch (IOException e) { 123 return null; } 125 } 126 127 131 public ClassLoader getClassLoader() { 132 return loader ; 133 } 134 } 135 | Popular Tags |