Quartz Scheduler with Spring


You have already seen how to build a scheduler using quartz. With already providing
support to any possible tech feature in today's world, it's no surprise that Spring has
support for quartz. We will see here how you can build quartz application using
Spring.

Again for this project also we are going to take help from maven.

If you don't know how to create a simple maven project , check this link - Create a Simple Maven Project

Let's go step by step.

1. Create a simple maven project.

2. We are using Spring 3.0 version here, agree it is bit old, but I guess no significant change has been done ( if any) for quartz support.

Enter this dependencies in pom.xml :


  
  
   org.springframework
   spring-core
   3.0.4.RELEASE
  

  
  
   org.springframework
   spring-context-support
   3.0.4.RELEASE
  

  
  
   org.springframework
   spring-tx
   3.0.4.RELEASE
  

  
  
   org.quartz-scheduler
   quartz
   1.8.5
  

 
3. Now under your 'src' folder make two sub-folder, namely : 'com/java' and 'resource'.

Quartz Scheduler(Using Maven)

Today we will be discussing about Quartz Scheduler in Java. For that we are going to need a couple of Quartz jars. But, As I will be developing the project using Maven Build tools, I am not downloading it.
So, let's start with creating a Maven project for Quartz.

Step 1 : Create a Maven Project.
       a. Set up Maven in your eclipse. If you don't know how to set up Maven in Eclipse, have a look at              this tutorial - Setup Maven in Eclipse .
       b. Create a new Maven Project with whatever name you want. If you don't know how to create a
           Maven project in Eclipse, visit this link - Create a simple Maven project

Now, your maven project is ready to implement a Quartz Scheduler. But, for that, we need to add a couple of dependencies in our pom.xml.

Step 2: Add dependencies for Quartz in pom.xml. 
Add the following dependencies in your pom.xml.    

        
   org.quartz-scheduler
   quartz
   2.2.1
  
  
   org.quartz-scheduler
   quartz-jobs
   2.2.1
  
Now, we need to create two classes.

A Simple Maven Project

Today we are discussing about how to create a simple Maven Project.
But, before we start discussing how to create a project, we need to know how to set up our eclipse with Maven. And, for that, visit this link - Install Maven into Eclipse

What is Maven and why we use it?
Well, Maven is a simple build tool. But what makes it more popular is that, if we need any jar for our project,we just have to mention all of them in the pom.xml of the project and it downloads all the jar dependencies automatically. We don't really need to include any jar in the project. And, so, the project size become small & easily transferable.

Google Charts


Google Charts, I believe, is one of the most beautiful & easiest tool to create Charts and Graphs. Previously we have discussed How to create Charts and Graphs in Java using JFreeChart , but I must admit that when you have scope to use Google Charts, you must go for it!
Google Charts provides you a support for charts completely over internet. You don't have to use any jar or anything in your project. It can be done completely on the client side. And, most importantly, it looks beautiful. :). But, yes, if you are creating an application which will run offline, then JFreeChart comes into use.

In this post, we will discuss about creating Column Chart & Stacked Column Chart using Google Charts.

Column Chart & Stacked Column Chart

Let's say we need to create a Column graph with 3 parameters:

1. on X axis: years (from 2000-2013)
2. on Y axis: numbers of employees in the organization at the end of the year(in Green Bar) &

Convert a JSON String into JavaScriptObject

Converting a JSON String in to a JavaScriptObject can be pretty easy. Either you can do it in javascript file, or, simply use a native method for that.
The code will as simple as follows:

var temp = jsonString;
var jsonObject = eval('('+temp+')');
return jsonObject
This program will return the JavasScriptObject.
But, if you want to return the JSON String , remove the previous return statement & add the the below line :

return JSON.stringify(jsonObject);

This return statement will convert your JavaScript Object in JSON String & return it.



Happy Learning!!