Start background thread using spring on startup

In this tutorial we will start a thread on the application startup using spring bean.So we will start the thread using @PostConstruct annotation on the method. So this makes sure that the annotated method is called before the Spring bean is put into service.  And we will be using executor service to start a thread. … Read more

Properly Shutting down an ExecutorService

I was recently working on an application that used hibernate for db access and lucene for storing and searching text. This combination was really great. It made searching really fast. And tomcat was used as the application container.Sometimes I used to get this exception on redeploy: And also tomcat used to complain that it could … Read more

Lucene using spring.

Today we are showing how to instantiate lucene using spring. We will be using annotations for instating the spring bean. Lets jump directly to the example class to see how it is done So the above class is a singleton spring bean. The annotation PostConstruct on the method init make sure that lucene IndexWriter is started on the startup. … Read more

Scrum in 2 minutes

What is scrum? Scrum is an agile methodology that tries to overcome the issues with waterfall concept.What is a standup meeting? Standup meetings are daily meetings in which all the team gives status about the three questions: 1. What did i do yesterday? 2. What is blocking me? 3. What am i doing today? This … Read more

maven parallel builds

maven 3.x has bought in a great feature, the possibility of parallel builds. mvn -T 4 clean install # Builds with 4 threads mvn -T 1C clean install # 1 thread per cpu core mvn -T 1.5C clean install # 1.5 thread per cpu co  I have been doing some experiments with this parallel builds … Read more

log4j2 writing multiple files for multiple webapps in tomcat

As we moved to the latest version of the log4j. We were using log4j 1.x and now we upgraded to log4j 2.x. We have 4 webapps in single tomcat container and they all share the same log4j2.xml. This log4j2.xml is provided at the startup of the tomcat container using the property “log4j.configurationFile”. property In log4j2.xml we had … Read more

Generating random integers using Random().nextInt(int bound)

In this tutorial we see how to generate a random number using the Random class in java and using the method  Random().nextInt(int bound). We will create a class named RandomIntegerGenerator. In this class we will use Random().nextInt(int bound) . It generates a random integer from 0 (inclusive) to bound (exclusive). Here we will set the bound … Read more