{"id":27171252,"url":"https://github.com/dykstrom/spring-and-bsaf","last_synced_at":"2025-04-09T08:32:24.074Z","repository":{"id":81342098,"uuid":"93891114","full_name":"dykstrom/spring-and-bsaf","owner":"dykstrom","description":"Spring and BSAF working together","archived":false,"fork":false,"pushed_at":"2024-01-13T14:16:23.000Z","size":213,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-01-13T23:54:27.151Z","etag":null,"topics":["java","spring","swing"],"latest_commit_sha":null,"homepage":null,"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/dykstrom.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-06-09T19:36:14.000Z","updated_at":"2023-03-02T08:41:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b99e6bc-e496-40f1-8285-8da46ef23c62","html_url":"https://github.com/dykstrom/spring-and-bsaf","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fspring-and-bsaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fspring-and-bsaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fspring-and-bsaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dykstrom%2Fspring-and-bsaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dykstrom","download_url":"https://codeload.github.com/dykstrom/spring-and-bsaf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248003021,"owners_count":21031715,"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":["java","spring","swing"],"created_at":"2025-04-09T08:31:12.379Z","updated_at":"2025-04-09T08:32:24.068Z","avatar_url":"https://github.com/dykstrom.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spring-and-bsaf\n\nThis small application demonstrates how to make the \n[Spring Framework](https://spring.io/projects/spring-framework) and the\n[Better Swing Application Framework (BSAF)](https://sourceforge.net/projects/bsaf)\nwork together. We leave the question of _why_ you would like to do that\nto another time. ;-)\n\nThe problem with combining the two frameworks is that they both want to create\nthe singleton instance of the main application class. BSAF requires you to\ncreate and run your Application subclass by calling the static _launch_ method. \nSpring of course wants to create all managed beans as part of the application\ncontext.\n\nThe solution is to introduce a @Configuration class with a method that creates \na Spring bean from the BSAF application instance. In the Application subclass,\nyou let BSAF create the application:\n\n```java\npublic static void main(String[] args) {\n    // Create the singleton application instance using BSAF here\n    launch(BsafApplication.class, args);\n}\n```\n    \nIn the @Configuration class, you create a bean that just returns the singleton\ninstance:\n\n```java\n@Bean\npublic BsafApplication application() {\n    // Return the singleton application instance as a Spring bean here\n    return (BsafApplication) Application.getInstance();\n}\n```\n\nThis enables the application instance to be injected into other classes, even \nthough it was created before the application context was loaded. You just have \nto be careful to not access the application bean before the application instance\nhas been created by calling _launch_. Otherwise, BSAF will create a dummy instance\nthat is not compatible with your real Application subclass.\n\nFor a Kotlin version of this project, please see\n[spring-and-bsaf-kotlin](https://github.com/dykstrom/spring-and-bsaf-kotlin).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdykstrom%2Fspring-and-bsaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdykstrom%2Fspring-and-bsaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdykstrom%2Fspring-and-bsaf/lists"}