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

Provide an API to say a bean depends on another instance

    XMLWordPrintable

Details

    • Epic
    • Resolution: Obsolete
    • Major
    • None
    • None
    • None
    • None
    • Programmatic dependencies
    • To Do

    Description

      Sometimes you want to initialize a bean before another bean. This is typically the case of @DependsOn with EJB but it can be more vicious and through several layers.

      If A depends on B which depends on C then we can desire to initialize C before A but if A, B and C are normal scoped then it will not happen before C is touched before touching A.

      We can't guarantee we can find the dependency and it is not desirable to hardcode it sometimes (test mock shouldnt go in "main" code typically). That's why having an event (guess it will belong to extensions) allowing to require this kind of eager initialization can be nice.

      we would get something like

      event.dependencyOn(bean1, bean2);
      

      and it would be fired before after validation event.

      The runtime behavior will be to create bean2 before bean1 (I have no issue reversing params/renaming the method). Only trick will be for not normal scoped beans where we can need to reuse the same instance but it sounds feasible in term of implementation since we'll be in the "create" stack anyway.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rmannibucau@gmail.com Romain Manni-Bucau
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: