[jboss-dev-forums] [Design the new POJO MicroContainer] - Federated resource visitor

alesj do-not-reply at jboss.com
Wed Oct 1 06:41:40 EDT 2008


In 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.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4179746#4179746

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4179746



More information about the jboss-dev-forums mailing list