[jboss-cvs] JBossAS SVN: r103684 - projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/filter.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 8 05:16:18 EDT 2010
Author: alesj
Date: 2010-04-08 05:16:17 -0400 (Thu, 08 Apr 2010)
New Revision: 103684
Modified:
projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/filter/ScanningMetaDataRecurseFilter.java
Log:
Smarter recurse filter.
Modified: projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/filter/ScanningMetaDataRecurseFilter.java
===================================================================
--- projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/filter/ScanningMetaDataRecurseFilter.java 2010-04-08 09:02:45 UTC (rev 103683)
+++ projects/scanning/trunk/scanning-impl/src/main/java/org/jboss/scanning/plugins/filter/ScanningMetaDataRecurseFilter.java 2010-04-08 09:16:17 UTC (rev 103684)
@@ -22,7 +22,10 @@
package org.jboss.scanning.plugins.filter;
import java.net.URL;
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.jboss.classloading.spi.visitor.ResourceContext;
import org.jboss.classloading.spi.visitor.ResourceFilter;
@@ -39,7 +42,8 @@
*/
public class ScanningMetaDataRecurseFilter implements ResourceFilter
{
- private Set<Node> roots;
+ /** Path tree roots */
+ private Map<String, RootNode> roots;
public ScanningMetaDataRecurseFilter(ScanningMetaData smd)
{
@@ -49,14 +53,15 @@
List<PathMetaData> paths = smd.getPaths();
if (paths != null && paths.isEmpty() == false)
{
- roots = new HashSet<Node>();
+ roots = new HashMap<String, RootNode>();
for (PathMetaData pmd : paths)
{
- Node pathNode = new Node(pmd.getPathName());
- roots.add(pathNode);
+ RootNode pathNode = new RootNode();
+ roots.put(pmd.getPathName(), pathNode);
Set<PathEntryMetaData> includes = pmd.getIncludes();
if (includes != null && includes.isEmpty() == false)
{
+ pathNode.explicitInclude = true;
for (PathEntryMetaData pemd : includes)
{
String name = pemd.getName();
@@ -77,20 +82,24 @@
URL url = resource.getUrl();
String urlString = url.toExternalForm();
- for (Node root : roots)
+ for (Map.Entry<String, RootNode> root : roots.entrySet())
{
- if (urlString.contains(root.value))
+ if (urlString.contains(root.getKey()))
{
- String resourceName = resource.getResourceName();
- List<String> tokens = PathTokenizer.getTokens(resourceName);
- Node current = root;
- // let's try to walk some tree path
- for (String token : tokens)
+ RootNode rootNode = root.getValue();
+ if (rootNode.explicitInclude) // we have explicit includes in path, try tree path
{
- current = current.getChild(token);
- // no fwd path
- if (current == null)
- return false;
+ String resourceName = resource.getResourceName();
+ List<String> tokens = PathTokenizer.getTokens(resourceName);
+ Node current = rootNode;
+ // let's try to walk some tree path
+ for (String token : tokens)
+ {
+ current = current.getChild(token);
+ // no fwd path
+ if (current == null)
+ return false;
+ }
}
return true;
}
@@ -100,14 +109,8 @@
private static class Node
{
- private String value;
private Map<String, Node> children;
- private Node(String value)
- {
- this.value = value;
- }
-
public Node addChild(String value)
{
if (children == null)
@@ -116,20 +119,20 @@
Node child = children.get(value);
if (child == null)
{
- child = new Node(value);
+ child = new Node();
children.put(value, child);
}
return child;
}
- public String getValue()
- {
- return value;
- }
-
public Node getChild(String child)
{
return children != null ? children.get(child) : null;
}
}
+
+ private static class RootNode extends Node
+ {
+ private boolean explicitInclude;
+ }
}
More information about the jboss-cvs-commits
mailing list