{"id":26062078,"url":"https://github.com/thorbenkuck/wiredi","last_synced_at":"2025-04-11T10:58:22.002Z","repository":{"id":48556400,"uuid":"191626196","full_name":"ThorbenKuck/WireDI","owner":"ThorbenKuck","description":"WireDI is a IOC-Framework, that bridges compile time and runtime dependency injection","archived":false,"fork":false,"pushed_at":"2025-03-09T09:40:05.000Z","size":1011,"stargazers_count":5,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T07:22:23.102Z","etag":null,"topics":["aspects","dependency-injection","inversion-of-control","ioc-container","ioc-framework"],"latest_commit_sha":null,"homepage":"https://docs.thorbenkuck.de/wiredi","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThorbenKuck.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-12T18:41:42.000Z","updated_at":"2025-03-09T09:40:08.000Z","dependencies_parsed_at":"2023-11-08T04:01:56.372Z","dependency_job_id":"cff73565-609e-410c-97bf-78e49542f20e","html_url":"https://github.com/ThorbenKuck/WireDI","commit_stats":null,"previous_names":["thorbenkuck/simpledi"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorbenKuck%2FWireDI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorbenKuck%2FWireDI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorbenKuck%2FWireDI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThorbenKuck%2FWireDI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThorbenKuck","download_url":"https://codeload.github.com/ThorbenKuck/WireDI/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248381678,"owners_count":21094524,"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":["aspects","dependency-injection","inversion-of-control","ioc-container","ioc-framework"],"created_at":"2025-03-08T15:49:34.116Z","updated_at":"2025-04-11T10:58:21.981Z","avatar_url":"https://github.com/ThorbenKuck.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WireDI\n\n[![Java CI with Maven](https://github.com/ThorbenKuck/WireDI/actions/workflows/maven.yml/badge.svg)](https://github.com/ThorbenKuck/WireDI/actions/workflows/maven.yml)\n\n![header](.img/header.png)\n\n## Links:\n\n- [Documentation](https://docs.thorbenkuck.de/wiredi)\n- [Maven-Central](https://repo1.maven.org/maven2/com/github/thorbenkuck/wire-di-bootstrap/)\n\nThis project started out as a proof of concept (originally named SimpleDI), to show that dependency injection (or more precisely IOC) could be done at compile time, while keeping the feature set from reflections.\nThis POC grew up to become WireDI, a compile time oriented framework, that still allows for runtime interactions.\n\nIt is full of all the features that you might know from existing IOC frameworks, but integrates the best of runtime\nreflection based operations into compile time, reducing the startup overhead.\nIt does this and still allows for runtime adjustments.\n\nBut let's start at the important questions:\n\n## What does this framework do exactly?\n\nIn its core, this framework is an IOC container.\nYou add one annotation to a class you want to be wired by this framework (namely `@Wire`) like this:\n\n```java\n@Wire\nclass YourClass {\n    // Fields, methods, constructors etc.\n}\n```\n\nand then you can extract the class with all wired classes like this:\n\n```java\nWireRepository wireRepository = WireRepository.open();\nMyClass instance = wireRepository.get(MyClass.class);\n```\n\nAll classes that you want to connect in this fashion have to be annotated with @Wire.\n\n### Yeah, I have seen this before... So, how does this framework differ from other frameworks?\n\nInstead of retrieving annotated classes, constructing AST and proxies at startup, WireDI pre-compiles this information\nat compile time.\nMultiple annotation processors pick up different annotations and create certain other instances of suppliers.\n\nThis means, that as you call `WireRepository.open()`, all proxies already exist, all dependency requirements are analyzed and all qualifiers are correctly set.\n\nThough precompiled, the data are not static.\nYou can modify, change, remove or even manipulate the process.\nIn total, it pre-analyzes the AST, but does not generate static IOC.\n\n### Ah, so it is one of those frameworks...\n\nYes and no.\nIt does a lot of work at compile time, but as a state, not completely.\nInstead, it extracts the reflection heavy operations and does them at compile time.\nAfter compile time, it neatly snuggles into a more traditional framework.\nYou can add custom instances, custom Aspects and other relevant information all at runtime.\n\nIt is not recommended, but you can certainly use it to do everything at runtime.\nAnd the combination of compile time and run time support allows us to enter a whole new dimension.\nWe can integrate other IOC frameworks into this once with relative ease.\nAlready existing frameworks, can benefit from the power of annotation processors and the already existing ecosystem of\nruntime DI and IOC.\n\nWe can go even as far as declaring aspects at runtime, even though the proxies are build at compile time.\nBut let us start from the beginning:\n\n## Quick Start\n\nTo use WireDi, you need two things: The `runtime environment` and the `processors`.\n\n#### 1) Runtime Environment\n\nAdd the runtime environment like this:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.wiredi\u003c/groupId\u003e\n    \u003cartifactId\u003eruntime-environment\u003c/artifactId\u003e\n    \u003cversion\u003e${revision}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nThis dependency will introduce the requirements to use the IOC container `WireRepository`, like this:\n\n```java\nimport com.wiredi.runtime.WireRepository;\n\npublic class Example {\n    public static void main(String[] args) {\n        WireRepository iocContainer = WireRepository.open();\n    }\n}\n```\n\nAdditionally, to make classes available to the IOC container,\nthis dependency also introduces the `@Wire` annotation, that you use like this:\n\n```java\nimport com.wiredi.annotations.Wire;\n\n@Wire\npublic class MyDependency {\n    // Members\n}\n```\n\n#### 2) Processors\n\nThe runtime environment itself will allow you to use the IOC container.\nTo fill it, you will additionally need the processors.\nThey need to be accessible to the compiler; There is no need to hold them in the class path for the runtime.\n\nYou can include them using the maven-compiler-plugin:\n\n```xml\n\u003cplugin\u003e\n    \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n    \u003cartifactId\u003emaven-compiler-plugin\u003c/artifactId\u003e\n    \u003cversion\u003e3.8.1\u003c/version\u003e\n    \u003cconfiguration\u003e\n        \u003cparameters\u003etrue\u003c/parameters\u003e\n        \u003cannotationProcessorPaths\u003e\n            \u003cannotationProcessorPath\u003e\n                \u003cgroupId\u003ecom.wiredi\u003c/groupId\u003e\n                \u003cartifactId\u003eprocessors\u003c/artifactId\u003e\n                \u003cversion\u003e${wiredi.version}\u003c/version\u003e\n            \u003c/annotationProcessorPath\u003e\n        \u003c/annotationProcessorPaths\u003e\n    \u003c/configuration\u003e\n\u003c/plugin\u003e\n```\n\nYou require hooking up one annotation processor and the api, as well as the core api.\nYou can do that simply, by adding this parent to your pom.xml\n\n```xml\n\u003cparent\u003e\n    \u003cgroupId\u003ecom.wiredi\u003c/groupId\u003e\n    \u003cartifactId\u003ebootstrap\u003c/artifactId\u003e\n    \u003cversion\u003e${revision}\u003c/version\u003e\n    \u003crelativePath/\u003e \u003c!-- Always look up parent from repository --\u003e\n\u003c/parent\u003e\n```\n\nThis parent introduces the wire-di annotation processor and wire-di-runtime-environment, which allows you at run time\nto utilize the data generated at compile time.\n\nFor other forms of introducing this library to your application, see the [usage section of the documentation](https://docs.thorbenkuck.de/wiredi/#/usage/).\n\n## Basic usage\n\nThe central annotation to mark classes as \"I want to be able to be handled for di\" is called `Wire`.\nThis annotation marks a class as \"Injection enabled,\" allowing the framework to inject it into other classes and other\nclasses into it.\n\nA basic example would look like this:\n\n```java\n@Wire\nclass A {\n    private final B b;\n    \n    public A(B b) {\n        this.b = b;\n    }\n}\n\n@Wire\nclass B {}\n\npublic class Main {\n    public static void main(String[] args)  {\n        WireRepository wireRepository = WireRepository.open();\n        A a = wireRepository.get(A.class);\n        // Do fancy stuff\n    }\n}\n```\n\nIn this example right here, we have two classes, A and B and A has a dependency to B.\nSince both classes are marked with`@Wire`, the annotation processor generated providers for these classes and makes them available through the ServiceLoader.\nThey then are automatically picked up by the WireRepository when \"load\" is called, which is done automatically when you create a WireRepository using \"open.\"\n\nAs you run this code, a lot happens behind the curtains.\nThe annotation processor generates instance of `IdentifiableProvider` classes, which you can even see in the compiled sources.\nThese providers hold a sum of static information about this class, that are then used at runtime;\nIncluding the template as to how this class is created.\n\n## Examples\n\nIf you'd like to see a few examples on how to use WireDI, have a look at the [examples](examples).\nThis project contains concrete examples for WireDI.\n\n## Properties\n\nOrder of Properties:\n\n- default properties (application.properties)\n- additional properties (key=load.additional-properties)\n- profile properties (application-\u003cprofile\u003e.properties)\n- OS Environment Variables\n- System Properties\n\n# Project Structure\n\nThe project is mainly split into two modules: [runtime](runtime) and [compile time](compile-time).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthorbenkuck%2Fwiredi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthorbenkuck%2Fwiredi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthorbenkuck%2Fwiredi/lists"}