Reputation: 273502
I am looking for a very lightweight dependency injection framework for java. With minimum possible dependencies and minimum features.
Just something along the following lines: receive a java.util.List
of Class
es, instantiate them and just auto-wire all the objects one into the other.
Upvotes: 3
Views: 3101
Reputation: 50237
I would recommend Spring, since this can provide a small footprint when using only the core packages.
If you think Spring is overkill, then perhaps PicoContainer, or guice?
Upvotes: 10
Reputation: 323
Take a look at ActiveJ Inject.
It is a lightweight dependency injection library. It is optimized for performance and has no third-party dependencies.
It is much faster than Spring DI or Guice and it is much lighter. Check the benchmarks here
Upvotes: 0
Reputation: 2316
Take a look at dagger2, developped at google (forked of square's dagger1), for only 17kb jar.
dagger2 documentation dagger2 github dagger2 examples
Upvotes: 2
Reputation: 111
Silk DI is about 120K
single jar file with no further runtime dependencies. It has a fluent binder interface like guice but is more flexible and allows to remove features you don't like. E.g. Collection
or List
injection can be added in a one liner.
Upvotes: 3
Reputation: 6227
I have been trying MentaContainer for less than a week now and I am satisfied by its clean and straightforward API. Instead of using XML or Annotations for the setup it uses a fluent API almost like a DSL which for me felt like like heaven because I am using it to build a small web container with IoC support. It provides a THREAD scope for the components which fits perfectly for the REQUEST scope of the web container. It is very lightweight so it may be what you need.
Upvotes: 2
Reputation:
Definitely look into Guice. Been using it for a year, and absolutely love it.
Upvotes: 0
Reputation: 91
Maybe you should have a look at Google Guice: http://code.google.com/p/google-guice/
Upvotes: 9