5 Replies Latest reply on Sep 19, 2016 8:59 AM by roadsurfer

    Retrieving Path Information

    jfisherdev

      I have a directory under my WildFly home directory that I would like to define a path for and to be able to retrieve at runtime. I am running a WildFly 9.0.2 server in standalone mode.

       

      The directory structure looks like this:

       

      WILDFLY_HOME [jboss.home.dir]

      |

      | - custom

              | - extras

      | - standalone

      ...

       

      I want the path to the "custom/extras" directory to be defined as a relative path to the jboss.home.dir path.

       

      In the standalone.xml, I define a path to the "custom/extras" directory as a path that is relative to the jboss.home.dir path like this:

       

      <paths>
           <path name="custom.extras.dir" relative-to="jboss.home.dir" path="/custom/extras"/>
      </paths>
      

       

      What I want to know is how would I obtain this path information from an application at runtime?

       

      As far as I know, named paths are not inherently registered as system properties, although jboss.home.dir and the other standard named are set as system properties. Ideally the path information would be accessible as a system property so one could do something like this to access path information:

       

      void someMethod(){
           ...
           final Path extrasPath = Paths.get(System.getProperty("custom.extras.dir"));
           ...
      }
      

       

      I would appreciate any information regarding whether or not it is possible to do this or if there is a better method to obtain this information.

        • 1. Re: Retrieving Path Information
          mayerw01

          What you can do is register your directory as a System property like

          /system-property=custDirectory:add(value=${jboss.home.dir}/custom/extras)

           

          and then retrieve the path via System.getProperty("custDirectory");

          • 2. Re: Retrieving Path Information
            jfisherdev

            I think the suggested solution will work.

             

            Thank you.

            • 3. Re: Retrieving Path Information
              roadsurfer

              I too have been trying to figure this out, am I to conclude from this that the "Paths" feature of WildFly is broken? i.e. you can only add paths OK, but there is no way to retrieve them at runtime.

              • 4. Re: Retrieving Path Information
                ctomc

                J I wrote:

                 

                I too have been trying to figure this out, am I to conclude from this that the "Paths" feature of WildFly is broken? i.e. you can only add paths OK, but there is no way to retrieve them at runtime.

                You can conclude whatever you want. But fact is that path manager and its "paths" configuration in standalone.xml have noting to do with java.nio.Path and are for internal resolution of paths which is only useful with subsystems and not user code.

                • 5. Re: Retrieving Path Information
                  roadsurfer

                  OK, thanks. I had hope to be able to use that feature to make some configuration easier, wasn't clea rot me from the documentation that it was more for subsystem-only use.

                   

                  I guess I will simply find another way to do it.