Add a new bean to the list of beans to be checked for timeouts
497209
public void add(StatefulBeanO beanO) {
        BeanId id = beanO.beanId;
        TimeoutElement elt = beanO.ivTimeoutElement;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "add " + beanO.beanId + ", " + elt.timeout);

        // LIDB2775-23.4 Begins
        Object obj = ivStatefulBeanList.put(id, elt);
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, (obj != null) ? "Stateful bean information replaced" : "Stateful bean information added");
        // LIDB2775-23.4 Ends

        synchronized (this) {
            if (numObjects == 0 && !ivIsCanceled) // F743-33394
            {
                startAlarm();
            }

            numObjects++;
            numAdds++;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "add");
    }
1316693
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {

		if (beanFactory == null) {
			return;
		}

		String[] beanNames = beanFactory.getBeanDefinitionNames();
		int singletonBeanCount = 0;

		for (int i = 0; i < beanNames.length; i++) {
			// using beanDefinition to check singleton property because when
			// accessing through
			// context (applicationContext.isSingleton(beanName)), bean will be
			// created already,
			// possibly bypassing other BeanFactoryPostProcessors
			BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanNames[i]);

			if (beanDefinition.isSingleton()) {
				singletonBeanCount++;
			}

		}

		this.progressMonitor.taskStarted(this.loadingAppContextMessage, singletonBeanCount);

		beanFactory.addBeanPostProcessor(new ProgressMonitoringBeanPostProcessor(beanFactory));

	}
380119
private void instantiateSingletons() {
        if (log.isDebugEnabled()) {
            log.debug("Initializing singletons in " + this);
        }

        Activity activity = context.getDefaultActivity();
        for (BeanRule beanRule : beanRuleRegistry.getIdBasedBeanRules()) {
            instantiateSingleton(beanRule, activity);
        }
        for (Set<BeanRule> beanRuleSet : beanRuleRegistry.getTypeBasedBeanRules()) {
            for (BeanRule beanRule : beanRuleSet) {
                instantiateSingleton(beanRule, activity);
            }
        }
        for (BeanRule beanRule : beanRuleRegistry.getConfigurableBeanRules()) {
            instantiateSingleton(beanRule, activity);
        }
    }
1279538
private void _createEagerBeans(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
        List<ManagedBean> eagerBeans = new ArrayList<ManagedBean>();
        
        // check all registered managed-beans
        for (ManagedBean bean : runtimeConfig.getManagedBeans().values())
        {
            String eager = bean.getEager();
            if (eager != null && "true".equals(eager))
            {
                // eager beans are only allowed for application scope
                if (ManagedBeanBuilder.APPLICATION.equals(bean.getManagedBeanScope()))
                {
                    // add to eager beans
                    eagerBeans.add(bean);
                }
                else
                {
                    // log warning and continue (the bean will be lazy loaded)
                    log.log(Level.WARNING, "The managed-bean with name "
                            + bean.getManagedBeanName()
                            + " must be application scoped to support eager=true.");
                }
            }
        }
        
        // check if there are any eager beans
        if (!eagerBeans.isEmpty())
        {
            ManagedBeanBuilder managedBeanBuilder = new ManagedBeanBuilder();
            Map<String, Object> applicationMap = externalContext.getApplicationMap();
            
            for (ManagedBean bean : eagerBeans)
            {
                // check application scope for bean instance
                if (applicationMap.containsKey(bean.getManagedBeanName()))
                {
                    // do not build bean, because it already exists
                    // (e.g. @ManagedProperty from previous managed bean already created it)
                    continue;
                }

                // create instance
                Object beanInstance = managedBeanBuilder.buildManagedBean(facesContext, bean);
                
                // put in application scope
                applicationMap.put(bean.getManagedBeanName(), beanInstance);
            }
        }
    }
