Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-11905

Sort MandatoryDocumentInitializer by priority when executing them

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.0-milestone-2
    • Fix Version/s: 7.0-rc-1
    • Component/s: Old Core
    • Labels:
      None
    • Difficulty:
      Unknown
    • Documentation:
      N/A
    • Similar issues:

      Description

      Right now, all MandatoryDocumentInitializers are executed at the same level, in a random order. However, it may be the case when one document initializer needs to be execute before or after another.
      Examples:

      1. Both the Class document and a couple of instances are mandatory documents, but the instances need to be initialized after the class and not before.
      2. Mandatory class document defines a StrigList property for which possible values need to be determined to a list of document, but those documents are themselves mandatory documents as well. This class can not be initialized before the mandatory document "dependencies" are initialized.
      3. etc.

      The simplest way would be to use a @Priority annotation on the components and then sorting the initializes based on this priority.
      For the @Priority annotation, javax.annotation could be used which contains some general purpose annotations such as this one.
      This also has the benefit that it does not influence in any way existing implementations, as thy can be considered as having all the same default priority of, say, 1000.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                enygma Eduard Moraru
                Reporter:
                enygma Eduard Moraru
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Date of First Response: