docs: private Reference createDefinitionResourceFactoryReference(ComponentNameSpaceConfiguration compNSConfig,
                                                                 InjectionScope scope,
                                                                 String refName,
                                                                 String type,
                                                                 @Sensitive Map<String, Object> properties) throws Exception {
  
          ResourceFactoryBuilder builder = getResourceFactoryBuilder(type);
  
          J2EEName j2eeName = compNSConfig.getJ2EEName();
  
          // d660700 - Based on the scope, determine the metadata for recording the
          // resulting reference, and add additional keys to the properties list.
          String appName, moduleName, compName;
          MetaData metaData;
          if (scope == InjectionScope.GLOBAL) {
              metaData = null;
              appName = moduleName = compName = null;
          } else {
              appName = j2eeName.getApplication();
  
              if (scope == InjectionScope.APP) {
                  metaData = compNSConfig.getApplicationMetaData(); // F743-31682
                  moduleName = compName = null;
              } else {
                  moduleName = j2eeName.getModule();
  
                  if (scope == InjectionScope.MODULE) {
                      metaData = compNSConfig.getModuleMetaData();
                      compName = null;
                  } else {
                      compName = j2eeName.getComponent();
  
                      metaData = compNSConfig.getComponentMetaData();
                      if (metaData == null) {
                          // All components in a web module share the same namespace.
                          metaData = compNSConfig.getModuleMetaData();
                      }
                  }
              }
          }
  
          if (appName == null) {
              properties.remove("application");
          } else {
              properties.put("application", appName);
          }
  
          if (moduleName == null) {
              properties.remove("module");
          } else {
              properties.put("module", moduleName);
          }
  
          if (compName == null) {
              properties.remove("component");
          } else {
              properties.put("component", compName);
          }
  
          properties.put("declaringApplication", j2eeName.getApplication());
          properties.put("jndiName", InjectionScope.denormalize(refName));
  
          ResourceFactory resourceFactory = builder.createResourceFactory(properties);
          Reference ref = new ResourceFactoryReference(type, resourceFactory, properties);
  
          // Save the reference in the relevant scope data so that it can be
          // destroyed when the scope is destroyed.
          getInjectionScopeData(metaData).addDefinitionReference(refName, ref);
  
          return ref;
      }