JayWire Dependency Injection

Overview

Build Status Published Version Join the chat at https://gitter.im/vanillasource/jaywire

JayWire Dependency Injection

A very small and lightweight dependency injection framework for Java 8 without magic. Main features are:

  • 100% pure Java code (no XML, no config files)
  • Explicit, compile-time wireing
  • Typesafe
  • Modular and extendable
  • Small and easy

JayWire avoids any magic, that means:

  • No classpath scanning
  • No reflection
  • No annotations
  • No bytecode enhancement / weaving
  • No transparent proxies
  • No code generation
  • No hidden / static state

Getting the library

Add this dependency to your Maven build:

<dependency>
   <groupId>com.vanillasource.jaywire</groupId>
   <artifactId>jaywire</artifactId>
   <version>1.1.0</version>
</dependency>

This will include the basic interfaces and scopes for standalone usage. For integration with Web-frameworks see Wiki.

Wireing everything together

For a simple application a single "Module" object wireing everything together is written this way:

import com.vanillasource.jaywire.standalone.StandaloneModule;

public class MyAppModule extends StandaloneModule {
   public Database getDatabase() {
      return singleton(() -> new MyAppDatabase(...));
   }

   public ServiceA getServiceA() {
      return singleton(() -> new ServiceA(getDatabase()));
   }

   public ServiceB getServiceB() {
      return singleton(() -> new ServiceB(getDatabase(), getServiceA());
   }
}

In this example there is a Database, ServiceA and ServiceB, all of them singletons. It is assumed that these services / classes are written in the usual Object-Oriented approach by taking all required dependencies as constructor parameters. These dependencies are then "injected" by simply calling the appropriate methods to get fully constructed dependencies and supplying them as parameters to objects.

You can use the MyAppModule then at the "top" of your application to start processing:

public class MyApp {
   public static final void main(String[] argv) {
      MyAppModule module = new MyAppModule();
      module.getServiceB().run();
   }
}

Documentation

The JayWire API Documentation.

Please visit the JayWire Wiki for more information.

Related external projects

  • Pouch is an interesting rethinking of the Service Locator pattern.
You might also like...

A free injection hacked client for Minecraft using Java-agents

Swift Swift is a free and open-source injection hacked client base for Minecraft using Java-agents. Issues If you notice any bugs, you can let us know

Oct 8, 2022

A free mixin-based injection hacked-client for Minecraft using Minecraft Forge.

Custom LiquidBounce 1.8.9 build that aims to improve original visuals and bypasses, along with built-in ViaVersion to help you change from 1.8 to 1.17.1 without creating any other version branch.

Jan 2, 2023

A free mixin-based injection hacked client for Minecraft 1.8.9

LiquidCat is a free and open source mixin-based injection hacked client using Forge for Minecraft 1.8.9

Nov 18, 2022

A injection client for Minecraft 1.8.9forge,forked and optimize on VapuLite

A injection client for Minecraft 1.8.9forge,forked and optimize on VapuLite

May 8, 2022

A 1.12.2 forge injection based hacked client for anarchy servers

nebula another failed abortion of inferno and the aftermath of gavin at coding also is an anarchy utility client, i think thats important to point out

Dec 24, 2022

A lightweight, mixin like injection lib using ASM

ClassTransform A lightweight, mixin like injection lib using ASM. The usage is like Mixins. You can almost copy-paste mixins code and it works. Why? I

Dec 22, 2022

A fast dependency injector for Android and Java.

Dagger A fast dependency injector for Java and Android. Dagger is a compile-time framework for dependency injection. It uses no reflection or runtime

Dec 30, 2022

This open source project allows you to easily integrate Camunda's External Task Clients into Micronaut projects: simply add a dependency in your Micronaut project

micronaut-camunda-external-client This open source project allows you to easily integrate Camunda 's External Task Clients into Micronaut projects. Mi

Dec 18, 2022

Sauron, the all seeing eye! It is a service to generate automated reports and track migrations, changes and dependency versions for backend services also report on known CVE and security issues.

Sauron, the all seeing eye! It is a service to generate automated reports and track migrations, changes and dependency versions for backend services also report on known CVE and security issues.

SAURON - VERSION AND DEPLOYMENT TRACKER DESCRIPTION Sauron, the all seeing eye! It is a service to generate automated reports and track migrations, ch

Oct 31, 2022

Zero-dependency Reactive Streams publishers library

⚡️ Mutiny Zero: a zero-dependency Reactive Streams publishers library for Java Mutiny Zero is a minimal API for creating reactive-streams compliant pu

Dec 14, 2022

PotPvP 1.8 with CarbonSpigot as its dependency

PotPvP Reprised A fork of PotPvP, porting it to 1.8 and changing mSpigot's dependency to CarbonSpigot. Information This fork has also changed all APIs

Nov 30, 2022

Zero-Dependency RFC 8252 OAuth 2.0 Authorization Flow

Tiny OAuth2 Client This is a minimal zero-dependency implementation of the RFC 8252 OAuth 2.0 for Native Apps, relying on Loopback Interface Redirecti

Jun 17, 2022
Comments
  • Related project

