1 61 62 package org.apache.commons.discovery.jdk; 63 64 import java.util.Enumeration ; 65 import java.io.IOException ; 66 67 68 71 class JDK11Hooks extends JDKHooks { 72 private static final ClassLoader systemClassLoader 73 = new PsuedoSystemClassLoader(); 74 75 76 83 public ClassLoader getThreadContextClassLoader() { 84 return null; 85 } 86 87 94 public ClassLoader getSystemClassLoader() { 95 return systemClassLoader; 96 } 97 98 105 public Enumeration getResources(ClassLoader loader, 106 String resourceName) 107 throws IOException 108 { 109 132 133 final URL first = (URL)loader.getResource(resourceName); 134 final Enumeration rest = loader.getResources(resourceName); 135 136 return new Enumeration () { 137 private boolean firstDone = (first == null); 138 private URL next = getNext(); 139 140 public Object nextElement() { 141 URL o = next; 142 next = getNext(); 143 return o; 144 } 145 146 public boolean hasMoreElements() { 147 return next != null; 148 } 149 150 private URL getNext() { 151 URL n; 152 153 if (!firstDone) { 154 158 firstDone = true; 159 n = first; 160 } else { 161 169 n = null; 170 while (rest.hasMoreElements() && n == null) { 171 n = (URL)rest.nextElement(); 172 if (first != null && 173 n != null && 174 n.equals(first)) 175 { 176 n = null; 177 } 178 } 179 } 180 181 return n; 182 } 183 }; 184 } 185 } 186 | Popular Tags |