Unzipping a jar file programmatically

In this post, I will explain how to unzip a jar file. Below is the complete code to unzipping a jar file programmatically Main code 1 package jar; 2 3 import java.io.File; 4 import java.io.FileOutputStream; 5 import java.io.IOException; 6 import java.io.InputStream; 7 import java.util.Enumeration; 8 import java.util.jar.JarEntry; 9 import java.util.jar.JarFile; 10 11 public class JarDemo2…… Continue reading Unzipping a jar file programmatically

Function functional interface

In this post, with an example I will show how to use Function functional interface. Function interface is a functional interface that takes an input and produces an output. This is achieved by its “apply” method. Below is an example Main Code 1 package function; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 import java.util.function.Function;…… Continue reading Function functional interface

Validating JobParameters using JobParametersValidator interface

In this post under Spring Batch, I will explain how to validate the parameters passed to the job instance. The interface we will be using for validating the Job parameters is org.springframework.batch.core.JobParametersValidator which has only one method as shown below public interface JobParametersValidator { void validate(JobParameters parameters) throws JobParametersInvalidException; } Based on the signature of…… Continue reading Validating JobParameters using JobParametersValidator interface

Passing Job Parameters using JobParametersBuilder

Passing Job Parameters In this post under Spring Batch I will explain how to pass parameters to a job. We will take the help of org.springframework.batch.core.JobParametersBuilder class which follows Builder design pattern. We will use JobParametersBuilder class to build the job parameters. Then we pass the job parameters along with the job (to be executed)…… Continue reading Passing Job Parameters using JobParametersBuilder

Adding Job Listener using JobListener Interface

In this post of Quartz, I will explain how to add listeners to listen for job events. We can use the listeners to listen for job events and add custom logic at these points. We need to create a class that implements org.quartz.JobListener interface or extends org.quartz.listeners.JobListenerSupport class and override interested events. For our example…… Continue reading Adding Job Listener using JobListener Interface

Adding Trigger Listener using TriggerListener

In this post of Quartz, I will explain how to add listeners to listen for trigger events. We can use the listeners to listen for trigger events and add custom logic at these points. We need to create a class that implements org.quartz.TriggerListener interface or extends org.quartz.listeners.TriggerListenerSupport class and override interested events. For our example…… Continue reading Adding Trigger Listener using TriggerListener

Chaining multiple ItemProcessor

In this post of Spring Batch, I will explain with an example how to chain multiple ItemProcessors. For my example, I will create an ItemProcessor which will go through employee records one item at a time and filter out odd records. Below is the code of the ItemProcessor package package12; import org.springframework.batch.item.ItemProcessor; public class EmployeeFilterItemProcessor…… Continue reading Chaining multiple ItemProcessor

ItemReadListener, ItemWriteListener, and ItemProcessListener Example

In this post under Spring Batch, I will explain how to create listeners during 1) reading of an item 2) writing of an items 3) processing of an item with an example. We create listeners by implementing the three interfaces ItemReadListener, ItemWriteListener, and ItemProcessListener. The class that implements ItemReadListener<T> interface must provide implementation for the…… Continue reading ItemReadListener, ItemWriteListener, and ItemProcessListener Example