3

Is there any small DI framework out here that implements the javax.inject package (bar the @Scope annotation: @Singleton is enough) and provides only a container around it to get instances from? This framework will be embedded with my framework in other small applications, so I can't affort to have much features, or size. More features means more support from me which I don't want either. Even a "go see the documentation" is too much support for this project.

Features required:

  • implements javax.inject
  • constructor injection

Optional features:

  • less reflection as possible, including proxy

What did I do already?

I know the following ones, but most provide way too much stuff with them and therefore a clog of APIs that I don't want/need.

  • Dagger: current first choice for this project. Remove the modules and that's what I'm looking for (yes, that means no interface). A size of 58kb is excellent compared to other frameworks. The compile-time injection is the cherry on the cake.
  • Guice: always my first choice when it comes to DI, but it's too big for this project, especially in terms of API.
  • Spring: I said small...
  • HK2: don't know enough to properly judge, but it looks like it has most of Guice's features.
  • Pico-container: isn't really "pico" anymore, at least in terms of API.
  • 1
    What about the CDI reference implementation, Weld? – Basil Bourque Sep 8 '16 at 5:55
  • I never used it outside of an application server, but the fact that it has so many options make it clear it's not a real contender in my search. This can be seen here: docs.jboss.org/cdi/api/1.2 – Olivier Grégoire Sep 8 '16 at 7:53
  • Try hk2 (hk2.java.net). It is not as small as it used to be but it is still relatively small compared to many others – jwells131313 Sep 8 '16 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.