Bean and observer registration is delayed until after all {@link AfterBeanDiscovery} observers are notified.
186507
private void finish() {
        try {
            GlobalEnablementBuilder globalEnablementBuilder = getBeanManager().getServices().get(GlobalEnablementBuilder.class);
            for (BeanRegistration registration : additionalBeans) {
                processBeanRegistration(registration, globalEnablementBuilder);
            }
            for (ObserverRegistration registration : additionalObservers) {
                processObserverRegistration(registration);
            }
        } catch (Exception e) {
            throw new DefinitionException(e);
        }
    }
317805
public void waitForEntityStart() {
        if (log.isDebugEnabled()) {
            log.debug("waiting to ensure {} doesn't abort prematurely", this);
        }
        Duration startTimeout = getConfig(START_TIMEOUT);
        CountdownTimer timer = startTimeout.countdownTimer();
        boolean isRunningResult = false;
        long delay = 100;
        while (!isRunningResult && !timer.isExpired()) {
            Time.sleep(delay);
            try {
                isRunningResult = driver.isRunning();
            } catch (Exception e) {
                ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
                // provide extra context info, as we're seeing this happen in strange circumstances
                if (driver == null) {
                    throw new IllegalStateException(this +
                            " concurrent start and shutdown detected");
                }
                throw new IllegalStateException("Error detecting whether " + this +
                        " is running: " + e, e);
            }
            if (log.isDebugEnabled()) {
                log.debug("checked {}, is running returned: {}", this, isRunningResult);
            }
            // slow exponential delay -- 1.1^N means after 40 tries and 50s elapsed, it reaches
            // the max of 5s intervals
            // TODO use Repeater
            delay = Math.min(delay * 11 / 10, 5000);
        }
        if (!isRunningResult) {
            String msg = "Software process entity " + this + " did not pass is-running " +
                    "check within the required " + startTimeout + " limit (" +
                    timer.getDurationElapsed().toStringRounded() + " elapsed)";
            log.warn(msg + " (throwing)");
            ServiceStateLogic.setExpectedState(this, Lifecycle.RUNNING);
            throw new IllegalStateException(msg);
        }
    }
1207434
private void registerAspect(BeanDefinitionRegistry registry) {

        GenericBeanDefinition beanDefinition = new GenericBeanDefinition();
        beanDefinition.setBeanClass(DisconfAspectJ.class);
        beanDefinition.setLazyInit(false);
        beanDefinition.setAbstract(false);
        beanDefinition.setAutowireCandidate(true);
        beanDefinition.setScope("singleton");

        registry.registerBeanDefinition("disconfAspectJ", beanDefinition);
    }
338203
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {

		for (String beanName : registry.getBeanDefinitionNames()) {
			BeanDefinition beanDefinition = registry.getBeanDefinition(beanName);
			String beanClassName = beanDefinition.getBeanClassName();
			try {
				Class beanClass = Class.forName(beanClassName);
				// large project need using Google Collection's lookup
				for (final Field field : ClassUtil.getAllDecaredFields(beanClass)) {
					if (field.isAnnotationPresent(Autowired.class)) {
						// inject jdon components into spring components with
						// AutoWire;
						Object o = findBeanClassInJdon(field.getType());
						if (o != null) {
							neededJdonComponents.put(field.getName(), o);
						}
					}
				}
			} catch (ClassNotFoundException ex) {
				ex.printStackTrace();
			}
		}
	}
