2 Replies Latest reply on Oct 7, 2016 3:07 AM by davidbenninger

    Additional war file in wildfly-swarm

    davidbenninger

      I have an existing Wildfly application I would like to migrate to wildfly-swarm. With our application war file we are also deploying the solr.war file for our indexes.

       

      Is it possible to add the solr.war as an additional deployment to the wildfly-swarm? Is there an example?

       

      (I don't wanna use solr embedded because it is less tested and does not provide a UI...)

       

      Thanks

      David

        • 1. Re: Additional war file in wildfly-swarm
          tremes

          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

            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);

              }

              }

              }

            }