@Override protected T parse(DeploymentUnit unit, String name, T root) throws Exception { // Try to find the metadata VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; VirtualFile file = vfsDeploymentUnit.getMetaDataFile(name); if (file == null) return null; T result = parse(vfsDeploymentUnit, file, root); if (result != null) init(vfsDeploymentUnit, result, file); return result; }
/** * Parse the file, initialize the result if exists. * * @param unit the deployment unit * @param file the file * @param root the root * @param checkIgnore do we check for ignored names * @return parsed result * @throws Exception for any error */ protected T parseAndInit(VFSDeploymentUnit unit, VirtualFile file, T root, boolean checkIgnore) throws Exception { if (checkIgnore && ignoreFile(unit, file)) return null; T result = parse(unit, file, root); if (result != null) init(unit, result, file); return result; }
@Override protected T parse(DeploymentUnit unit, String name, String suffix, T root) throws Exception { // Should we include the deployment // The infrastructure will only check leafs anyway so no need to check here if (name == null && isIncludeDeploymentFile()) name = unit.getName(); // Try to find the metadata VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit; List<VirtualFile> files = vfsDeploymentUnit.getMetaDataFiles(name, suffix); if (files.size() == 0) return null; // TODO JBMICROCONT-184 remove this limitation if (files.size() > 1) throw new DeploymentException("Only one file is allowed, found=" + files); VirtualFile file = files.get(0); T result = parse(vfsDeploymentUnit, file, root); if (result != null) init(vfsDeploymentUnit, result, file); return result; }
/** * Handle multiple files. * * @param unit the vfs deployment unit * @param root possibly null pre-existing root * @param files the matching files * @return null or merged single result * @throws Exception for any error */ protected T handleMultipleFiles(VFSDeploymentUnit unit, T root, List<VirtualFile> files) throws Exception { if (allowsMultipleFiles(files) == false) throw new IllegalArgumentException("Multiple matching files not allowed: " + files); for (VirtualFile file : files) { if (ignoreFile(unit, file) == false) { T result = parse(unit, file, root); if (result != null) { init(unit, result, file); unit.addAttachment(file.toURL().toString(), result, getOutput()); } } } return null; }