docs: public ComponentNameSpaceConfiguration finishBMDInitForReferenceContext(BeanMetaData bmd,
                                                                              String defaultCnrJndiName,
                                                                              WSEJBHandlerResolver wsHandlerResolver) // F743-17630CodRv
                      throws ContainerException, EJBConfigurationException {
          final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
          if (isTraceOn && tc.isEntryEnabled())
              Tr.entry(tc, "finishBMDInitForReferenceContext: " + bmd.j2eeName); // d640935.1
  
          // -----------------------------------------------------------------------
          // Load Customer provided classes (i.e. bean interface(s),
          // home interface(s), and bean implementation.
          // ----------------------------------------------------------------------
          loadCustomerProvidedClasses(bmd);
  
          // -----------------------------------------------------------------------
          // Perform validation of meta data on customer provided classes.
          // -----------------------------------------------------------------------
          boolean checkAppConfigCustom = bmd.isCheckConfig(); // F743-33178
          if (isValidationLoggable(checkAppConfigCustom)) {
              //Validate that business interfaces do not contain the @Asynchronous annotation
              AppConfigChecker.validateAsyncOnInterfaces(bmd.ivBusinessLocalInterfaceClasses, tc);
              AppConfigChecker.validateAsyncOnInterfaces(bmd.ivBusinessRemoteInterfaceClasses, tc);
              AppConfigChecker.validateStatefulTimeoutOnInterfaces(bmd.ivBusinessLocalInterfaceClasses, tc); // F743-6605
              AppConfigChecker.validateStatefulTimeoutOnInterfaces(bmd.ivBusinessRemoteInterfaceClasses, tc); // F743-6605
              AppConfigChecker.validateStatefulTimeoutOnSFSB(bmd, tc); // F743-6605
          }
  
          // ----------------------------------------------------------------------
          // Process automatic timers
          //
          // F743-506 - Process automatic timers.  Since automatic timers
          // processing is always needed at application startup regardless of
          // deferred EJB initialize, processBean might have already done this
          // processing.
          // ----------------------------------------------------------------------
          if (bmd.ivInitData.ivTimerMethods == null) {
              processAutomaticTimerMetaData(bmd);
  
              // Automatic timer metadata depends on timeout metadata, so we only need
              // to process timeout metadata if automatic timer processing hasn't
              // already done so.
              if (bmd.ivInitData.ivTimerMethods == null) {
                  // ----------------------------------------------------------------
                  // Determine if this EJB implements TimedObject or contains a 'timeout'
                  // method and initialize the BMD fields for runtime processing. This
                  // must be done after loading the customer provided classes, but before
                  // processing the method metadata.                               d438133.2
                  // ----------------------------------------------------------------
                  processTimeoutMetaData(bmd);
              }
          }
  
          // -----------------------------------------------------------------------
          bmd.accessIntentList = null;
          bmd.isoLevelList = null;
          List<ContainerTransaction> transactionList = null;
          List<MethodPermission> securityList = null; //366845.11.1
          ExcludeList excludeList = null; //366845.11.1
          Method[] localBeanMethods = null;
          Method[] remoteBeanMethods = null;
  
          // ----------------------------------------------------------------------
          // Compress the specific bean types down to three basic types to simplify the code
          // which follows (e.g. BMP Entity -> Entity,  StatefulSession -> Session)
          // ----------------------------------------------------------------------
          int beanType = compressBeanTypeMap[bmd.type];
  
          // -----------------------------------------------------------------------
          // Calculate bean metadata specific to each of the three basic bean types
          // -----------------------------------------------------------------------
          processMetadataByBeanType(bmd, beanType);
  
          // ----------------------------------------------------------------------
          // Create info object to store fully fluffed up resource-reference data.
          // ----------------------------------------------------------------------
          bmd._resourceRefList = bmd.wccm.createResRefList(); // F743-18775 F743-14912
  
          // ----------------------------------------------------------------------
          // Create transaction configuration objects
          // ----------------------------------------------------------------------
          bmd._localTran = bmd.wccm.createLocalTransactionSettings(); // F743-18775 F743-14912
          bmd._globalTran = bmd.wccm.createGlobalTransactionSettings(); // F743-18775 F743-14912
          setCommitDanglingWork(bmd);
  
          // -----------------------------------------------------------------------
          // A persister is only needed for EJB 1.x CMP, create the persister
          // only if needed.                                               f110762.2
          //
          // Moved CMP 1.1 pesister creation to this point in the initialization
          // because the connection manager factory uses ComponentMetaData (ie. bmd). d114138.3
          // Also, it depends on bmd._resourceRefList set above.
          // -----------------------------------------------------------------------
          if (bmd.cmpVersion == InternalConstants.CMP_VERSION_1_X) {
              bmd.persister = createCMP11Persister(bmd, defaultCnrJndiName);
  
              //F001925 start: now that we have a persister, we need to use reflections to determine
              // if 'supportsFluffOnFind' is supported.  For more details, see bmd.supportsFluffOnFind.
              try {
                  Method method = bmd.persister.getClass().getDeclaredMethod("supportsFluffOnFind");
                  bmd.supportsFluffOnFind = ((Boolean) method.invoke(bmd.persister)).booleanValue();
                  if (isTraceOn && tc.isDebugEnabled())
                      Tr.debug(tc, "Using 'supportsFluffOnFind' for bean with J2EEName = " + bmd.j2eeName);
              } catch (Throwable t) {
                  //intentionally left blank since most CMP 1.x persisters will not be using 'supportsFluffOnFind'.
              }
              //F001925 end
          }
  
          // ----------------------------------------------------------------------
          // Intialize Concurrency Control policies for the bean
          //-----------------------------------------------------------------------
          setConcurrencyControl(bmd); //116394.3
  
          // ----------------------------------------------------------------------
          // Calculate Bean Pool Limits (ie. may be values from a system
          // property or default values), including min, max, and initial
          // pool size
          // ----------------------------------------------------------------------
          processBeanPoolLimits(bmd);
  
          // ----------------------------------------------------------------------
          // Handle cached timer data settings
          // ----------------------------------------------------------------------
          processCachedTimerDataSettings(bmd); // F001419
  
          // ----------------------------------------------------------------------
          // Intialize activation and load policies for the bean.  This
          // must be done before the lines below that depend on optionA setting.
          // ----------------------------------------------------------------------
          setActivationLoadPolicy(bmd);
  
          // ----------------------------------------------------------------------
          // A LockManager is only needed for Option A Entity beans
          // (or) for Statless beans with a MaxCreation limit.                PK20648
          // Depends on pool limits and activation policies being set
          // above.
          // ----------------------------------------------------------------------
          if (bmd.optionACommitOption || // d173022.11
              bmd.ivMaxCreation > 0) {
              bmd.container.initOptACleanUpLockManager();
          }
  
          // ----------------------------------------------------------------------
          // Check if any pin policy other than TRANSACTION has been
          // specified,  if specified print a warning
          // ----------------------------------------------------------------------
          checkPinPolicy(bmd);
  
          //------------------------------------------------------------------------
          // Process metadata for IBM Extensions to EJB spec:
          //
          // 1) DisableFlushBeforeFind
          // 2) DisableEJBStoreForNonDirtyBeans
          // 3) LightWeightLocal
          //------------------------------------------------------------------------
          processEJBExtensionsMetadata(bmd);
  
          //------------------------------------------------------------------------
          // Process the XML and annotations that specify whether the
          // caller's security identity or a run-as security identity
          // should be used for the execution of the bean's methods.    d366845.11.1
          //------------------------------------------------------------------------
          processSecurityIdentity(bmd);
  
          //------------------------------------------------------------------------
          // Process the XML that specify the relationship between a
          // security role-link and it's corresponding role.              d366845.11
          //------------------------------------------------------------------------
          processSecurityRoleLink(bmd);
  
          //-----------------------------------------------------------------------
          // Build up all the method level metadata objects.  This
          // code must come after we have finished the specific processing
          // for each bean type and retrieved the vairous method attribute
          // lists above.  This processing on this call handles Bean
          // methods, Home methods, and CMR methods.
          // ----------------------------------------------------------------------
  
          // ----------------------------------------------------------------------
          // Get list of all methods that have TX or Security attributes from WCCM
          // ----------------------------------------------------------------------
          EJBJar ejbjar = bmd.wccm.ejbjar; //89981
          if (ejbjar != null) {
              AssemblyDescriptor assemblyDescriptor = ejbjar.getAssemblyDescriptor();
              if (assemblyDescriptor != null) {
                  transactionList = assemblyDescriptor.getContainerTransactions();
                  securityList = assemblyDescriptor.getMethodPermissions(); //d366845.11.1
                  excludeList = assemblyDescriptor.getExcludeList(); //d366845.11.1
              }
          }
  
          // ----------------------------------------------------------------------
          // ActivitySessionAttributes
          //
          // LIDB441.5 - Get the list of all methods that have AttivitySessionAttributes
          // from the ContainerExtensionFactory.  The base implementation should return
          // a list with AS_UNKNOWN, while the PME implementation should parse the real
          // values from the pme extensions xmi.
          //
          // Only container mangaged activity sessions use the AS attributes
          // Also, it is very possible that there are no activity session attributes
          // because they are an optional PME extension.
          // ----------------------------------------------------------------------
          List<ActivitySessionMethod> activitySessionList = null;
          if (!bmd.usesBeanManagedAS) {
              if (isTraceOn && tc.isDebugEnabled()) {
                  Tr.debug(tc, "Attempting to do any needed activitySession work for bean " + bmd.j2eeName.getComponent());
              }
  
              try {
                  activitySessionList = bmd.container.getContainerExtensionFactory().getActivitySessionAttributes(bmd);//d143954 F743-24095
              } catch (Exception ex) {
                  FFDCFilter.processException(ex, CLASS_NAME + ".finishBMDInit", "913", this);
                  ContainerException cex = new ContainerException("Failed to initialize BeanMetaData instance", ex);
                  Tr.error(tc, "CAUGHT_EXCEPTION_THROWING_NEW_EXCEPTION_CNTR0035E",
                           new Object[] { ex, cex.toString() }); // d194031
                  throw cex;
              }
          } // if ! bean managed AS
  
          // ----------------------------------------------------------------------
          // Build complete method lists based on the various customer provided interface(s). d369262.3
          // ----------------------------------------------------------------------
          localBeanMethods = DeploymentUtil.getMethods(bmd.localInterfaceClass,
                                                       bmd.ivBusinessLocalInterfaceClasses);
  
          if (bmd.type == InternalConstants.TYPE_MESSAGE_DRIVEN) {
              // If this is a no-method interface MDB, we need to collect the methods off the bean class instead of the interface.
              if (bmd.container.isNoMethodInterfaceMDBEnabled() && localBeanMethods.length == 0) {
                  localBeanMethods = DeploymentUtil.getMethods(null, new Class[] { bmd.enterpriseBeanClass });
                  bmd.ivIsNoMethodInterfaceMDB = true;
              }
  
              // For MDBs using an ActivationSpec, remove any message listener interface methods that
              // conflict with the MessageEndpoint interface methods; they cannot be overridden.
              if (bmd.ivActivationSpecJndiName != null) {
                  localBeanMethods = removeMessageEndpointMethods(localBeanMethods);
              }
          }
  
          remoteBeanMethods = DeploymentUtil.getMethods(bmd.remoteInterfaceClass,
                                                        bmd.ivBusinessRemoteInterfaceClasses);
          Method[] webserviceMethods = DeploymentUtil.getMethods(bmd.webserviceEndpointInterfaceClass,
                                                                 null);
          Method[] localHomeMethods = DeploymentUtil.getMethods(bmd.localHomeInterfaceClass,
                                                                null);
          Method[] remoteHomeMethods = DeploymentUtil.getMethods(bmd.homeInterfaceClass,
                                                                 null);
          Method[] timerMethods = getTimerMethods(bmd); // F743-506
  
          // d630468 - If the only webservice endpoint for the bean is the JAX-RPC
          // service-endpoint declared in XML, then webserviceMethods only contains
          // the methods from that interface.  If the bean has an undeclared
          // JAX-RPC service endpoint or is declared as a JAX-WS provider, then we
          // won't know the full list of webservice methods until they are provided
          // by the webservices engine later.  Collect all public methods on the
          // bean class now and filter out the unneeded ones then.
          if (bmd.ivHasWebServiceEndpoint &&
              (bmd.webserviceEndpointInterfaceClass == null ||
               bmd.ivInitData.ivWebServiceEndpoint)) {
              webserviceMethods = DeploymentUtil.getMethods(bmd.enterpriseBeanClass, null);
          }
  
          // Get all the public methods of the bean class including the
          // methods inherited from the super class of bean class.
          Method[] allPublicMethods = bmd.enterpriseBeanClass.getMethods(); // d430356
  
          ByteCodeMetaData byteCodeMetaData = new ByteCodeMetaData(bmd.enterpriseBeanClass, allPublicMethods); // F61004.1
  
          // ----------------------------------------------------------------------
          // Calculate all the method metadata
          // ----------------------------------------------------------------------
          processMethodMetadata(bmd,
                                byteCodeMetaData,
                                beanType,
                                transactionList,
                                securityList,
                                excludeList,
                                activitySessionList,
                                localBeanMethods,
                                remoteBeanMethods,
                                timerMethods,
                                webserviceMethods,
                                localHomeMethods,
                                remoteHomeMethods,
                                allPublicMethods); // d494984
  
          //------------------------------------------------------------------------
          // If running in a clustered (wlm) environment, and there is either
          // a remote home, remote interface, or remote business
          // interface(s), then obtain the Cluster Identity
          // (name), which will be used to register the remote wrappers
          // (registerServant).  Note that this value is constant for all Remote
          // objects associated witha a specific J2EEName, except for instances
          // of Stateful Session beans.  Stateful beans may not exist on more
          // than one process, so are not WLMable in the normal sense.
          // For Stateful failover, a Cluster Identity must be obtained for
          // eache bean instance.                                          LI2401-11, d461515
          //------------------------------------------------------------------------
          if (bmd.remoteInterfaceClass != null ||
              bmd.homeInterfaceClass != null ||
              bmd.ivBusinessRemoteInterfaceClasses != null) {
              bmd.ivCluster = bmd.container.getEJBRuntime().getClusterIdentity(bmd.j2eeName);
          }
  
          // ----------------------------------------------------------------------
          // Create method--TO--MethodInfo[] mapping
          ///
          // Build a map where the map key is the Method object of a public method of the EJB and
          // the map value is an ArrayList of EJBMethodInfoImpl objects. We have one implementation
          // of the method in the EJB class, but that method could appear in more than one
          // interface (remote or local component or business interface, thus there are
          // multiple EJBMethodInfo arrays to be processed).
          // ----------------------------------------------------------------------
          final Map<Method, ArrayList<EJBMethodInfoImpl>> methodInfoMap = createEJBMethodInfoMap(bmd, allPublicMethods); // d430356
  
          //------------------------------------------------------------------------
          // If this is a SFSB, determine if there are any @Init methods for this
          // EJB and create any metadata necessary for JITDeploy to be able to
          // generate the objects that invoke those methods.
          //------------------------------------------------------------------------
          if (bmd.type == InternalConstants.TYPE_STATEFUL_SESSION &&
              !bmd._moduleMetaData.isEJBDeployed()) {
              initializeSFSBInitMethodMap(bmd, allPublicMethods);
  
              // For EJB 3 modules, also flag the EJBMethodInfo object for each of
              // the @Remove method in SFSB.
              if (bmd.ivModuleVersion >= BeanMetaData.J2EE_EJB_VERSION_3_0) {
                  flagSFSBRemoveMethods(bmd, allPublicMethods, methodInfoMap); // d430356
              }
          }
  
          //------------------------------------------------------------------------
          // Create interceptor meta data.
          //
          // Now that we have EJBMethodInfoImpl and the rest of BeanMetaData fields
          // finished, we can do the InterceptorMetaData that may be needed for this EJB.
          // Must follow initialization of method metadata.
          //------------------------------------------------------------------------
          initializeInterceptorMD(bmd, methodInfoMap); //d367572.4 // d430356
  
          if (bmd.ivInterceptorMetaData != null && bmd.ivInterceptorMetaData.ivBeanLifecycleMethods != null) {
              initializeLifecycleInterceptorMethodMD(bmd.ivInterceptorMetaData.ivBeanLifecycleMethods,
                                                     transactionList,
                                                     activitySessionList,
                                                     bmd);
          }
  
          // -----------------------------------------------------------------------
          // Attempt to automatically enable lightweight transactions for local methods. F61004.1
          // -----------------------------------------------------------------------
          processAutomaticLightweightTransaction(bmd, byteCodeMetaData);
  
          // ----------------------------------------------------------------------
          // Add the bean class itself to the list of classes 'in play' for reference processing.
          // ----------------------------------------------------------------------
          List<Class<?>> classesInPlay = new ArrayList<Class<?>>();
          classesInPlay.add(bmd.enterpriseBeanClass);
  
          ResourceRefConfigList resRefList = bmd._resourceRefList; // F743-18775
          Map<JNDIEnvironmentRefType, Map<String, String>> allBindings = JNDIEnvironmentRefBindingHelper.createAllBindingsMap();
          Map<String, String> envEntryValues = new HashMap<String, String>();
  
          populateBindings(bmd, allBindings, envEntryValues, resRefList);
  
          InterceptorMetaData imd = bmd.ivInterceptorMetaData;
          List<Class<?>> interceptorClassList = null;
          if (imd != null) {
              // There is atleast 1 interceptor class for this EJB.  So add the classes
              // to the injectionClasses list.
              interceptorClassList = Arrays.asList(imd.ivInterceptorClasses);
              classesInPlay.addAll(interceptorClassList);
          }
  
          // JAX-WS Handlers are part of the EJB's component namespace
          // (java:comp/env), so check with WebServices if there are any
          // handler classes for this Stateless/Singleton EJB, and if so, add them
          // to the list of 'injection' classes.                          d495644
          if ((bmd.ivModuleVersion >= BeanMetaData.J2EE_EJB_VERSION_3_0) &&
              (wsHandlerResolver != null) &&
              (bmd.type == InternalConstants.TYPE_SINGLETON_SESSION || // F743-508
               bmd.type == InternalConstants.TYPE_STATELESS_SESSION)) {
              List<Class<?>> handlerClasses = wsHandlerResolver.retrieveJAXWSHandlers(bmd.j2eeName);
              if (handlerClasses != null) {
                  classesInPlay.addAll(handlerClasses);
              }
          }
  
          //---------------------------------------------------------
          // Get the WCCM artifacts relavent to refeference processing
          //----------------------------------------------------------
          String displayName = null;
          Map<JNDIEnvironmentRefType, List<? extends JNDIEnvironmentRef>> allRefs = new EnumMap<JNDIEnvironmentRefType, List<? extends JNDIEnvironmentRef>>(JNDIEnvironmentRefType.class);
  
          // get WCCM artifacts associated with bean itself
          EnterpriseBean enterpriseBean = bmd.wccm.enterpriseBean;
          if (enterpriseBean != null) {
              if (isTraceOn && tc.isDebugEnabled())
                  Tr.debug(tc, "adding references from enterprise bean: " + enterpriseBean);
  
              List<DisplayName> displayNames = enterpriseBean.getDisplayNames();
              displayName = displayNames.isEmpty() ? null : displayNames.get(0).getValue();
              JNDIEnvironmentRefType.addAllRefs(allRefs, enterpriseBean);
          }
  
          // get WCCM artifacts associated with any interceptor classes
          // If there were interceptor classes defined in ejb-jar.xml file,
          // then update the WCCM reference lists with the references from
          // each interceptor class that is bound to the enterprise bean class.
          Map<String, Interceptor> interceptorMap = bmd._moduleMetaData.ivInterceptorMap;
          if ((interceptorMap != null) &&
              (interceptorClassList != null) &&
              (interceptorClassList.size() > 0)) {
              // There is atleast one interceptor class bound to the EJB class,
              // so do for each interceptor class in list passed to this method.
              for (Class<?> interceptorClass : interceptorClassList) {
                  // Get the fully qualified interceptor class name and lookup in the
                  // map passed to this method the WCCM Interceptor object associated
                  // with the interceptor class name.
                  String name = interceptorClass.getName();
                  Interceptor interceptor = interceptorMap.get(name);
  
                  // Only process if found in the interceptor map. If will not be found
                  // if the Interceptor is reference via the @Inteceptor annotation
                  // rather than the <interceptor> element in ejb-jar.xml file for the module.
                  if (interceptor != null) {
                      if (isTraceOn && tc.isDebugEnabled())
                          Tr.debug(tc, "adding references from interceptor: " + interceptor);
  
                      // Found in the map, so it is in ejb-jar.xml which is why we
                      // have a WCCM Interceptor object to process.  So update each
                      // of the reference lists with references for this Inteceptor class.
                      JNDIEnvironmentRefType.addAllRefs(allRefs, interceptor);
                  }
              }
          }
  
          //-------------------------------------------
          //Ensure display name is set correctly
          //-------------------------------------------
          if (displayName == null || displayName.equals("")) {
              displayName = bmd.j2eeName.getComponent();
          } else if (!displayName.equals(bmd.j2eeName.getComponent())) {
              displayName = displayName + " (" + bmd.j2eeName.getComponent() + ")";
          }
  
          //-----------------------------------------------------------------------
          // Stick Method related data into BMD so we can get at during .finishBMDInit()
          // ----------------------------------------------------------------------
          bmd.methodsExposedOnLocalInterface = localBeanMethods;
          bmd.methodsExposedOnRemoteInterface = remoteBeanMethods;
          bmd.methodsExposedOnLocalHomeInterface = localHomeMethods;
          bmd.methodsExposedOnRemoteHomeInterface = remoteHomeMethods;
          bmd.allPublicMethodsOnBean = allPublicMethods;
          bmd.methodsToMethodInfos = methodInfoMap;
  
          //-----------------------------------------------------------------------
          // Create and populate ComponentNameSpaceConfiguration
          //-----------------------------------------------------------------------
          EJBModuleMetaDataImpl mmd = bmd._moduleMetaData;
          String logicalAppName = mmd.getEJBApplicationMetaData().getLogicalName(); // F743-23167
          String logicalModuleName = mmd.ivLogicalName; // F743-23167
          Object loadStrategy = bmd.wccm.getModuleLoadStrategy(); // F68113.4
          UserTransaction ejbUserTransaction = bmd.usesBeanManagedTx ? UserTransactionWrapper.INSTANCE : null; // F743-17630.1, d631349
          ComponentNameSpaceConfiguration.ReferenceFlowKind owningFlow = bmd.type == InternalConstants.TYPE_MANAGED_BEAN ? ComponentNameSpaceConfiguration.ReferenceFlowKind.MANAGED_BEAN // d705480
                          : ComponentNameSpaceConfiguration.ReferenceFlowKind.EJB;
  
          ComponentNameSpaceConfiguration compNSConfig = new ComponentNameSpaceConfiguration(displayName, bmd.getJ2EEName()); // F48603.7
          compNSConfig.setLogicalModuleName(logicalAppName, logicalModuleName); // F743-23167
          compNSConfig.setOwningFlow(owningFlow);
          compNSConfig.setCheckApplicationConfiguration(checkAppConfigCustom); // F743-33178
  
          compNSConfig.setClassLoader(bmd.classLoader);
          compNSConfig.setModuleMetaData(bmd.getModuleMetaData());
          compNSConfig.setModuleLoadStrategy(loadStrategy);
          compNSConfig.setComponentMetaData(bmd); // F743-31658
          compNSConfig.setMetaDataComplete(bmd.metadataComplete);
          compNSConfig.setInjectionClasses(classesInPlay);
          compNSConfig.setEJBTransaction(ejbUserTransaction);
          compNSConfig.setUsesActivitySessions(bmd.usesBeanManagedAS);
          compNSConfig.setSFSB(bmd.isStatefulSessionBean());
  
          JNDIEnvironmentRefType.setAllRefs(compNSConfig, allRefs);
          JNDIEnvironmentRefBindingHelper.setAllBndAndExt(compNSConfig, allBindings, envEntryValues, resRefList);
  
          if (isTraceOn && tc.isEntryEnabled())
              Tr.exit(tc, "finishBMDInitForReferenceContext: " + compNSConfig.toDumpString());
          return compNSConfig;
      }