Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-625

When exactly are events with @Initialized(X.class) and @Destroyed(X.class) qualifiers fired

    Details

      Description

      The spec states that @Initialized(X.class) is fired when a context is initialized and @Destroyed(X.class) when a context is destroyed (note that for @ApplicationScoped the wording leaves out the context: "when the application is destroyed").

      Does it mean that:

      • @Initialized(X.class) is fired after the initialization of a context is finished, i.e. the context is ready?
      • @Destroyed(X.class) is fired after the destruction of a context is finished, i.e. after all the beans are destroyed?

      I'm asking because for @Destroyed(X.class) it might be useful to perform some cleanup before the context is actually destroyed - see also CDI-601.

      In RI/Weld, the behaivour of @Destroyed(ApplicationScoped.class) is currently a little bit inconsistent. For webapps and Weld SE, the event is fired before the context is destroyed. But for non-web EE modules (e.g. ejb jar) the event is fired after the context is destroyed.

      I believe this should be more clear.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mkouba Martin Kouba
                  Reporter:
                  mkouba Martin Kouba
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  7 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: