Federated resource visitor
alesj Oct 1, 2008 6:41 AMIn order to impl Seam's tight integration with existing JBoss5/MC AnnotationEnvironment / ResourceVisitor (RV) pattern:
- https://jira.jboss.org/jira/browse/JBAS-6012
I need a sort of federated resource visitor - in order not to visit same resources many times.
e.g. with Seam deployment I would need to check for
- annotations (we already do this via GenericAnnotationRV)
- different configuration files; xmls, .properties, ...
hence requiring RV per resource.
I've hacked this FederatedVFSVR:
protected boolean acceptRecurseFilter(VirtualFile file) { if (recurseFilters == null || recurseFilters.length == 0) return true; String path = determinePath(file); ResourceContext resource = new VFSResourceContext(file, path, getClassLoader()); boolean accept = false; for (int j = 0; j < recurseFilters.length; j++) { recurseFlags[j] = recurseFilters[j] == null || recurseFilters[j].accepts(resource); if (recurseFlags[j]) // one accepts it accept = true; } return accept; } public void visit(VirtualFile file) { try { // We don't want directories if (file.isLeaf() == false) return; // Determine the resource name String path = determinePath(file); // go over the true flags for (int j = 0; j < visitors.length; j++) { if (recurseFlags == null || recurseFlags.length <= i || recurseFlags[j]) { // Check for inclusions/exclusions if (includeds != null && includeds.length > j && includeds[j] != null && includeds[j].matchesResourcePath(path) == false) continue; if (excludeds != null && excludeds.length > j && excludeds[j] != null && excludeds[j].matchesResourcePath(path)) continue; ResourceContext resource = new VFSResourceContext(file, path, getClassLoader()); //Check the filter and visit if (filters == null || filters.length <= j || filters[j] == null || filters[j].accepts(resource)) visitors[j].visit(resource); } } } catch (Exception e) { throw new Error("Error visiting " + file, e); } }
But I would need to somehow enable its usage in VFSClassLoaderPolicyModule,
where we actually 'hit' the Module.
Should I again expand Module::visit method,
to take multiple visitors, filters, recurseFilters?
Back-porting the old behavior to call the old non-federated single VFS VR.