433702
void waitProposedEpochFromQuorum()
      throws InterruptedException, TimeoutException, IOException {
    ClusterConfiguration currentConfig = persistence.getLastSeenConfig();
    long acknowledgedEpoch = persistence.getAckEpoch();
    // Waits PROPOED_EPOCH from a quorum of peers in current configuraion.
    while (this.quorumMap.size() < getQuorumSize() - 1) {
      MessageTuple tuple = filter.getExpectedMessage(MessageType.PROPOSED_EPOCH,
                                                     null,
                                                     config.getTimeoutMs());
      Message msg = tuple.getMessage();
      String source = tuple.getServerId();
      ZabMessage.ProposedEpoch epoch = msg.getProposedEpoch();
      ClusterConfiguration peerConfig =
        ClusterConfiguration.fromProto(epoch.getConfig(), source);
      long peerProposedEpoch = epoch.getProposedEpoch();
      long peerAckedEpoch = epoch.getCurrentEpoch();
      int syncTimeoutMs = epoch.getSyncTimeout();
      Zxid peerVersion = peerConfig.getVersion();
      Zxid selfVersion = currentConfig.getVersion();
      // If the peer's config version doesn't match leader's config version,
      // we'll check if the peer has the more likely "correct" configuration.
      if (!peerVersion.equals(selfVersion)) {
        LOG.debug("{}'s config version {} is different with leader's {}",
                  peerVersion, selfVersion);
        if (peerAckedEpoch > acknowledgedEpoch ||
            (peerAckedEpoch == acknowledgedEpoch &&
             peerVersion.compareTo(selfVersion) > 0)) {
          LOG.debug("{} probably has right configuration, go back to "
              + "leader election.",
              source);
          // TODO : current we just go back to leader election, probably we want
          // to select the peer as leader.
          throw new BackToElectionException();
        }
      }
      // Rejects peer who is not in the current configuration.
      if (!currentConfig.contains(source)) {
        LOG.debug("Current configuration doesn't contain {}, ignores it.",
                  source);
        continue;
      }
      if (this.quorumMap.containsKey(source)) {
        throw new RuntimeException("Quorum set has already contained "
            + source + ", probably a bug?");
      }
      LOG.debug("Got PROPOSED_EPOCH from {}", source);
      PeerHandler ph = new PeerHandler(source, transport,
                                       config.getTimeoutMs()/3);
      ph.setLastProposedEpoch(peerProposedEpoch);
      ph.setSyncTimeoutMs(syncTimeoutMs);
      this.quorumMap.put(source, ph);
    }
    LOG.debug("Got proposed epoch from a quorum.");
  }
18452
private static void waitUntilFinished(FluoConfiguration config) {
    try (Environment env = new Environment(config)) {
      List<TableRange> ranges = getRanges(env);

      outer: while (true) {
        long ts1 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp();
        for (TableRange range : ranges) {
          boolean sawNotifications = waitTillNoNotifications(env, range);
          if (sawNotifications) {
            ranges = getRanges(env);
            // This range had notifications. Processing those notifications may have created
            // notifications in previously scanned ranges, so start over.
            continue outer;
          }
        }
        long ts2 = env.getSharedResources().getOracleClient().getStamp().getTxTimestamp();

        // Check to ensure the Oracle issued no timestamps during the scan for notifications.
        if (ts2 - ts1 == 1) {
          break;
        }
      }
    } catch (Exception e) {
      log.error("An exception was thrown -", e);
      System.exit(-1);
    }
  }
