Get the Instance Id

Version 1.6 by Vincent Massol on 2026/06/18 10:29

Content

Steps

To get the Instance Id, follow these steps:

  • From Java:
    1. 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.

    2. Get the id:

      The API is:

      public interface InstanceIdManager
      {
          /**
           * @return the Instance id or null if it isn't set
           */
          InstanceId getInstanceId();
      }
  • From a script in a wiki page:
    1. Get the id:
      {{velocity}}
        $services.instance.getInstanceId()
      {{/velocity}}

Get Connected