2 Replies Latest reply on Sep 15, 2012 4:02 PM by Guillaume Grossetie

    [Proposal] Resolve expression values on system properties

    Guillaume Grossetie Newbie

      Hi,

       

      The StringPropertyReplacer class already provides a method #replaceProperties that replaces ${expression} value with system properties. I think that it can be useful to resolve expression on system properties with system properties.

       

      Example :

          <system-properties>
              <property name="my.image.dir" value="${jboss.server.data.dir}/image"/>
          </system-properties>
      

       

      Sure I can do the work on my code but I don't want to reference jboss system property :

          <system-properties>
              <property name="my.image.dir" value="image"/>
          </system-properties>
      
      System.getProperty("jboss.server.data.dir") + "/" + System.getProperty("my.image.dir");
      

       

      If we use StringPropertyReplacer we can also do sometthing like :

          <system-properties>
              <property name="my.dir" value="/my/dir"/>
              <property name="my.image.dir" value="${my.dir:/home}/image"/>
          </system-properties>
      

       

      The basic idea is to check if the added/removed/changed system property resolve expression :

      setSystemProperty("my.image.dir", "${jboss.server.data.dir}/image");
      # my.image.dir = "${jboss.server.data.dir}/image"
      
      setSystemProperty("jboss.server.data.dir", "/opt/jboss");
      # retrieve my.image.dir property, resolve expression and setSystemProperty("my.image.dir", "/opt/jboss/image");
      # my.image.dir = /opt/jboss/image
      

       

      The resolved expression will not be stored on the standalone.xml/domain.xml file.

       

      What do you think ?

       

      Guillaume.