    Related project

    I'm happy to run across a like-minded individual.

    I added a link from https://bitbucket.org/cowwoc/pouch/ to your project. Feel free to link back to my project if you see fit.

    opened by cowwoc 1
  • Add a Gitter chat badge to README.md

    Add a Gitter chat badge to README.md

    vanillasource/jaywire now has a Chat Room on Gitter

    @robertbraeutigam has just created a chat room. You can visit it here: https://gitter.im/vanillasource/jaywire.

    This pull-request adds this badge to your README.md:

    Gitter

    If my aim is a little off, please let me know.

    Happy chatting.

    PS: Click here if you would prefer not to receive automatic pull-requests from Gitter in future.

    opened by gitter-badger 0
  • Bump wicket-core from 6.18.0 to 7.17.0 in /jaywire-wicket

    Bump wicket-core from 6.18.0 to 7.17.0 in /jaywire-wicket

    Bumps wicket-core from 6.18.0 to 7.17.0.

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Owner
VanillaSource
VanillaSource
Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 6 and above, brought to you by Google.

Guice Latest release: 5.0.1 Documentation: User Guide, 5.0.1 javadocs, Latest javadocs Continuous Integration: Mailing Lists: User Mailing List Licens

Google 11.7k Dec 29, 2022
Dynamic Context Dependency Injection

Welcome to the Project Dynamic CDI JDK Informations Actual version is running from JDK8 up to JDK13. The version 1.0.x is based on JDK8. The implement

Sven Ruppert 8 Dec 10, 2019
A fast dependency injector for Android and Java.

Dagger A fast dependency injector for Java and Android. Dagger is a compile-time framework for dependency injection. It uses no reflection or runtime

Google 16.9k Dec 30, 2022
Lightweight dependency injection for Java and Android (JSR-330)

About Feather Feather is an ultra-lightweight dependency injection (JSR-330) library for Java and Android. Dependency injection frameworks are often p

Zsolt Herpai 341 Nov 29, 2022
Guice (pronounced 'juice') is a lightweight dependency injection framework for Java 6 and above, brought to you by Google.

Guice Latest release: 5.0.1 Documentation: User Guide, 5.0.1 javadocs, Latest javadocs Continuous Integration: Mailing Lists: User Mailing List Licens

Google 11.7k Dec 29, 2022
Spring Kurulumundan Başlayarak, Spring IOC ve Dependency Injection, Hibernate, Maven ve Spring Boot Konularına Giriş Yapıyoruz.

Spring Tutorial for Beginners File Directory Apache Tomcat Apache Tomcat - Eclipse Bağlantısı Spring Paketlerinin İndirilmesi ve Projeye Entegrasyonu

İbrahim Can Erdoğan 11 Apr 11, 2022
Dynamic Context Dependency Injection

Welcome to the Project Dynamic CDI JDK Informations Actual version is running from JDK8 up to JDK13. The version 1.0.x is based on JDK8. The implement

Sven Ruppert 8 Dec 10, 2019
A light-weight and dynamic dependency injection framework

⚠️ This project is now part of the EE4J initiative. This repository has been archived as all activities are now happening in the corresponding Eclipse

Java EE 105 Dec 23, 2022
JavaFX micro-framework that follows MVVM Pattern with Google Guice dependency Injection

ReactiveDeskFX (JavaFX and Google Guice MVVM Pattern micro-framework) JavaFX micro-framework to develop very fast JavaFX components with minimal code

TangoraBox 3 Jan 9, 2022
Yet another Java annotation-based command parsing library, with Dependency Injection inspired by Guice

Commander A universal java command parsing library Building This project uses Gradle. Clone this repository: git clone https://github.com/OctoPvP/Comm

OctoDev 4 Oct 2, 2022