1.3.5. System properties

Since Kernel 2.0.7 and 2.1, it is possible to use system properties in literal values of component configuration metadata. This makes it possible to resolve properties at runtime instead of providing a value at packaging time.

Example: Configuration file based on system properties


<component>
    <key>org.exoplatform.services.database.HibernateService</key>
    <jmx-name>database:type=HibernateService</jmx-name>
    <type>org.exoplatform.services.database.impl.HibernateServiceImpl</type>
    <init-params>
        <properties-param>
            <name>hibernate.properties</name>
            <description>Default Hibernate Service</description>
            ...
            <property name="hibernate.connection.url" value="${connectionUrl}"/>
            <property name="hibernate.connection.driver_class" value="${driverClass}"/>
            <property name="hibernate.connection.username" value="${username}"/>
            <property name="hibernate.connection.password" value="${password}"/>
            <property name="hibernate.dialect" value="${dialect}"/>
            ...
        </properties-param>
    </init-params>
</component>

System properties can be set by using the -D option: java -DconnectionUrl=jdbc:hsqldb:file:../temp/data/exodb -DdriverClass=org.hsqldb.jdbcDriver in the startup commands/scripts.

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus