JAVA

Spring Retry in Action

Overview In a project, there might be a use case where you need to re-invoke a failed operation or call a method again on failure. Spring Retry provides declarative retry support for Spring applications. In this blog, we will configure and use Spring Retry logic using Spring Application. Install Dependencies Link for other versions of spring-retry. Please Note: You will also need dependent jars for Spring Retry. Example 1. Enable Spring Retry in SpringBoot Application Read more…

By Ashish, ago
Apache Tomcat

Session Replication in Tomcat

Overview In this blog, we will cover What is Session Replication? How to configure Session replication into multiple Server running in a Cluster. Session Replication When it comes to the high availability of Application, we generally run our server as a Cluster of multiple servers running using Load Balancer. But what if I am logged in to one of the servers and the server goes down for some reason. We do have other servers in a Read more…

By Ashish, ago
Nginx

Configure Load Balancing with Nginx

Overview In this post, we will cover the following points What is Nginx? Install Nginx Configuring Nginx as a load balancer What is Nginx? NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. Install Nginx Once done start serevr using below command If all goes well, in a browser hit http://localhost You should see something like this Configuring Nginx as a load balancer We are going to add Read more…

By Ashish, ago
JAVA

Read Dynamic Object from JSON using Gson

Overview We have seen in prev post  how to use GSON to convert a JSON to Java Object and other way around In this post, we will see how to convert JSON which has Dynamic Keys. Sample JSON If you notice in above JSON Sample_01 and Sample_20 are dynamic. In this case, we can’t simply define a Java POJO and map it to this JSON. So how do we read this kind of JSON? We will use Read more…

By Ashish, ago
JAVA

Bean Scope in Spring

Overview When defining a <bean> you have the option of declaring scope for that bean In this blog we will cover What are different types of Scope available in Spring.. Example for each scope type Types of Scope Scope Description singleton Scopes a single bean definition to a single object instance per Spring IoC container. prototype Scopes a single bean definition to any number of object instances. request Scopes a single bean definition to the Read more…

By Ashish, ago
JAVA

Dependency Injection in Spring without XML

Overview In previous blog we saw Dependency Injection in Spring using Annotation. Here we will see how we can do same using Annotation but without defining Autoscan in xml. We will make use of @Configuration and @Bean to define configuration same as we did for xml in above case. Configuration Class Car Class Main Class Explanation Annotating a class with the @Configuration indicates that the class can be used by the Spring IoC container as Read more…

By Ashish, ago
JAVA

Dependency Injection in Spring using Annotation

Overview In previous blog we saw Dependency Injection in Spring using XML. Here we will see how we can do same using Annotation Construction Injection using Annotation xml file Paint class Car class Main class Explanation In xml we are telling Spring to look for a package to scan for Annotation based configurations like in this case @Component and @Autowired . @Autowired above Car is way of injecting Bean as a Constructor Setter Injection using Read more…

By Ashish, ago
JAVA

Dependency Injection in Spring using XML

Overview In my previous blog we saw an overview of Spring IoC and DI. Here we will see Dependency Injection (DI) in detail by answering following question: What is DI Ways of injecting Dependency using XML Dependency Injection Dependency Injection (DI) is a design pattern that removes the dependency from the programming code so that it can be easy to manage and test the application. Dependency Injection makes our programming code loosely coupled. Ways of Read more…

By Ashish, ago
JAVA

Inversion of Control and Dependency Injection with Spring – Overview

Overview In this blog we will cover following points What is IoC Spring IoC Container Dependency Injection in Spring Example Code Inversion of Control(IoC) Inversion of Control is a principle in software engineering by which the control of objects or portions of a program is transferred to a container or framework. Inversion of Control can be achieved through various mechanisms such as: Strategy design pattern, Service Locator pattern, Factory pattern, and Dependency Injection (DI). Spring Read more…

By Ashish, ago
JAVA

Spring – An Overview

Overview Spring is a framework for dependency-injection which is a pattern that allows to build very decoupled systems. The Spring Framework is divided into modules. Applications can choose which modules they need. At the heart are the modules of the core container, including a configuration model and a dependency injection mechanism. Official Website Spring Release Spring 1     : 2004 Spring 2     : 2006 Spring 3     : 2009 Spring 4     : 2013 Read more…

By Ashish, ago