Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing com.google.inject with javax.inject

Is it true that javax.inject annotations can function as direct replacements for com.google.inject?

So that, if I replaced all my current guice/gin annotations with those from javax.inject, my app would compile and run just fine?

First, does javax.inject cover all the bases that google.inject cover?

like image 960
Blessed Geek Avatar asked Oct 20 '11 13:10

Blessed Geek


People also ask

What is javax inject inject?

Package javax. inject. This package specifies a means for obtaining objects in such a way as to maximize reusability, testability and maintainability compared to traditional approaches such as constructors, factories, and service locators (e.g., JNDI).

Does Google use Guice?

Use of Google Guice for implementing dependency injection in application is very easy and it does it beautifully. It's used in Google APIs so we can assume that it's highly tested and reliable code.

What is Guice injector?

Interface Injector. public interface Injector. Builds the graphs of objects that make up your application. The injector tracks the dependencies for each type and uses bindings to inject them. This is the core of Guice, although you rarely interact with it directly.

What is com Google inject?

Package com. google. inject Description. Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework.


1 Answers

Yes, it will work fine. In fact the author of guice (Bob Lee) is a spec-lead for the javax.inject specification.

javax.inject.Inject does not have the optional attribute, so if you want an optional dependency, you'd have to use the guice annotation.

like image 78
Bozho Avatar answered Sep 23 '22 15:09

Bozho