@Test public void canReferenceAbsolutePathInClassPathEntry() throws Exception { Collection<? extends File> jars = bsc.getJarsFromClasspathEntry(getTemplateParentPath("backing"), bundles.getAbsolutePath()); assertThat(jars).hasSize(1); }
Collection<File> getJarsFromClasspathEntry(Path templatePath, String entry) { Collection<File> jars = new ArrayList<>(); entry = entry.replace("/", File.separator); String path = new File(entry).isAbsolute() ? entry : templatePath.toString() + File.separator + entry; int slashIndex = path.lastIndexOf(File.separator); if (slashIndex == -1) { return Collections.emptyList(); } String dirName = path.substring(0, slashIndex); path = path.replaceAll("\\\\", "\\\\\\\\"); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + path); File parentDir = new File(dirName); File[] realMatchingFiles = parentDir.listFiles(f -> matcher.matches(f.toPath()) && f.toPath().startsWith(configurationGenerator.getNuxeoHome().toPath())); if (realMatchingFiles != null) { for (File file : realMatchingFiles) { if (file.isDirectory()) { jars.addAll(Arrays.asList(file.listFiles(f -> f.getName().endsWith(JAR_EXTENSION)))); } else { if (file.getName().endsWith(JAR_EXTENSION)) { jars.add(file); } } } } return jars; }
BackingServiceConfigurator { Collection<File> getJarsFromClasspathEntry(Path templatePath, String entry) { Collection<File> jars = new ArrayList<>(); entry = entry.replace("/", File.separator); String path = new File(entry).isAbsolute() ? entry : templatePath.toString() + File.separator + entry; int slashIndex = path.lastIndexOf(File.separator); if (slashIndex == -1) { return Collections.emptyList(); } String dirName = path.substring(0, slashIndex); path = path.replaceAll("\\\\", "\\\\\\\\"); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + path); File parentDir = new File(dirName); File[] realMatchingFiles = parentDir.listFiles(f -> matcher.matches(f.toPath()) && f.toPath().startsWith(configurationGenerator.getNuxeoHome().toPath())); if (realMatchingFiles != null) { for (File file : realMatchingFiles) { if (file.isDirectory()) { jars.addAll(Arrays.asList(file.listFiles(f -> f.getName().endsWith(JAR_EXTENSION)))); } else { if (file.getName().endsWith(JAR_EXTENSION)) { jars.add(file); } } } } return jars; } }
BackingServiceConfigurator { Collection<File> getJarsFromClasspathEntry(Path templatePath, String entry) { Collection<File> jars = new ArrayList<>(); entry = entry.replace("/", File.separator); String path = new File(entry).isAbsolute() ? entry : templatePath.toString() + File.separator + entry; int slashIndex = path.lastIndexOf(File.separator); if (slashIndex == -1) { return Collections.emptyList(); } String dirName = path.substring(0, slashIndex); path = path.replaceAll("\\\\", "\\\\\\\\"); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + path); File parentDir = new File(dirName); File[] realMatchingFiles = parentDir.listFiles(f -> matcher.matches(f.toPath()) && f.toPath().startsWith(configurationGenerator.getNuxeoHome().toPath())); if (realMatchingFiles != null) { for (File file : realMatchingFiles) { if (file.isDirectory()) { jars.addAll(Arrays.asList(file.listFiles(f -> f.getName().endsWith(JAR_EXTENSION)))); } else { if (file.getName().endsWith(JAR_EXTENSION)) { jars.add(file); } } } } return jars; } BackingServiceConfigurator(ConfigurationGenerator configurationGenerator); }
BackingServiceConfigurator { Collection<File> getJarsFromClasspathEntry(Path templatePath, String entry) { Collection<File> jars = new ArrayList<>(); entry = entry.replace("/", File.separator); String path = new File(entry).isAbsolute() ? entry : templatePath.toString() + File.separator + entry; int slashIndex = path.lastIndexOf(File.separator); if (slashIndex == -1) { return Collections.emptyList(); } String dirName = path.substring(0, slashIndex); path = path.replaceAll("\\\\", "\\\\\\\\"); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + path); File parentDir = new File(dirName); File[] realMatchingFiles = parentDir.listFiles(f -> matcher.matches(f.toPath()) && f.toPath().startsWith(configurationGenerator.getNuxeoHome().toPath())); if (realMatchingFiles != null) { for (File file : realMatchingFiles) { if (file.isDirectory()) { jars.addAll(Arrays.asList(file.listFiles(f -> f.getName().endsWith(JAR_EXTENSION)))); } else { if (file.getName().endsWith(JAR_EXTENSION)) { jars.add(file); } } } } return jars; } BackingServiceConfigurator(ConfigurationGenerator configurationGenerator); void verifyInstallation(); }
BackingServiceConfigurator { Collection<File> getJarsFromClasspathEntry(Path templatePath, String entry) { Collection<File> jars = new ArrayList<>(); entry = entry.replace("/", File.separator); String path = new File(entry).isAbsolute() ? entry : templatePath.toString() + File.separator + entry; int slashIndex = path.lastIndexOf(File.separator); if (slashIndex == -1) { return Collections.emptyList(); } String dirName = path.substring(0, slashIndex); path = path.replaceAll("\\\\", "\\\\\\\\"); PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + path); File parentDir = new File(dirName); File[] realMatchingFiles = parentDir.listFiles(f -> matcher.matches(f.toPath()) && f.toPath().startsWith(configurationGenerator.getNuxeoHome().toPath())); if (realMatchingFiles != null) { for (File file : realMatchingFiles) { if (file.isDirectory()) { jars.addAll(Arrays.asList(file.listFiles(f -> f.getName().endsWith(JAR_EXTENSION)))); } else { if (file.getName().endsWith(JAR_EXTENSION)) { jars.add(file); } } } } return jars; } BackingServiceConfigurator(ConfigurationGenerator configurationGenerator); void verifyInstallation(); static final String PARAM_RETRY_POLICY_ENABLED; static final String PARAM_RETRY_POLICY_MAX_RETRIES; static final String PARAM_RETRY_POLICY_DELAY_IN_MS; static final String PARAM_POLICY_DEFAULT_DELAY_IN_MS; static final String PARAM_RETRY_POLICY_DEFAULT_RETRIES; static final String PARAM_CHECK_CLASSPATH_SUFFIX; static final String PARAM_CHECK_SUFFIX; }