289745
@Override
    public void merge(Collection<Bean> beans) throws AbortRuntimeException {
        init();
        Map<HBeanRow, HBeanRow> providedRows = new HashMap<>();
        for (Bean bean : beans) {
            HBeanRow row = new HBeanRow(bean, uids);
            providedRows.put(row, row);
            for (BeanId id : bean.getReferences()) {
                HBeanRow refRow = new HBeanRow(id, uids);
                providedRows.put(refRow, refRow);
            }
        }
        HBeanRowCollector storedCollector = null;
        try {
            storedCollector = table.getEager(providedRows);
        } catch (HBeanNotFoundException e) {
            // only throw exception if the bean was not provided
            if (!idsFoundIn(beans, e)) {
                throw Events.CFG301_MISSING_RUNTIME_REF(e.getNotFound().iterator().next());
            }
        }

        Map<HBeanRow, HBeanRow> storedRows = storedCollector.getRowMap();
        Set<RowMutations> mutations = new HashSet<>();

        for (HBeanRow provided : providedRows.keySet()) {
            HBeanRow stored = storedRows.get(provided);
            RowMutations rowMutations = new RowMutations(provided.getRowKey());
            Set<HBeanRow> deleteReferences = stored.merge(provided, rowMutations);
            try {
                deleteReferences = table.getLazy(deleteReferences);
                for (HBeanRow row : deleteReferences) {
                    RowMutations mutation = row.removePredecessor(provided);
                    mutations.add(mutation);
                }
            } catch (HBeanNotFoundException e) {
                throw new IllegalStateException("Broken predecessors");
            }
            mutations.add(rowMutations);
        }
        table.mutate(mutations);
    }
809241
function (def) {

                // prepare error stack
                this._errors = [];

                var beans = def.$beans;
                for (var beanName in beans) {
                    if (!beans.hasOwnProperty(beanName) || beanName.indexOf(':') != -1) {
                        continue;
                    }
                    // check that keys for beans are valid
                    if (!Aria.checkJsVarName(beanName)) {
                        this._logError(this.INVALID_NAME, [beanName, this._currentBeanName]);
                    }
                    this._preprocessBean(beans[beanName], def.$package + "." + beanName, def);
                }

                // Generate fast normalization functions at the end:
                var toGenerateFastNorm = this.__toGenerateFastNorm;
                while (toGenerateFastNorm.length > 0) {
                    var beanDef = toGenerateFastNorm.shift();
                    var baseType = beanDef[this._MD_BASETYPE];

                    if (baseType.makeFastNorm) {
                        // generate fast normalizer
                        baseType.makeFastNorm(beanDef);
                    }
                }

                return this._errors;
            }
284049
public void registerSingleton(String name, Class<?> clazz) throws BeansException {
        GenericBeanDefinition bd = new GenericBeanDefinition();
        bd.setBeanClass(clazz);
        getDefaultListableBeanFactory().registerBeanDefinition(name, bd);
    }
373581
private static void checkBeanFactory(long waitTime, String bean) {
		if(beanFactory != null) {
			return;
		}

		// Jeśli czas oczekiwania jest określony, to wstrzymujemy bieżący wątek
		// do momentu ustawienia fabryki bean'ów. Dla ujemnej wartości czasu
		// oczekiwania - do skutku. Jeśli wartość jest dodatnia - aż upłynie
		// zdana ilość sekund:
		if(waitTime != 0) {
			long endTime = currentTimeMillis() + (waitTime * 1000);
			while(beanFactory == null && (waitTime < 0 || currentTimeMillis() < endTime)) {
				try {
					Thread.sleep(1000);
				} catch(InterruptedException e) {
				}
			}
		}

		if(beanFactory == null) {
			throw new BeanRetrievalException(bean,
					"Bean utils not initialized (bean factory not set)");
		}
	}
1287103
private void setupTempLists()
    {
        //synchronized(this){   //d173022.2
        //d115597 if necessary create a new tempList
        // and list of currentBeanOs.  Always delay this until actually needed
        //d115597

        if (tempList == null) {
            tempList = new ArrayList<BeanO>();
            currentBeanOs = new HashMap<BeanId, BeanO>();//should release old list
        }
        //}
    }
855247
public void add(BeanId beanId)
    {
        BeanId[] buckets = this.ivBuckets;
        buckets[(beanId.hashValue & 0x7FFFFFFF) % buckets.length] = beanId;
    }
519377
public static <E> BeanListHandler<E> create(Class<E> beanType) {
		return new BeanListHandler<E>(beanType);
	}
