Sam- Care you supply a patch to include this?
On Thu, Jun 16, 2011 at 7:35 AM, sam lee <[email protected]> wrote: > I ended up walking resource myself: > > private void visit(Resource resource) { > //actually do something.. like, adding to sitemap. > } > > > public void walkBreathFirst(Resource resource) { > final Queue<Resource> toVisit = new > ConcurrentLinkedQueue<Resource>(); > try { > toVisit.add(resource); > while (!toVisit.isEmpty()) { > final Resource visitedResource = toVisit.remove(); > visit(visitedResource); > > final Iterator<Resource> iter = > visitedResource.listChildren(); > while (iter.hasNext()) { > toVisit.add(iter.next()); > } > } > } catch (SitemapException e) { > > } > } > > On Thu, Jun 16, 2011 at 9:47 AM, sam lee <[email protected]> wrote: > >> Hey, >> >> I need to walk a large resource tree (for sitemap generation, for example). >> >> I'm aware of javax.jcr.ItemVisitor .. But I want to visit Resources >> instead, not Nodes. >> I could use ItemVisitor and elevate Nodes to Resources using >> ResourceResolver: >> >> @Override >> public void visit(Node node) throws RepositoryException { >> resolver.getResource(node.getPath()); >> } >> >> >> Is there a better way? I want to implement void visit(Resource >> resource); if possible. >> >> If I were to write my own ResourceVisitor, I would use recursion. But is >> recursion safe for a large tree? >> Looking at source code of javax.jcr.util.TraversingItemVisitor, it uses >> simple recursion too (with a queue for breathfirst traversal). >> >> What is a recommended way of walking a large resource tree? >> >> >> >
