A tiny drop-in replacement for guice 2.0
Current Version 0.1.0
Guice is a dependency injection framework. Such frameworks can help decouple code but some, e.g. guice, add a dependency on themself.
Creating a library that works nice with an without guice is hard. You want to use Guice annotations and the Provider interface. The user of the library is forced to add
650 KB of Guice.jar even if he choosed not to use it.
A obvious choice is to create a small lib with just the annotations and the Provider interface.
But while you're at it why not go all the way, reimplemet part of Guice but in a smaller package.
Osashosa is only 24k.
How to use?
Follow the docimentation for Guice: Guice Docu
Compared to Guice
osashosa implements, appart from the annotations and Provider interface, the module and injector logic of guice.
You get not only clean compiles but also the functionalty of guice, well most of it.
The biggest requirement is: Constructor injection only.
Otherwise all should work:
- typesave bindng with typeliterals
- overrides of Modules
- name annotations
The biggest runtime change is no AOP and lazy loading. All objects are eager loaded.
|Provider interface and logic||+||+|
Osashosa is "Orangen Saft Schorle Sauer". A Schorle is a mix of Juice and Water. Osashosa is watered Guice.
And last but not least osashosa is an abbreviation created by my wife years ago.
When to Use it?
When you want to create library and use the Guice DI style but don't want to require people to include Guice.
With Osashosa you can create a library that optionally uses DI. You can write the code so that osashosa or Guice is required to be on the classpath but not used at all.
Osashosa is just smaller in that case.