Search in sources :

Example 6 with VirtualFileFilter

use of org.jboss.vfs.VirtualFileFilter in project wildfly by wildfly.

the class JdrTestCase method testWildcardFilterMiddleGlob.

@Test
public void testWildcardFilterMiddleGlob() throws Exception {
    VirtualFileFilter filter = Filters.wildcard("/this*test.txt");
    VirtualFile good = VFS.getChild("/this/is/a/test.txt");
    VirtualFile bad1 = VFS.getChild("/that/is/a/test.txt");
    VirtualFile bad2 = VFS.getChild("/this/is/a/test.xml");
    VirtualFile win = VFS.getChild("/C:/this/is/a/test.txt");
    VirtualFile winbad = VFS.getChild("/C:/this/is/a/test.xml");
    assertTrue(filter.accepts(good));
    assertTrue(filter.accepts(win));
    assertFalse(filter.accepts(bad1));
    assertFalse(filter.accepts(bad2));
    assertFalse(filter.accepts(winbad));
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) Test(org.junit.Test)

Example 7 with VirtualFileFilter

use of org.jboss.vfs.VirtualFileFilter in project wildfly by wildfly.

the class KernelDeploymentParsingProcessor method parseDescriptors.

/**
     * Find and parse -jboss-beans.xml files.
     *
     * @param unit the deployment unit
     * @param root the root
     * @throws DeploymentUnitProcessingException
     *          for any error
     */
protected void parseDescriptors(DeploymentUnit unit, VirtualFile root) throws DeploymentUnitProcessingException {
    if (root == null || root.exists() == false)
        return;
    Collection<VirtualFile> beans;
    final String name = root.getName();
    if (name.endsWith("jboss-beans.xml")) {
        beans = Collections.singleton(root);
    } else {
        VirtualFileFilter filter = new SuffixMatchFilter("jboss-beans.xml");
        beans = new ArrayList<VirtualFile>();
        try {
            // try plain .jar/META-INF
            VirtualFile metainf = root.getChild("META-INF");
            if (metainf.exists())
                beans.addAll(metainf.getChildren(filter));
            // allow for WEB-INF/*-jboss-beans.xml
            VirtualFile webinf = root.getChild("WEB-INF");
            if (webinf.exists()) {
                beans.addAll(webinf.getChildren(filter));
                // allow WEB-INF/classes/META-INF
                metainf = webinf.getChild("classes/META-INF");
                if (metainf.exists())
                    beans.addAll(metainf.getChildren(filter));
            }
        } catch (IOException e) {
            throw new DeploymentUnitProcessingException(e);
        }
    }
    for (VirtualFile beansXmlFile : beans) parseDescriptor(unit, beansXmlFile);
}
Also used : VirtualFile(org.jboss.vfs.VirtualFile) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) VirtualFileFilter(org.jboss.vfs.VirtualFileFilter) SuffixMatchFilter(org.jboss.vfs.util.SuffixMatchFilter) IOException(java.io.IOException)

Aggregations

VirtualFileFilter (org.jboss.vfs.VirtualFileFilter)7 VirtualFile (org.jboss.vfs.VirtualFile)6 Test (org.junit.Test)5 IOException (java.io.IOException)1 TreeSet (java.util.TreeSet)1 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)1 SuffixMatchFilter (org.jboss.vfs.util.SuffixMatchFilter)1