Instance API

Last modified by Admin on 2024/10/10 01:19

cogAPI related to the XWiki instance (e.g. compute a unique id for the instance)
TypeJAR
Category
Developed by

XWiki Development Team

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Compatibility

Feature added in XWiki 5.2M2

Installable with the Extension Manager

Description

At the moment the only API provided is one to generate and retrieve an id unique per XWiki instance. This can be used to identify uniquely a XWiki instance, even across restarts and across upgrades since the unique id is stored in XWiki's database.

To get the InstanceIdManager:

@Inject
private Provider<InstanceIdManager> idManagerProvider;

Note the usage of a Provider. This is required only when the component in which you're injecting the Instance Id Manager is loaded before the XWiki Store has been initialized.

The API is:

public interface InstanceIdManager
{
   /**
     * @return the Instance id or null if it isn't set
     */

    InstanceId getInstanceId();
}

Script service

Since 8.3RC1 Getting the XWiki instance id:

{{velocity}}
  $services.instance.getInstanceId()
{{/velocity}}

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager).

You can also use the manual method which involves dropping the JAR file and all its dependencies into the WEB-INF/lib folder and restarting XWiki.

Dependencies

Dependencies for this extension (org.xwiki.platform:xwiki-platform-instance 16.8.0):

Get Connected