511121
public void finishBMDInitWithReferenceContext(BeanMetaData bmd) throws ContainerException, EJBConfigurationException {
        final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();

        if (isTraceOn && tc.isEntryEnabled()) //367834.5
            Tr.entry(tc, "finishBMDInitWithReferenceContext", bmd.j2eeName); //367834.5  d640935.1

        try {
            processReferenceContext(bmd);
        } catch (InjectionException ex) {
            // Unwrap the exception thrown by ComponentNameSpaceConfigurationProviderImpl.
            for (Throwable cause = ex.getCause(); cause != null; cause = cause.getCause()) {
                if (cause instanceof EJBConfigurationException) {
                    throw (EJBConfigurationException) cause;
                }
                if (cause instanceof ContainerException) {
                    throw (ContainerException) cause;
                }
            }

            throw new EJBConfigurationException(ex);
        }

        EnterpriseBean eb = bmd.wccm.enterpriseBean;

        // -----------------------------------------------------------------------
        // Look for Session Synchronization methods for Stateful beans  F743-25855
        // -----------------------------------------------------------------------
        if (bmd.isStatefulSessionBean() &&
            !bmd.usesBeanManagedTx) {
            processSessionSynchronizationMD(bmd, (Session) eb);
        }

        // -----------------------------------------------------------------------
        // Get the managed object factory or constructor for non-entity
        // -----------------------------------------------------------------------
        // Must obtain managed object factory before generating the implementation
        // classes, as the wrapper may be different if managed object factory will
        // handle injection and interceptors.
        if (!bmd.isEntityBean()) {
            initializeManagedObjectFactoryOrConstructor(bmd);
        }

        // ------------------------------------------------------------------------------
        // Load the all the generated (ie. EJBDeploy or JITDeploy)implementation classes
        // ------------------------------------------------------------------------------
        loadGeneratedImplementationClasses(bmd,
                                           bmd.methodsExposedOnLocalInterface, // F743-17630
                                           bmd.methodsExposedOnRemoteInterface, // F743-17630
                                           bmd.methodsExposedOnLocalHomeInterface, // F743-17630
                                           bmd.methodsExposedOnRemoteHomeInterface); // F743-17630

        // -----------------------------------------------------------------------
        // Get the constructor for entity beans
        // -----------------------------------------------------------------------
        // Must obtain the entity bean constructor after loading the generated
        // implementation classes, as the concrete bean class may be generated.
        if (bmd.isEntityBean()) {
            initializeEntityConstructor(bmd);
        }

        // -----------------------------------------------------------------------
        // Build the Message Destination Link Map if this is an MDB.       d510405
        // -----------------------------------------------------------------------
        // For an annotations only configuration, there will be no Enterprise
        // Bean in WCCM.  In this case there are no resource refs in xml to retrieve.
        if (eb != null && eb.getKindValue() == EnterpriseBean.KIND_MESSAGE_DRIVEN) {
            MessageDriven mdb = (MessageDriven) eb;
            String link = mdb.getLink();

            if (link != null) {
                if (isTraceOn && tc.isDebugEnabled())
                    Tr.debug(tc, "processing message-destination-link : " + link +
                                 " : " + bmd.j2eeName);

                String moduleName = null;
                String destJndiName = null;
                String appName = bmd.j2eeName.getApplication();

                Map<String, Map<String, String>> appMap = InjectionEngineAccessor.getMessageDestinationLinkInstance().getMessageDestinationLinks().get(appName); //d493167

                // create a new application map if one is not present
                if (appMap == null) {
                    appMap = new HashMap<String, Map<String, String>>();
                    InjectionEngineAccessor.getMessageDestinationLinkInstance().getMessageDestinationLinks().put(appName, appMap); //493167
                }

                // Get the JNDIname of the MessageDestination from BMD
                destJndiName = bmd.ivMessageDestinationJndiName;

                // parse the link if the link name is in the format of moduleName#linkName
                int lindex = link.indexOf('#');
                if (lindex != -1) {
                    // Module name may have path information... remove it.    d510405
                    int mindex = link.lastIndexOf('/');
                    if (mindex > -1 && mindex < lindex) {
                        moduleName = link.substring(mindex + 1, lindex);
                    } else {
                        // If no path was specified, then the referenced module
                        // is in the same location. Use first half of the link.
                        moduleName = link.substring(0, lindex);
                    }
                    link = link.substring(lindex + 1);
                } else {
                    moduleName = bmd.j2eeName.getModule();
                }

                Map<String, String> moduleMap = appMap.get(moduleName);
                if (moduleMap == null) {
                    moduleMap = new HashMap<String, String>();
                    appMap.put(moduleName, moduleMap);
                }

                if (isTraceOn && tc.isDebugEnabled())
                    Tr.debug(tc, "adding destination: " + link + " -> destinationJndiName:" +
                                 destJndiName + " for module: " + moduleName);

                moduleMap.put(link, destJndiName);
            }
        }

        //------------------------------------------------------------------------
        // Finish up a few last odds & ends
        //------------------------------------------------------------------------

        // Z/OS specific metadata and trace
        processZOSMetadata(bmd);

        // F743-609CodRev
        // If this bean has any asynchronous methods, make sure the container has a work manager
        // setup to execute runable objects for those methods
        if (bmd.ivHasAsynchMethod) {
            bmd.container.getEJBRuntime().setupAsync();
        }

        // Finally, run some checks to make sure everything we have initialized
        // is legal.
        bmd.validate();//d133681

        // Metadata for this bean type is now fully ready to use.  This flag must only be
        // set at the very end of BMD initialization.
        bmd.fullyInitialized = true;
        bmd.wccm = null;
        bmd.ivInitData = null;
        removeTemporaryMethodData(bmd); // F743-17630
        if (bmd._moduleMetaData.ivInterceptorBindingMap != null) {
            bmd._moduleMetaData.removeEJBInterceptorBindings(bmd.enterpriseBeanName); // d695226
        }

        // Write out bean metadata into the trace file in a format that the trace
        // explorer tool can read.
        if (isTraceOn && TEBeanMetaDataInfo.isTraceEnabled()) // d527372
            TEBeanMetaDataInfo.writeTraceBeanMetaData(bmd, bmd.ivModuleVersion); // d161864

        // TODO: MLS - this was an old comment.  Check if ActivationConfig could go
        // in the new bmd.wccm object now and be nulled out.
        // Note, do not null out ivActivationConfig at this time since
        // we must defer the destruction of reference until endpoint is
        // activated. See MessageEndpointFactoryImpl.activateEndpoint method.
        //ivActivationConfig = null;   //LI2110.41

        if (isTraceOn && tc.isEntryEnabled()) //367834.5
            Tr.exit(tc, "finishBMDInitWithReferenceContext"); //367834.5 d640935.1

    }
