Search in sources :

Example 1 with ForwardingBeanAttributes

use of org.jboss.weld.util.bean.ForwardingBeanAttributes in project core by weld.

the class ProbeExtension method processBeanAttributes.

public <T> void processBeanAttributes(@Observes ProcessBeanAttributes<T> event, BeanManager beanManager) {
    probe.getBootstrapStats().increment(EventType.PBA);
    final BeanAttributes<T> beanAttributes = event.getBeanAttributes();
    final WeldManager weldManager = (WeldManager) beanManager;
    if (isMonitored(event.getAnnotated(), beanAttributes, weldManager)) {
        event.setBeanAttributes(new ForwardingBeanAttributes<T>() {

            @Override
            public Set<Class<? extends Annotation>> getStereotypes() {
                return ImmutableSet.<Class<? extends Annotation>>builder().addAll(attributes().getStereotypes()).add(MonitoredComponent.class).build();
            }

            @Override
            protected BeanAttributes<T> attributes() {
                return beanAttributes;
            }

            @Override
            public String toString() {
                return beanAttributes.toString();
            }
        });
        ProbeLogger.LOG.monitoringStereotypeAdded(event.getAnnotated());
    }
    if (eventMonitorContainerLifecycleEvents) {
        addContainerLifecycleEvent(event, "Types: [" + Formats.formatTypes(event.getBeanAttributes().getTypes()) + "], qualifiers: [" + Formats.formatAnnotations(event.getBeanAttributes().getQualifiers()) + "]", beanManager);
    }
}
Also used : ImmutableSet(org.jboss.weld.util.collections.ImmutableSet) Set(java.util.Set) ForwardingBeanAttributes(org.jboss.weld.util.bean.ForwardingBeanAttributes) ProcessBeanAttributes(javax.enterprise.inject.spi.ProcessBeanAttributes) BeanAttributes(javax.enterprise.inject.spi.BeanAttributes) Annotation(java.lang.annotation.Annotation) WeldManager(org.jboss.weld.manager.api.WeldManager)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Set (java.util.Set)1 BeanAttributes (javax.enterprise.inject.spi.BeanAttributes)1 ProcessBeanAttributes (javax.enterprise.inject.spi.ProcessBeanAttributes)1 WeldManager (org.jboss.weld.manager.api.WeldManager)1 ForwardingBeanAttributes (org.jboss.weld.util.bean.ForwardingBeanAttributes)1 ImmutableSet (org.jboss.weld.util.collections.ImmutableSet)1