5 Replies Latest reply on Sep 29, 2010 3:06 PM by menegazzo

    How to programmatically list deploy folders

    menegazzo

      I want to create a new xml (or properties) file with some values needed by one module.

       

      My question is:

      How can i programmatically list the deploy folders under a given configuration? (default or standard, for example)

      The idea is to check these folders when the module is loaded, trying to find the xml file.

       

      //example (class names are fictitious)
      
      ...
      
      List<DeploymentFolder> = SomeJBossService.getDeploymentFolders("default");
      
      ...
      
      

       

      I tried to lookup DeploymentManager, with success, but seems it does not have the services i need, only things like redeploy(), start(), stop().

       

      Any help will be very appreciated

        • 1. Re: How to programmatically list deploy folders
          peterj

          You can use the jboss.server.home.dir system property, which yields jboss_home/server/xxx, where xxx is the cofiguration such as 'default'. Then tack 'deploy' on to that and use File.listFiles to get the contents of the deploy directory.

          • 2. Re: How to programmatically list deploy folders
            menegazzo

            Simple and fast, but rely on fact that deploy folder is always named "deploy", wich is not the case.

            • 3. Re: How to programmatically list deploy folders
              peterj

              That's true, but I always prefer a simple solution, especially if it fits 99.99% of the cases (with the hundreds of the people I've helped with JBoss AS, I can count on one hand the number who has used a deploiy directory other than 'deploy', and still have fingers left over). Though I am willing to admit that your situation might be one of the excpetions (is it?).

               

              I did consider how to ask for the deploy directory, but that gets a little tricky. In 4.2.3 and earlier, you could ask the URLDeploymentScanner MBean. In 5.0.0 and later you have to ask a microcontainer bean. I guess you could declare a bean in you own *-jboss-beans.xml file and have that bean reference the BootstrapProfileFactory bean, which you could then query to determine the list of deployment directories.

              • 4. Re: How to programmatically list deploy folders
                peterj

                And I should mention that the fun part in 5.x is to figure out where the deploy directory declaration is hiding - it changes in every release. The BootstrapProfileFactory bean location is for 5.1.0 only, for 5.0.1 it is VFSDeploymentScanner.

                • 5. Re: How to programmatically list deploy folders
                  menegazzo

                  Yes, we are part of 0.01%. I must admit, after all these args, is better to adopt your solution. I will create a simple service/interface to do this, to not generate coupling. Its hard, but i agree thanks for helping