Recursive method to search for JAR files starting at a given level @param file The directory to search in @param jars A list of file objects that will be loaded with discovered jar files @throws SecurityException if a security manager exists and prevents reading
(final File file, List<File> jars)
| 225 | * @throws SecurityException if a security manager exists and prevents reading |
| 226 | */ |
| 227 | private static void searchForJars(final File file, List<File> jars) { |
| 228 | if (file.isFile()) { |
| 229 | if (file.getAbsolutePath().toLowerCase().endsWith(".jar")) { |
| 230 | jars.add(file); |
| 231 | LOG.debug("Found a jar: " + file.getAbsolutePath()); |
| 232 | } |
| 233 | } else if (file.isDirectory()) { |
| 234 | File[] files = file.listFiles(); |
| 235 | if (files == null) { |
| 236 | // if this is null, it's due to a security issue |
| 237 | LOG.warn("Access denied to directory: " + file.getAbsolutePath()); |
| 238 | } else { |
| 239 | for (File f : files) { |
| 240 | searchForJars(f, jars); |
| 241 | } |
| 242 | } |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Attempts to add the given file object to the class loader |