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

Dependency Injection using @Inject and @Named Annotations

We have many ways to Inject Dependencies in Spring. XML Configuration, @Autowired Annotation, @Resource annotation are few of them. Among these methods we have JSR 330 Standard annotations as well. We can choose any one of these based on our application needs. Key Points : @Inject can be used instead of @Autowired and @Resource annotations […]

Categories
Spring Spring Core

Primitives as Dependency in Spring

In Spring Based application all the Objects are Created and Managed by IoC Container. For any Object we have dependency of another Object or Primitives in general. We are going to see a Detailed explanation of “How Primitives are used as Dependencies in Spring Framework?” in this Article. Constructor-args The above code having all available […]

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
Java

What is IoC and DI in Java

What is Inversion of Control? As the name suggests, IoC is to Invert the control flow of a program. It is an Idea to Decouple/remove dependencies of the object and provide control to another layer(XML, Java Class, Properties,…) to instantiate required Objects. For more understanding on the above definition I’m adding below example code and […]