Search in sources :

Example 11 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)11 VirtualFile (org.jboss.vfs.VirtualFile)10 IOException (java.io.IOException)5 Test (org.junit.Test)5 TreeSet (java.util.TreeSet)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 URL (java.net.URL)1 SuffixMatchFilter (org.jboss.vfs.util.SuffixMatchFilter)1 UDFMetaData (org.teiid.deployers.UDFMetaData)1