Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8091703

Support for Dependency Injection in Application

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: tbd
    • Component/s: javafx
    • Labels:
      None

      Description

      I'm tinkering with a pet project trying to integrate CDI (Weld) with JavaFX2. I don't use FXML for the moment, just building the GUI programatically.

      Weld creates my Application class, with all its dependencies, and launches an event that I can answer and call to Application.launch. The problem is that this method creates a new instance of my Application subclass, so all the injections are lost.

      I could work around if Application.launch accepted the proper instance and not only its class, but I suppose it's much better if you could subclass some method used to create the instance or even provide an instance builder or factory, so I could use Weld, Guice, Spring or whatever.

      I've seen a couples of issues about that in FXMLLoader, related to the controller creation, but I think I'm the first one requesting this at this level. Sorry if it's not the case. :)

      Kind regards!

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Imported: