Search in sources :

Example 1 with WeldInjectionPointAttributes

use of org.jboss.weld.injection.attributes.WeldInjectionPointAttributes in project core by weld.

the class Probe method hasDeclaredObserversOrIsInjectedIntoObserver.

private boolean hasDeclaredObserversOrIsInjectedIntoObserver(Bean<?> bean, Collection<ObserverMethod<?>> observers) {
    for (ObserverMethod<?> observerMethod : observers) {
        if (observerMethod instanceof ObserverMethodImpl) {
            ObserverMethodImpl<?, ?> observerMethodImpl = (ObserverMethodImpl<?, ?>) observerMethod;
            if (bean.equals(observerMethodImpl.getDeclaringBean())) {
                return true;
            }
            Set<WeldInjectionPointAttributes<?, ?>> injectionPoints = observerMethodImpl.getInjectionPoints();
            if (!injectionPoints.isEmpty()) {
                BeanManager beanManager = getBeanManager(observerMethodImpl.getDeclaringBean());
                if (beanManager != null) {
                    for (WeldInjectionPointAttributes<?, ?> injectionPoint : injectionPoints) {
                        if (bean.equals(beanManager.resolve(beanManager.getBeans(injectionPoint.getType(), injectionPoint.getQualifiers().toArray(new Annotation[injectionPoint.getQualifiers().size()]))))) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : ObserverMethodImpl(org.jboss.weld.event.ObserverMethodImpl) WeldInjectionPointAttributes(org.jboss.weld.injection.attributes.WeldInjectionPointAttributes) BeanManager(javax.enterprise.inject.spi.BeanManager) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 ObserverMethodImpl (org.jboss.weld.event.ObserverMethodImpl)1 WeldInjectionPointAttributes (org.jboss.weld.injection.attributes.WeldInjectionPointAttributes)1