use of org.jboss.weld.serialization.spi.ContextualStore 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());
}
Aggregations