[jboss-user] [JBoss Microcontainer] - Is it possible to add classloader root with wildcard pattern?
Ales Justin
do-not-reply at jboss.com
Wed Jul 14 06:46:32 EDT 2010
Ales Justin [http://community.jboss.org/people/alesj] replied to the discussion
"Is it possible to add classloader root with wildcard pattern?"
To view the discussion, visit: http://community.jboss.org/message/552495#552495
--------------------------------------------------------------
> Feel free to suggest a proper patch which would handle this wildcard matching.
List<VirtualFile> vfsRoots = new ArrayList<VirtualFile>();
for (String root : roots)
{
int wc = root.lastIndexOf("*"); // is it wildcard
if (wc >= 0)
{
final String wcString = root.substring(wc + 1);
VirtualFile start;
if (wc > 0) // some more path before
{
start = VFS.getChild(root.substring(0, wc));
}
else
{
start = VFS.getRootVirtualFile();
}
try
{
List<VirtualFile> children = start.getChildren(new VirtualFileFilter()
{
public boolean accepts(VirtualFile file)
{
String name = file.getName();
return name.endsWith(wcString);
}
});
vfsRoots.addAll(children);
}
catch (IOException e)
{
throw new RuntimeException("Error creating VFS files for " + root, e);
}
}
else
{
try
{
URI uri = new URI(root);
vfsRoots.add(VFS.getChild(uri));
}
catch (URISyntaxException e)
{
throw new RuntimeException("Error creating VFS file for " + root, e);
}
}
}
this.vfsRoots = vfsRoots.toArray(new VirtualFile[vfsRoots.size()]);
This would do it for wildcard.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/552495#552495]
Start a new discussion in JBoss Microcontainer at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2114]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100714/f1d64bf7/attachment-0001.html
More information about the jboss-user
mailing list