{"id":23516318,"url":"https://github.com/suppierk/inject","last_synced_at":"2025-10-31T14:30:38.710Z","repository":{"id":269175578,"uuid":"906642399","full_name":"SuppieRK/inject","owner":"SuppieRK","description":"Java JSR 330 dependency injection library","archived":false,"fork":false,"pushed_at":"2025-02-02T05:59:37.000Z","size":171,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-16T22:33:14.084Z","etag":null,"topics":["dependency-injection","java","java-11","jsr330","library","minimalistic"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SuppieRK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-21T13:36:16.000Z","updated_at":"2025-02-02T05:56:49.000Z","dependencies_parsed_at":"2024-12-21T14:32:39.674Z","dependency_job_id":"cfe4b8ee-c62e-4893-a79e-b3fb0dc47588","html_url":"https://github.com/SuppieRK/inject","commit_stats":null,"previous_names":["suppierk/inject"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuppieRK%2Finject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuppieRK%2Finject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuppieRK%2Finject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SuppieRK%2Finject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SuppieRK","download_url":"https://codeload.github.com/SuppieRK/inject/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239207442,"owners_count":19599963,"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","java","java-11","jsr330","library","minimalistic"],"created_at":"2024-12-25T15:12:39.247Z","updated_at":"2025-10-31T14:30:38.652Z","avatar_url":"https://github.com/SuppieRK.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Inject\n\n\u003e The work on this software project is in no way associated with my employer nor with the role I'm having at my\n\u003e employer.\n\u003e\n\u003e I maintain this project alone and as much or as little as my **spare time** permits using my **personal** equipment.\n\nSmall [dependency injection](https://en.wikipedia.org/wiki/Dependency_injection) library for Java supporting\nreflection-based objects creation (aka a [factory pattern](https://en.wikipedia.org/wiki/Factory_method_pattern)) using\nslightly extended [JSR 330](https://jcp.org/en/jsr/detail?id=330) specification provided\nby [Jakarta Inject library](https://mvnrepository.com/artifact/jakarta.inject/jakarta.inject-api).\n\nThe main goal of this library is to provide the most obvious path to register and reuse dependencies in your code, which\nwas inspired by other libraries such as:\n\n- [Feather](https://github.com/zsoltherpai/feather) - with some features absent here, namely injection into the current\n  class for testing.\n- [Dagger 2](https://github.com/google/dagger) - the concept of `@Provides` is useful, code generation not so much.\n- [Guice](https://github.com/google/guice) - without the bloat of additional annotations you might never use or support\n  for Jakarta's `servlet,persistence`.\n\nIn addition to JSR 330 annotations, this library adds its own `@Provides` annotation to mark methods which produce\ndependencies for other classes - something that is missing from the specification to let users denote which specific\nmethods outputs should be exposed to other classes.\n\n## [How to add?](https://mvnrepository.com/artifact/io.github.suppierk/inject)\n\n- **Maven**\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.suppierk\u003c/groupId\u003e\n    \u003cartifactId\u003einject\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n- **Gradle** (_works for both Groovy and Kotlin_)\n\n```groovy\nimplementation(\"io.github.suppierk:inject:2.0.1\")\n```\n\n[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-orange.svg)](https://sonarcloud.io/summary/overall?id=SuppieRK_inject)\n\n## Hello, World!\n\n```java\nimport jakarta.inject.Inject;\nimport io.github.suppierk.inject.Provides;\nimport io.github.suppierk.inject.Injector;\n\npublic class HelloWorld {\n    static class Provider {\n        @Provides\n        String helloWorld() {\n            return \"Hello, World!\";\n        }\n    }\n\n    static class Consumer implements Runnable {\n        private final String helloWorld;\n\n        @Inject\n        public Consumer(String helloWorld) {\n            this.helloWorld = helloWorld;\n        }\n\n        @Override\n        public void run() {\n            System.out.println(helloWorld);\n        }\n    }\n\n    public static void main(String[] args) {\n        final Injector injector = Injector.injector()\n                .add(Provider.class, Consumer.class)\n                .build();\n\n        injector.get(Consumer.class).run();\n    }\n}\n```\n\n## Known problems\n\n- Do not invoke `Provider.get()` or `Supplier.get()` in the constructor of the object which is a part of the dependency\n  cycle - this will result in an infinite instantiation loop and will cause your program to become stuck.\n\n## More examples\n\n- Visit our [Wiki](https://github.com/SuppieRK/inject/wiki) for more in-depth look at the features.\n- Take a look at the complete stack proposal in [JIQS](https://github.com/SuppieRK/jiqs) repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuppierk%2Finject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuppierk%2Finject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuppierk%2Finject/lists"}