Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

In other words, is the instance of my Extension contextual and what is its scope?

According to section 11.5 of the CDI specification:

The container instantiates a single instance of each extension at the beginning of the application initialization process and maintains a reference to it until the application shuts down. The container delivers event notifications to this instance by calling its observer methods.

Speaking in code, the following assertion will be true (because there is always at least one bean):

public class TestExtension implements Extension
{
   private List<Bean> beans = new ArrayList<Bean>();

   public void onProcessBean(@Observes ProcessBean e)
   {
      beans.add(e.getBean());
   }

   public void afterBeanDiscovery(@Observes AfterBeanDiscovery e)
   {
      assert beans.size() > 0;
   }
}

The possibilities of what you can do with extensions are limitless.