org.jboss.vfs.VirtualFileFilter Java Examples

The following examples show how to use org.jboss.vfs.VirtualFileFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CamelContextDescriptorsProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

    final DeploymentUnit depUnit = phaseContext.getDeploymentUnit();
    final String runtimeName = depUnit.getName();

    CamelDeploymentSettings.Builder depSettings = depUnit.getAttachment(CamelDeploymentSettings.BUILDER_ATTACHMENT_KEY);
    if (depSettings.isDisabledByJbossAll() || !depSettings.isDeploymentValid() || runtimeName.endsWith(".ear")) {
        return;
    }

    try {
        boolean addedAny = false;
        if (runtimeName.endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX)) {
            URL fileURL = depUnit.getAttachment(Attachments.DEPLOYMENT_CONTENTS).asFileURL();
            addedAny |= addConditionally(depUnit, depSettings, fileURL);
        } else {
            VirtualFileFilter filter = new VirtualFileFilter() {
                public boolean accepts(VirtualFile child) {
                    return child.isFile() && child.getName().endsWith(CamelConstants.CAMEL_CONTEXT_FILE_SUFFIX);
                }
            };
            VirtualFile rootFile = depUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot();
            for (VirtualFile vfile : rootFile.getChildrenRecursively(filter)) {
                addedAny |= addConditionally(depUnit, depSettings, vfile.asFileURL());
            }
        }

        if (addedAny) {
            LOGGER.info("Camel context descriptors found");
        }
    } catch (IOException ex) {
        throw new IllegalStateException("Cannot create camel context: " + runtimeName, ex);
    }
}