Autowire Spring Beans using XML Configuration

Let’s look at the examples to Autowire the Spring beans by constructor, by type and by their names using Spring XML configuration. Class Structure Product – a POJO class to store product info ProductDAO – an interface that we will use in a dependent service class ProductDAOImpl – an implementation of ProductDAO returns list of … Read more

Annotation Based Spring Config and Auto Wiring

In this example, I’ll show how to do an Annotation Based Spring configuration to define beans and auto wire them together. Use Case The Use Case we are going to work on is to fetch list of employees from a service. The service inturn fetch it from data access object. Creating a Maven Project First … Read more

Spring XML Configuration and Setter Injection

In this example, we will inject the dependencies of a class using setter injection. For setter injection, if class A refers to another class called as B, then A should expose a setter method with B as its argument. Use Case The use case that we implement is like the one we did using constructor … Read more

Spring XML Configuration and Constructor Injection

This is an example to show you how we can inject dependencies using constructor injection within Spring XML configuration. Use Case Our use case is simple, we want to establish the dependencies between app, service and data access layers. We want to retrieve list of users from database (mocked in our case) using a data … Read more

Selection Sort

Overview Selection sort is the most basic way of sorting an Array. We compare each element with its subsequent elements and swap them if one is smaller than the other. Complexity The complexity of selection sort algorithm for worst case, average cases and best cases is O(n2). Selection Sort in Java Selection Sort in C … Read more