Parses the specified path for modules with relevant annotations and caches new entries. @param root root path @param ctx database context @param cache cached modules @param old old cache @throws QueryException query exception @throws IOException I/O exception
(final Context ctx, final IOFile root,
final HashMap<String, WebModule> cache, final HashMap<String, WebModule> old)
| 353 | * @throws IOException I/O exception |
| 354 | */ |
| 355 | private static void parse(final Context ctx, final IOFile root, |
| 356 | final HashMap<String, WebModule> cache, final HashMap<String, WebModule> old) |
| 357 | throws QueryException, IOException { |
| 358 | |
| 359 | // check if directory is to be skipped |
| 360 | final IOFile[] files = root.children(); |
| 361 | for(final IOFile file : files) { |
| 362 | if(file.name().equals(IO.IGNORESUFFIX)) return; |
| 363 | } |
| 364 | |
| 365 | for(final IOFile file : files) { |
| 366 | if(file.isDir()) { |
| 367 | parse(ctx, file, cache, old); |
| 368 | } else { |
| 369 | final String path = file.path(); |
| 370 | if(file.hasSuffix(IO.XQSUFFIXES)) { |
| 371 | // retrieve existing module or create new instance |
| 372 | WebModule module = old.get(path); |
| 373 | if(module == null) module = new WebModule(file); |
| 374 | |
| 375 | // parse updated module, add to cache |
| 376 | module.parse(ctx); |
| 377 | cache.put(path, module); |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 | } |