In all previous Spring Batch posts, the DelimitedLineAggregator(which creates String format of java objects) and DelimitedLineTokenizer (which extracts fields from each record) assume ‘,’ as delimiter as shown below EMP_ID0,EMP_NAME0,EMP_STATUS0,0EMP_ID1,EMP_NAME1,EMP_STATUS1,1EMP_ID2,EMP_NAME2,EMP_STATUS2,2EMP_ID3,EMP_NAME3,EMP_STATUS3,3 We can use other symbols as delimiter and inform DelimitedLineAggregator and DelimitedLineTokenizer about this. At the time of reading and writing, the default delimiter is…… Continue reading Using custom delimiter while reading and writing batch file
Saving a transient object
In this post of Hibernate ORM, I will explain how to save a transient object with an example. A transient object exists only in memory, no representation of it exists in database. Hibernate runtime doesn’t manage (ie., automatically update or sync up with database representation) the transient object. The object’s identifier property value will be…… Continue reading Saving a transient object
eq(), first() and last() JQuery functions
In this post of JQuery, I will explain the three functions eq(), first(), and last() functions with a example. Below is the complete code for reference 1 <html> 2 <head> 3 <a href=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”>https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js</a> 4 </head> 5 <body> 6 7 function selectElement() { 8 var $elements = $(‘a’); 9 10 var $indexedElement = $elements.eq(0); 11 alert($indexedElement.length);…… Continue reading eq(), first() and last() JQuery functions
Selecting elements by their attributes
In this post of JQuery, I will show how to select elements using their attributes. Below is the complete html code that will be used as an example 1 <html> 2 <head> 3 <a href=”https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js”>https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js</a> 4 </head> 5 <body> 6 7 function selectElement() { 8 var $element = $(‘a[href]’); 9 $(‘#input1’).val($element.length); 10 11 $element =…… Continue reading Selecting elements by their attributes
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
Exploring jar files programmatically
In this post under java, I will show how to browse a jar file programmatically. For the example I will browse the mockito jar file. So I will add the “mockito-core-2.11.0.jar” in the classpath of the java file. Below is the complete code for browsing the jar file programmatically Main Code 1 package jar; 2…… Continue reading Exploring jar files programmatically
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
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) as parameters to…… 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