606323
public synchronized void notifyObservers(Object arg) {
        for (int i = 0; i < observers.size(); i++) {
            observers.elementAt(i).update(this, arg);
        }
    }
120435
public void observeBeforeBeanDiscovery(@Observes BeforeBeanDiscovery bbd, BeanManager beanManager) {
        log.debugf("MPJWTExtension(), adding producers");
        String extensionName = MPJWTExtension.class.getName();
        for (Class<?> clazz : new Class<?>[] {
                JWTAuthContextInfoProvider.class,
                CommonJwtProducer.class,
                PrincipalProducer.class,
                RawClaimTypeProducer.class,
                ClaimValueProducer.class,
                JsonValueProducer.class,
        }) {
            bbd.addAnnotatedType(beanManager.createAnnotatedType(clazz), extensionName + "_" + clazz.getName());
        }
    }
1049352
private void waitForAsyncSendsResolution() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "waitForAsyncSendsResolution");

        //AsyncSend is only for non-managed environments.. no need to wait for managed environment
        if (!isManaged()) {

            synchronized (_inProgressAysncSends) {
                while (_inProgressAysncSends.get() > 0L) {
                    try {
                        //wait for 20 seconds.. and again check for condition..if no notification comes before then.
                        _inProgressAysncSends.wait(1000 * 20);
                    } catch (InterruptedException e) {
                        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                            SibTr.debug(tc, "waitForAsyncSendsResolution got interrupted", e);
                    }
                }
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "waitForAsyncSendsResolution");
    }
464748
public final void waitForCheckpoint()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "waitForCheckpoint"
                            );

        if (!testInterfaces) {
            if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
                trace.exit(this, cclass
                           , "waitForCheckpoint via InterfaceDisabledException"
                                );
            throw new InterfaceDisabledException(this
                                                 , "waitForCheckpoint");
        } // if (!testInterfaces).   

        objectManagerState.waitForCheckpoint(true);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "waitForCheckpoint"
                            );
    }
