ProductPromotion
Logo

Java

made by https://0x3d.site

GitHub - vanillasource/jaywire: JayWire Dependency Injection
JayWire Dependency Injection. Contribute to vanillasource/jaywire development by creating an account on GitHub.
Visit Site

GitHub - vanillasource/jaywire: JayWire Dependency Injection

GitHub - vanillasource/jaywire: JayWire Dependency Injection

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.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory