Most of todays Java EE web applications use CDI. Most of them also take advantage of using CDI SPI and its extension mechanism. You can implement several container lifecycle events (see Contexts and Dependency Injection for the Java EE platform) and you can also have multiple CDI extensions in your web application and thus it might be sometimes difficult to track all actions performed by your CDI extensions. Since Weld 2.3.4.Final you can track all these actions at least at logging level. Just turn on DEBUG log level (see Weld: Documentation) for Weld and watch e.g for following output:

 

DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-3) WELD-000154: AfterBeanDiscovery.addBean() called by com.redhat.tremes.MyExtension@5a86fc30 for com.redhat.tremes.FooBean@47abc033
DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-8) WELD-000148: ProcessAnnotatedType.setAnnotatedType() called by com.redhat.tremes.MyExtension@50fed5b1: [BackedAnnotatedType]
                                                                       public  class com.redhat.tremes.Foo replaced by com.redhat.tremes.MyAnnotatedType@3153e10c













 

 

This corresponds to the following CDI extension:

 

public class MyExtension implements Extension {

   void observes(@Observes ProcessAnnotatedType<Foo> event) {

     annotatedTypeFoo = event.getAnnotatedType();
     event.setAnnotatedType(new MyAnnotatedType(annotatedTypeFoo));
   }

   public void observes(@Observes AfterBeanDiscovery event) {
     AnnotatedConstructor<Foo> constructor = annotatedTypeFoo.getConstructors().iterator().next();
     event.addBean(new FooBean(constructor));
   }

   private AnnotatedType<Foo> annotatedTypeFoo;

}






 

There are going to be implemented further enhancements in upcoming Weld 2.3.5.Final release. See: [WELD-2170] Log veto actions performed by extensions - JBoss Issue Tracker and [WELD-2171] Log modifications of lists returned by AfterTypeDiscovery - JBoss Issue Tracker