334767
@Override
    public void resume() throws PauseableComponentException {
        try {
            shouldActivate = true;
            if (ivState == INACTIVE_STATE) {
                activateEndpoint();
            } else if (ivState == ACTIVE_STATE) {
                Tr.info(tc, "MDB_ENDPOINT_ALREADY_ACTIVE_CNTR4118I", beanMetaData.enterpriseBeanName, beanMetaData.getModuleMetaData().getName(),
                        beanMetaData.getModuleMetaData().getApplicationMetaData().getName());
            } else {
                throw new PauseableComponentException(Tr.formatMessage(tc, "MDB_ENDPOINT_DID_NOT_RESUME_CNTR4120W", beanMetaData.enterpriseBeanName,
                                                                       beanMetaData.getModuleMetaData().getName(),
                                                                       beanMetaData.getModuleMetaData().getApplicationMetaData().getName()));
            }
        } catch (ResourceException re) {
            throw new PauseableComponentException(re);
        }

    }
236393
private void registerJsfCdiToSpring(BeanDefinition definition) {

		if (definition instanceof AnnotatedBeanDefinition) {
			AnnotatedBeanDefinition annDef = (AnnotatedBeanDefinition) definition;

			String scopeName = null;
			// firstly check whether bean is defined via configuration
			if (annDef.getFactoryMethodMetadata() != null) {
				scopeName = deduceScopeName(annDef.getFactoryMethodMetadata());
			}
			else {
				// fallback to type
				scopeName = deduceScopeName(annDef.getMetadata());
			}

			if (scopeName != null) {
				definition.setScope(scopeName);

				log.debug("{} - Scope({})", definition.getBeanClassName(), scopeName.toUpperCase());
			}
		}
	}
14511
private void afterBeginCallback() {
		if ( this.timeOut > 0 ) {
			owner.setTransactionTimeOut( this.timeOut );
		}
		owner.afterTransactionBegin();
		for ( TransactionObserver observer : observers ) {
			observer.afterBegin();
		}
		log.trace( "ResourceLocalTransactionCoordinatorImpl#afterBeginCallback" );
	}
1329771
protected void waitDebuggerConnected(ILaunch launch,
			DebugSessionAcceptor acceptor) throws CoreException
	{
		int timeout = VdmDebugPlugin.getDefault().getConnectionTimeout();
		if (!acceptor.waitConnection(timeout))
		{
			launch.terminate();
			return;
		}
		if (!acceptor.waitInitialized(60 * 60 * 1000))
		{
			launch.terminate();
			abort("errDebuggingEngineNotInitialized", null);
		}
	}
241201
@Override
	public Object postProcessBeforeInitialization(final Object bean, final String beanName) throws BeansException {
		if (bean instanceof EventSubscriber) {
			Subscribe annotation = getAnnotation(bean.getClass(), beanName);
			if (annotation != null) {
				subscribers.put(beanName, annotation);
			}
		}
		return bean;
	}
612560
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if( bean instanceof AuthenticationAware || bean instanceof LoginAware ) {

            // If the bean isn't a singleton, then add it to our list
            if( beanName == null || !getApplicationContext().containsBean( beanName )
                    || !getApplicationContext().isSingleton( beanName ) ) {
                addToNonSingletonListeners( bean );
            }

            // Install the last known authentication token
            if( bean instanceof AuthenticationAware ) {
                if( logger.isDebugEnabled() )
                    logger.debug( "NOTIFY bean '" + bean + "' of new authorization for '" + currentAuthentication
                            + "'" );

                AuthenticationAware aab = (AuthenticationAware) bean;
                aab.setAuthenticationToken(currentAuthentication);
            }
        }
        return bean;
    }