code: public ExtensionContext getExtensionContext(final String moduleName, ManagementResourceRegistration rootRegistration, ExtensionRegistryType extensionRegistryType) {
          // Can't use processType.isServer() to determine where to look for profile reg because a lot of test infrastructure
          // doesn't add the profile mrr even in HC-based tests
          ManagementResourceRegistration profileRegistration = rootRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(PROFILE)));
          if (profileRegistration == null) {
              profileRegistration = rootRegistration;
          }
          ManagementResourceRegistration deploymentsRegistration = processType.isServer() ? rootRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(DEPLOYMENT))) : null;
  
          // Hack to restrict extra data to specified extension(s)
          boolean allowSupplement = legallySupplemented.contains(moduleName);
          ManagedAuditLogger al = allowSupplement ? auditLogger : null;
          return new ExtensionContextImpl(moduleName, profileRegistration, deploymentsRegistration, pathManager, extensionRegistryType, al);
      }
docs: Gets an {@link ExtensionContext} for use when handling an {@code add} operation for
  a resource representing an {@link org.jboss.as.controller.Extension}.
  
  @param moduleName the name of the extension's module. Cannot be {@code null}
  @param rootRegistration the root management resource registration
  @param extensionRegistryType the type of registry we are working on, which has an effect on things like whether extensions get registered etc.
  
  @return  the {@link ExtensionContext}.  Will not return {@code null}