{"id":18523502,"url":"https://github.com/gluonhq/ignite","last_synced_at":"2025-10-10T22:46:40.824Z","repository":{"id":45202992,"uuid":"166857442","full_name":"gluonhq/ignite","owner":"gluonhq","description":"Gluon Ignite creates a common abstraction over several popular dependency injection frameworks. With this library, developers can use popular dependency injection frameworks in their JavaFX applications, including inside their FXML controllers.","archived":false,"fork":false,"pushed_at":"2021-12-31T16:17:57.000Z","size":151,"stargazers_count":31,"open_issues_count":1,"forks_count":13,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-24T05:13:40.686Z","etag":null,"topics":["dependency-injection","javafx"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gluonhq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-21T18:01:39.000Z","updated_at":"2025-03-12T02:50:47.000Z","dependencies_parsed_at":"2022-08-30T06:00:27.766Z","dependency_job_id":null,"html_url":"https://github.com/gluonhq/ignite","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonhq%2Fignite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonhq%2Fignite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonhq%2Fignite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gluonhq%2Fignite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gluonhq","download_url":"https://codeload.github.com/gluonhq/ignite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248031502,"owners_count":21036414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dependency-injection","javafx"],"created_at":"2024-11-06T17:35:48.494Z","updated_at":"2025-10-10T22:46:35.805Z","avatar_url":"https://github.com/gluonhq.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gluon Ignite \n\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-dagger.svg?label=ignite-dagger)](https://search.maven.org/artifact/com.gluonhq/ignite-dagger)\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-guice.svg?label=ignite-guice)](https://search.maven.org/artifact/com.gluonhq/ignite-guice)\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-spring.svg?label=ignite-spring)](https://search.maven.org/artifact/com.gluonhq/ignite-spring)\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-micronaut.svg?label=ignite-micronaut)](https://search.maven.org/artifact/com.gluonhq/ignite-micronaut)\n\nGluon Ignite allows developers to use popular dependency injection frameworks in their JavaFX applications, \nincluding inside their FXML controllers. Gluon Ignite creates a common abstraction over several popular \ndependency injection frameworks (currently _[Guice](https://github.com/google/guice), [Spring](https://spring.io/)_, \nand _[Dagger](https://square.github.io/dagger/)_). \n\nSince `v1.1.0` we also added an extended support for [Microunaut](https://micronaut.io). Read further for more details.  \n\n\n\nWith full support of [JSR-330](https://www.jcp.org/en/jsr/detail?id=330), Gluon Ignite makes using dependency injection in JavaFX applications trivial. \nHere is a quick example of creating an application using the Guice framework and Gluon Ignite.\n\n```java\npublic class GuiceApp extends Application implements ExampleApp {\n \n    public static void main(String[] args) {\n        launch(args);\n    }\n \n    private GuiceContext context = new GuiceContext(this, () -\u003e Arrays.asList(new GuiceModule()));\n \n    @Inject private FXMLLoader fxmlLoader;\n \n    @Override public void start(Stage primaryStage) throws IOException {\n        context.init();\n        fxmlLoader.setLocation(getViewLocation());\n        Parent view = fxmlLoader.load();\n \n        primaryStage.setTitle(\"Guice Example\");\n        primaryStage.setScene(new Scene(view));\n        primaryStage.show();\n    }\n}\n \nclass GuiceModule extends AbstractModule {\n    @Override protected void configure() {\n        bind(Service.class).to(Service.class);\n    }\n}\n```\nBy using Gluon Ignite, you not only get dependency injection inside your application class, but also \nwithin your FXML controllers too. Even though the sample above shows a Guice context, as mentioned \nGluon Ignite also supports other DI frameworks. By using a `DaggerContext` or `SpringContext` in your application, \nit can be easily set up to work with those frameworks instead. \nSamples of applications are available in the project [Wiki](https://github.com/gluonhq/ignite/wiki/Spring-Sample)\n\n### Micronaut support\n\nIgnite implementation for Micronaut provides much deeper integration with Micronaut framework.\n\n#### _Application main class_\n\nOn top of common, for Ignite, implementation of `DIContext` interface, Ignite Micronaut provides \nspecial implementation of JavaFX `Application` class, which can to be configured \nas your main class: `com.gluonhq.ignite.micronaut.FXApplication`.\nThis makes the code a lot cleaner. As an application developer, you just have to implement \nan entry point into your application, which will be picked up by Micronaut automatically, \nsince it is a normal Micronaut bean. \n\nHere is a simple example:\n```java\nimport io.micronaut.context.event.ApplicationEventPublisher;\nimport io.micronaut.runtime.event.annotation.EventListener;\nimport javafx.scene.Scene;\nimport javafx.stage.Stage;\n\nimport javax.inject.Inject;\nimport javax.inject.Singleton;\n\nimport static com.gluonhq.micronaut.FXApplication.StartEvent;\nimport static com.gluonhq.micronaut.FXApplication.StopEvent;\n\n@Singleton\npublic class AppEntryPoint {\n\n    @Inject\n    private Object something;\n\n    @EventListener\n    void onAppStart(StartEvent event) {\n        Stage stage = event.getStage();\n        Scene scene = new Scene( new Label(\"Hello, world!\"));\n        stage.setScene(scene);\n        stage.setTitle(\"My application\");\n        stage.show();\n    }\n    \n    @EventListener\n    void onAppStop(StopEvent event) {\n        //...\n    }\n\n}\n```\n#### _JavaFX Application Thread_ \nAny bean method can be forced to run on JavaFX Application Thread using `OnFxThread` annotation\n```java\n@OnFXThread\nvoid refreshTime() {\n    label.setText(timePattern.format(ZonedDateTime.now()));\n}\n```\n#### _FXML Views_ \nIgnite Micronaut implements support for FXML views based on naming conventions:\n- A simple empty bean inherited from `FXMLView` defines the view, its name should be exactly \n  the same as corresponding `fxml` file and should be in the corresponding package. This name usually ends with `View` but does not have to.\n- A bean named `\u003cViewName\u003eController` defines a related FXML controller class. As per JavaFX standard, \n  it should be defined within `fxml` as well. The framework automatically makes it injectable.\n- Optional stylesheet can be provided and should be located in the corresponding folder, \n  next to the `fxml` file, named as `\u003cViewName\u003e.css`       \n  \nThe view loaded by simply injecting the `View` class, and retrieving its root node using `getRoot` method.\nHere is a simple example:\n```java\npackage example.view;\n\n@Singleton\npublic class ContentView extends BorderPane {\n\n    @Inject\n    private NavigationView navigationView;\n\n    @Inject\n    private StateView carStateView;\n    // view      : example.view.StateView.java\n    // controller: example.view.StateController.java\n    // fxml      : example/view/StateView.fxml\n    // stylesheet: example/view/StateView.css\n\n    @PostConstruct\n    private void init() {\n        setCenter(navigationView);\n        setLeft(carStateView.getRoot());\n    }\n\n}\n```  \n\n#### _Loading FXML directly_\n\nFXML can be loaded using `FXMLLoader` bean. Controller class will also become injectable in this case.\n\n```java\n\n@Singleton\nclass SimpleLoad {\n\n    @Inject\n    FXMLLoader loader; // Note that the loader can only be used once.\n    \n    @PostConstruct\n    private void init() {\n       Node root = loader.load( SimpleLoad.class.getResourceAsStream(\"view.fxml\"));\n    }\n\n}\n``` \n\n\n### How to use Gluon Ignite\n\nTo use Gluon Ignite in your software, simply include it as a dependency in your preferred dependency manager. \nAll artifacts are available in Maven Central:\n\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-dagger.svg?label=ignite-dagger)](https://search.maven.org/artifact/com.gluonhq/ignite-dagger)\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-guice.svg?label=ignite-guice)](https://search.maven.org/artifact/com.gluonhq/ignite-guice)\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-spring.svg?label=ignite-spring)](https://search.maven.org/artifact/com.gluonhq/ignite-spring)\n[![xxx](https://img.shields.io/maven-central/v/com.gluonhq/ignite-micronaut.svg?label=ignite-micronaut)](https://search.maven.org/artifact/com.gluonhq/ignite-micronaut)\n\n\u003e Note that `ignite-common` is automatically included as a dependency for each module, \nso it is not necessary to include this as a dependency.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgluonhq%2Fignite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgluonhq%2Fignite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgluonhq%2Fignite/lists"}