-
1. Re: Additional war file in wildfly-swarm
tremes Oct 7, 2016 1:32 AM (in response to davidbenninger)Hi David,
I am not sure what do you mean by "additional deployment". I think you will need to merge these applicaitons into the single one then or start secondary service and establish some kind of communication. Anyway it's better to ask at WildFly Swarm google group which is more active. wildfly-swarm (at) googlegroups.com;
-
2. Re: Additional war file in wildfly-swarm
davidbenninger Oct 7, 2016 3:07 AM (in response to tremes)Yes, I think the google group would have been better.... thanks thomas.
I have found a solution that seems to work fine:
List<File> list = findFilesOnClasspath("solr-\\d+\\.\\d+\\.\\d+\\.war$");
WebArchive solr = ShrinkWrap.create(ZipImporter.class, "solr.war").importFrom(list.get(0)).as(WebArchive.class);
// ...
swarm.deploy(solr);
// ...
private static List<File> findFilesOnClasspath(String regex) {
Pattern pattern = Pattern.compile(regex);
return getFiles(System.getProperty("java.class.path")).stream().filter(file -> pattern.matcher(file.getName()).matches()).collect(Collectors.toList());
}
private static List<File> getFiles(String paths) {
List<File> filesList = new ArrayList<>();
for (String path : paths.split(File.pathSeparator)) {
File file = new File(path);
if( file.isDirectory()) {
recurse(filesList, file);
}
else {
filesList.add(file);
}
}
return filesList;
}
private static void recurse(List<File> filesList, File f) {
File list[] = f.listFiles();
if (list != null) {
for (File file : list) {
if (file.isDirectory()) {
recurse(filesList, file);
}
else {
filesList.add(file);
}
}
}
}