Get configuration properties

Last modified by Vincent Massol on 2019/10/08 18:20

cogGets config properties from xwiki.properties or xwiki.cfg from a wiki page
Developed by

Vincent Massol

Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Example to get the value of a configuration property from xwiki.properties:

{{groovy}}
import org.xwiki.configuration.*
println services.component.getInstance(ConfigurationSource.class, 'xwikiproperties').getProperty('core.defaultDocumentSyntax')
{{/groovy}}

To get a value from xwiki.cfg:

{{groovy}}
import org.xwiki.configuration.*
println services.component.getInstance(ConfigurationSource.class, 'xwikicfg').getProperty('xwiki.encoding')
{{/groovy}}

To get a value from the Space preferences page (XWiki.XWikiPreferences page in the current space), then the Wiki preferences page (XWiki.XWikiPreferences page in the current wiki) and then from xwiki.properties:

{{groovy}}
import org.xwiki.configuration.*
println services.component.getInstance(ConfigurationSource.class).getProperty('core.defaultDocumentSyntax')
{{/groovy}}

Prerequisites & Installation Instructions

Copy the code snippet to a page and save it.

Tags:
Created by Vincent Massol on 2019/10/08 18:20
     

Get Connected