Extension Script Module
Last modified by Thomas Mortagne on 2026/02/26 15:39
| Provide script oriented APIs to manipulate extensions |
| Type | JAR |
| Category | API |
| Developed by | |
| Rating | |
| License | GNU Lesser General Public License 2.1 |
| Bundled With | XWiki Standard |
Table of contents
Description
The Extension module provide various script oriented APIs. It's also possible to extend it by registering a org.xwiki.script.service.ScriptService component with a hint prefixed with "extension.".
Following are the default set of extension related APIs:
- extension:
$services.extensionThe entry point of this module is the script service with the identifier extension which then provide several "sub-script services".- core:
$services.extension.coreThis script service is dedicated to code extensions. Core extension being the unmodificable extension included in the WAR or coming from the application server. - local:
$services.extension.localThis script service is dedicated to local extensions. Local extension being all the extension installed or not that have been downloaded at some point. - installed:
$services.extension.installedThis script service is dedicated to installed extensions. - rating:
$services.extension.ratingThis script service is dedicated to rating informations. - history:
$services.extension.historyProvides access to the Extension Job History and offers APIs to serialize (export), deserialize (import) and replay history records.
- core:
Examples
Non-interactive and synchronous install
Install some extension on current wiki in a non-interactive and synchronous fashion.
## Create install request for extension with id org.xwiki.contrib:extension-tweak and version 1.3 on current wiki
#set($installRequest = $services.extension.createInstallRequest('org.xwiki.contrib:extension-tweak', '1.3', "wiki:${xcontext.database}"))
## Disable interactive mode
$installRequest.setInteractive(false)
## Start install
#set($installJob = $services.extension.install($installRequest))
## Wait until install is done
$installJob.join()Search
Search remote extension
Since 7.1RC1 an advanced search API is provided with filtering, sorting, etc.
#set($query = $services.extension.newQuery('toto'))
## Sort by name
$query.addSort('name', 'DESC')
## Get only the flavors
$query.addFilter('category', 'flavor', 'EQUAL')
## Only the first 10 results
$query.setLimit(10)
## Execute search
#set($result = $services.extension.search($query))
## Display found extensions
#foreach ($extension in $result)
* $extension
#endSearch installed extension
#set($query = $services.extension.newQuery('toto'))
## Sort by name
$query.addSort('name', 'DESC')
## Get only the flavors
$query.addFilter('category', 'flavor', 'EQUAL')
## Only the first 10 results
$query.setLimit(10)
## Search in extensions installed in wiki "mywiki"
#set($result = $services.extension.installed.repository.searchInstalledExtensions('wiki:mywiki', $query))
## [since 8.1] Search in all installed extensions
#set($result = $services.extension.installed.repository.searchInstalledExtensions($query))
## Display found extensions
#foreach ($extension in $result)
* $extension
#end