280574
@Override
    public void create(Collection<Bean> beans) throws AbortRuntimeException {
        init();
        Set<HBeanRow> beanRows = new HashSet<>();
        Map<HBeanRow, HBeanRow> refRows = new HashMap<>();
        Map<BeanId, Bean> beansMap = BeanUtils.uniqueIndex(beans);
        try {
            for (Bean bean : beans) {
                beanRows.add(new HBeanRow(bean, uids));
                for (BeanId ref : bean.getReferences()) {
                    Bean refBean = beansMap.get(ref);
                    HBeanRow row;
                    if (refBean == null) {
                        row = new HBeanRow(ref, uids);
                    } else {
                        row = new HBeanRow(refBean, uids);
                    }
                    refRows.put(row, row);
                }
            }
            table.getLazy(beanRows);
            throw Events.CFG303_BEAN_ALREADY_EXIST(beans.iterator().next().getId());
        } catch (HBeanNotFoundException e) {
            // ensure beans to be create does not exist
        }

        // ensure references exist either in memory or storage
        try {
            refRows = table.getLazyAsMap(refRows);
        } catch (HBeanNotFoundException e) {
            // only throw exception if the bean was not provided
            // as an argument to the create method.
            if (!idsFoundIn(beans, e)) {
                throw Events.CFG301_MISSING_RUNTIME_REF(e.getNotFound().iterator().next());
            }
            // make sure that references found in storage override the refRows
            for (HBeanRow row : e.getFound().keySet()) {
                refRows.put(row, row);
            }

        }
        // select the rows to update predecessors
        for (HBeanRow beanRow : beanRows) {
            for (HBeanRow refRow : beanRow.getReferenceRows()) {
                refRow = refRows.get(refRow);
                refRow.addPredecessor(beanRow);
            }
        }

        table.put(beanRows);
        table.put(Sets.newHashSet(refRows.values()));
    }
1248106
protected void addToNonSingletonListeners(final Object bean) {
        if( logger.isDebugEnabled() )
            logger.debug( "Adding Authentication/LoginAware bean to list of non-singleton listeners: bean='" + bean );

        nonSingletonListeners.add( new WeakReference( bean ) );
    }
890121
@Override
    public synchronized BeanContext stop() {
        if (terminating.compareAndSet(false, true)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Stopping BeanContext");
            }
            publishEvent(new ShutdownEvent(this));

            // need to sort registered singletons so that beans with that require other beans appear first
            List<BeanRegistration> objects = topologicalSort(singletonObjects.values());

            Set<Integer> processed = new HashSet<>();
            for (BeanRegistration beanRegistration : objects) {
                BeanDefinition def = beanRegistration.beanDefinition;
                Object bean = beanRegistration.bean;
                int sysId = System.identityHashCode(bean);
                if (processed.contains(sysId)) {
                    continue;
                }

                if (LOG_LIFECYCLE.isDebugEnabled()) {
                    LOG_LIFECYCLE.debug("Destroying bean [{}] with identifier [{}]", bean, beanRegistration.identifier);
                }

                processed.add(sysId);
                if (def instanceof DisposableBeanDefinition) {
                    try {
                        //noinspection unchecked
                        ((DisposableBeanDefinition) def).dispose(this, bean);
                    } catch (Throwable e) {
                        if (LOG.isErrorEnabled()) {
                            LOG.error("Error disposing of bean registration [" + def.getName() + "]: " + e.getMessage(), e);
                        }
                    }
                }
                if (def instanceof Closeable) {
                    try {
                        ((Closeable) def).close();
                    } catch (Throwable e) {
                        if (LOG.isErrorEnabled()) {
                            LOG.error("Error disposing of bean registration [" + def.getName() + "]: " + e.getMessage(), e);
                        }
                    }
                }
                if (bean instanceof LifeCycle) {
                    ((LifeCycle) bean).stop();
                }
            }

            terminating.set(false);
            running.set(false);
            ClassLoadingReporter.finish();
        }
        return this;
    }
787770
private int insertIndex(List<BeanMetadataElement> filterChain) {
    int i;
    for (i = 0; i < filterChain.size(); i++) {
      BeanMetadataElement filter = filterChain.get(i);
      if (filter instanceof BeanDefinition) {
        String beanName = ((BeanDefinition) filter).getBeanClassName();
        if (beanName.equals(ExceptionTranslationFilter.class.getName())) {
           return i + 1;
        }
      }
    }
    return filterChain.size();
  }
175501
private void addCallback(BeanMessageID type, Callback<?> callback) {
        List<Callback<?>> callbacks = beanCallbacks.get(type);
        if (callbacks == null) {
            callbacks = new ArrayList<>(16);
            beanCallbacks.put(type, callbacks);
        }
        callbacks.add(callback);
    }
717382
def _add_timeout(self, request, future):
        """"""
        io_loop = IOLoop.current()
        t = io_loop.call_later(
            request.ttl,
            self._request_timed_out,
            request.id,
            request.service,
            request.ttl,
            future,
        )
        io_loop.add_future(future, lambda f: io_loop.remove_timeout(t))