JBoss Community

[Proposal] Resolve expression values on system properties

created by Guillaume Grossetie in JBoss AS 7 Development - View the full discussion

Hi,

 

The StringPropertyReplacer class already provide a method #replaceProperties that replace ${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.

Reply to this message by going to Community

Start a new discussion in JBoss AS 7 Development at Community