We have seen a basic DI implementation, now it is time to understand how injection works in Guice. Let's rewrite the example of a notification system using Guice, and along with that, we will see several indispensable interfaces and classes in Guice. We have a base interface called NotificationService, which is expecting a message and recipient details as arguments:
public interface NotificationService { boolean sendNotification(String message, String recipient);}
The SMSService concrete class is an implementation of the NotificationService interface. Here, we will apply the @Singleton annotation to the implementation class. When you consider that service objects will be made through injector classes, this annotation ...