I will continue with using the AlertService from part 2 of the series, to show how to utilise Dependency Injection in Spring with a more common situation. Let us start with the MessageServices and bring them under control of the BeanFactory in Spring by annotating them as a Component. @Component public class EmailMessageService implements MessageService...
Inversion of Control – Part III – Dependency Injection in Java Spring I
As I explained in the blog post about Inversion of Control, your code can be controlled not only by implementing an IoC Design Pattern within your code, by a framework that controls (part of) your code, but also by an entity, that you don’t have direct control over, such as a Servlet Container that...
Inversion of Control – Part II – Dependency Injection
In the first part, I described what Inversion of Control (IoC) is and how it can be implemented using the classical GoF design patterns. In this post, I will explain another implementation of IoC: Dependency Injection. I assume that you are familiar with programming to an interface (or abstract class) rather than classes, as you...