If an installation has multiple deployments and more than one of those deployments declares a dependency on a particular static module with 'annotations="true"', the Jandex indices for resources in such modules are computed multiple times, once per dependent deployment, increasing deployment time and the peak amount of memory needed to process the deployments. We should cache any such indices so they only need to be created once per top-level management operation.
We should create a Map<String, Set<Index>> and attach it to the executing management OperationContext. The map key is the module identifier. Any OSH that creates a DeploymentUnitService should pass that map to the DUS, which will make it available to DUPs via a deployment unit attachment. The attachment would be a utility object that holds the map and coordinates creation of indices for static modules. CompositeIndexProcessor would use the attachment.
The utility object should hold a WeakReference to the map, so when the OperationContext's strong ref to the map gets gc'd, the utility object ref can be gc'd as well, avoiding long term retention of potentially large Index objects. The weak ref approach avoids DUPs concurrently handling different deployments needing to coordinate when they are all done with the utility object.