Search in sources :

Example 1 with ExtensionBean

use of org.jboss.weld.bean.builtin.ExtensionBean in project core by weld.

the class Probe method init.

/**
 * @param beanManager
 */
void init(BeanManagerImpl beanManager) {
    ContextualStore contextualStore = beanManager.getServices().get(ContextualStore.class);
    bdaToManager.putAll(Container.instance(beanManager).beanDeploymentArchives());
    for (Entry<BeanDeploymentArchive, BeanManagerImpl> entry : bdaToManager.entrySet()) {
        ProbeLogger.LOG.processingBeanDeploymentArchive(entry.getKey().getId());
        BeanManagerImpl manager = entry.getValue();
        // Beans
        for (Bean<?> bean : manager.getBeans()) {
            // there's only one Instance bean though
            if (bean instanceof ExtensionBean) {
                // ExtensionBean does not include BeanManager in its BeanIdentifier
                ExtensionBean<?> extensionBean = (ExtensionBean<?>) bean;
                if (!idToBean.containsValue(extensionBean)) {
                    putBean(Components.getId(extensionBean.getIdentifier()), manager, extensionBean);
                }
            } else if (bean instanceof AbstractBuiltInBean<?>) {
                // Built-in beans are identified by the set of types
                String id = Components.getBuiltinBeanId((AbstractBuiltInBean<?>) bean);
                if (!idToBean.containsKey(id)) {
                    putBean(id, bean);
                }
            } else {
                if (manager.isBeanEnabled(bean)) {
                    // Make sure the bean is truly enabled
                    putBean(contextualStore, manager, bean);
                }
            }
        }
        // Interceptors
        for (Interceptor<?> interceptor : manager.getInterceptors()) {
            putBean(contextualStore, manager, interceptor);
        }
        // Decorators
        for (Decorator<?> decorator : manager.getDecorators()) {
            putBean(contextualStore, manager, decorator);
        }
        // Observers
        int customObservers = 0;
        for (ObserverMethod<?> observerMethod : manager.getObservers()) {
            if (observerMethod instanceof ObserverMethodImpl) {
                ObserverMethodImpl<?, ?> observerMethodImpl = (ObserverMethodImpl<?, ?>) observerMethod;
                putObserver(Components.getId(observerMethodImpl.getId()), observerMethodImpl);
            } else {
                // Custom observer methods
                putObserver(Components.getId("" + customObservers++), observerMethod);
            }
        }
    }
    // Find declared producers
    for (Bean<?> candidate : idToBean.values()) {
        BeanKind kind = BeanKind.from(candidate);
        if ((BeanKind.PRODUCER_FIELD.equals(kind) || BeanKind.PRODUCER_METHOD.equals(kind) || BeanKind.RESOURCE.equals(kind)) && candidate instanceof AbstractProducerBean) {
            AbstractProducerBean<?, ?, ?> producerBean = (AbstractProducerBean<?, ?, ?>) candidate;
            beanToDeclaredProducers.put(producerBean.getDeclaringBean(), producerBean);
        }
    }
    findUnusedBeans();
    initTs.set(System.currentTimeMillis());
}
Also used : AbstractBuiltInBean(org.jboss.weld.bean.builtin.AbstractBuiltInBean) ExtensionBean(org.jboss.weld.bean.builtin.ExtensionBean) AbstractProducerBean(org.jboss.weld.bean.AbstractProducerBean) InjectionPoint(javax.enterprise.inject.spi.InjectionPoint) BeanManagerImpl(org.jboss.weld.manager.BeanManagerImpl) ContextualStore(org.jboss.weld.serialization.spi.ContextualStore) ObserverMethodImpl(org.jboss.weld.event.ObserverMethodImpl) BeanDeploymentArchive(org.jboss.weld.bootstrap.spi.BeanDeploymentArchive) BeanKind(org.jboss.weld.probe.Components.BeanKind)

Aggregations

InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 AbstractProducerBean (org.jboss.weld.bean.AbstractProducerBean)1 AbstractBuiltInBean (org.jboss.weld.bean.builtin.AbstractBuiltInBean)1 ExtensionBean (org.jboss.weld.bean.builtin.ExtensionBean)1 BeanDeploymentArchive (org.jboss.weld.bootstrap.spi.BeanDeploymentArchive)1 ObserverMethodImpl (org.jboss.weld.event.ObserverMethodImpl)1 BeanManagerImpl (org.jboss.weld.manager.BeanManagerImpl)1 BeanKind (org.jboss.weld.probe.Components.BeanKind)1 ContextualStore (org.jboss.weld.serialization.spi.ContextualStore)1