Get configuration properties

Last modified by Vincent Massol on 2021/03/18 11:28

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

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

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}}
Tags:
     

Get Connected