Search in sources :

Example 6 with ObserverMethodImpl

use of org.jboss.weld.event.ObserverMethodImpl 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

ObserverMethodImpl (org.jboss.weld.event.ObserverMethodImpl)6 JsonObjectBuilder (org.jboss.weld.probe.Json.JsonObjectBuilder)4 Annotation (java.lang.annotation.Annotation)3 JsonArrayBuilder (org.jboss.weld.probe.Json.JsonArrayBuilder)3 AbstractProducerBean (org.jboss.weld.bean.AbstractProducerBean)2 AbstractBuiltInBean (org.jboss.weld.bean.builtin.AbstractBuiltInBean)2 BeanManagerImpl (org.jboss.weld.manager.BeanManagerImpl)2 BeanKind (org.jboss.weld.probe.Components.BeanKind)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 Bean (javax.enterprise.inject.spi.Bean)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 Decorator (javax.enterprise.inject.spi.Decorator)1 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 Interceptor (javax.enterprise.inject.spi.Interceptor)1 Prioritized (javax.enterprise.inject.spi.Prioritized)1 ProcessAnnotatedType (javax.enterprise.inject.spi.ProcessAnnotatedType)1 ProcessSyntheticAnnotatedType (javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType)1 AbstractClassBean (org.jboss.weld.bean.AbstractClassBean)1