Categories
Spring Spring Core

Java-Based Container Configuration

In our previous Articles we saw XML Based container configuration and Annotation based container configuration in detail. In this Article we are going to look at how Spring applications can be configured using Java classes and few annotations with a simple example.  Two main annotations on Java based container configuration in Spring are @Configuration and […]

Categories
Spring Spring Core

Spring Annotation Based container configuration

In Spring Framework we have three different ways to configure an IoC Container. XML Based Container Configuration Bean configuration will be in the form of XML meta-data. Refer this example for better understanding. Annotation Based Container Configuration Annotations will be used to configure each bean and its properties. Java Based Container Configuration Using Java Based […]

Categories
Spring Spring Core

Stereotype Annotations in Spring and Spring Boot

The @Component, @Controller, @Service and @Repository are the Stereotype annotations of Spring and Spring Boot Instead of providing Bean Definitions in XML Configuration file Spring provides these Stereotype annotations that can be defined in Java class itself.  Spring Automatically detects Stereotyped classes and configured with the ApplicationContext. As per the above diagram, @Controller, @Service and […]

Categories
Spring Spring Core

Spring Qualifier Annotation

Generally Autowired annotation will resolve dependencies based on the Type. If you are having only one Class implementing an interface, then Spring will make use of the Class implementation to resolve dependency. But, in most of the scenarios we have more than one Implementation classes for an Interface. If you use @Autowired in this case, […]

Categories
Spring Spring Core

Collection as Dependency Injection

As like Primitives and User Defined classes we can provide Collections as Dependencies in Spring Framework.  We will look at Collections as Dependencies in Spring with Constructor and Setter Injection in a Simple working example. In the below example I included all the possible Collections with Static and Dynamic values.  Before walkin to the Example […]

Categories
Spring Spring Core

How Dependency Injection works in Spring

We saw What is DI and its different form of Injection in our Previous Post, here we look at how Spring Dependency Injection works in Detail with Diagrammatic Representation. Step 1 : ApplicationContext will be Created and Configured by Reading Configuration Meta-Data.  Step 2 :  ApplicationContext will create all the Beans defined in Configuration Meta-Data. […]

Categories
Spring Spring Core

Instance Factory Method in Spring

The IoC container will invoke a non-static method of an Existing Bean to Instantiate an Object.  In our previous example we saw how Instantiation of Bean using Constructor args and Static-Factory Method with an Example. Now we will look at how Instantiation of Instance Factory Method works in Spring with an Example. Example of Instance […]

Categories
Spring Spring Core

Static Factory Method in Spring

In our previous article we saw how to instantiate a Bean with Constructor in Spring Framework. Now we will look at how we can instantiate a Static Factory Method.  Instantiate a Static Factory Method in Java  In a plain Java application we can instantiate the above Static Factory class as like below from another class […]

Categories
Spring Spring Core

Dependency Injection in Spring

Dependency Injection is a process to change the Binding of Objects from Compile time to Runtime. It focuses on creating loosely coupled objects and to make decoupling easier, Objects define their own dependent Objects and there will not be any tight-coupling between them. IoC container is responsible to create a Dependent objects and Inject where […]

Categories
Spring Spring Core

Instantiating a Bean with Constructor in Spring

Bean is nothing but a normal Java class, when it is configured and managed in a IoC container of Spring it becomes a special type of Object called Bean. Generally we can create a class with default no-args constructor or constructor with an argument, Static factory method with constructor as private access modifier or else […]

Categories
Spring

Introduction to Spring

Spring is an Open-Source framework and it has a wide range of documentation provided to make the learning curve easy. Spring came into existence in 2003 to overcome the heavy weight complexity in J2EE applications. People are thinking of some lightweight methodologies to divide a large application into small pieces and finally wire together. If […]