Tutorial 7: Add a Quartz menu item inside Spring batch admin
Add a Quartz menu in Spring Batch Admin
This article show how to add a menu item inside Spring batch Admin. Download the Source code
Note: Quartz is not yet implemented in this tutorial. This subject will be cover in the next article.
There are several steps when you add a menu item:
- Create a Quartz menu.
- Create a Quartz controler.
- Create a Quartz service.
- Create a Quartz template.
- Modify the Spring configuration.
A Quartz Menu
This class is integrated in the architecture of spring batch Admin.
The menu for Quartz is /quartz
package com.alaincieslik.springbatch.article.quartz.web;
import org.springframework.batch.admin.web.resources.BaseMenu;
public class QuartzMenu extends BaseMenu {
public QuartzMenu() {
super("/quartz", "Quartz", 5);
}
}
A Quartz Controller
There is no logic inside the controler. The objective of this article is just to configurate the menu into Spring batch admin.
package com.alaincieslik.springbatch.article.quartz.web;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.alaincieslik.springbatch.article.quartz.service.QuartzService;
@Controller
public class QuartzController {
@Autowired
private QuartzService quartzService;
@RequestMapping(value = "/quartz", method = RequestMethod.GET)
public List getTriggers() {
return new ArrayList();
}
}
A Quartz Service
The service is the entry point for all the quartz requests.
package com.alaincieslik.springbatch.article.quartz.service;
import java.util.List;
public interface QuartzService {
public List getTriggers();
}
A Quartz Service Implementation
package com.alaincieslik.springbatch.article.quartz.service;
import java.util.ArrayList;
import java.util.List;
public class QuartzServiceImpl implements QuartzService {
public List getTriggers(){
return new ArrayList();
}
}
A Quartz template
This template do not contains any logic. It just say hello way you click on the menu item.
<#import "/spring.ftl" as spring /> <div id="quartz"> Hello</div>
A Spring configuration
In Spring Admin Console, you can override the configuration in META-INF/spring/batch/servlet/override/web-context.xml
Links
- Download the Source code
- Add Quartz into Spring Batch to schedule a job batch
- Spring batch
- Spring batch admin
Wham bam thank you, ma’am, my questions are ansewerd!
Superior tihkning demonstrated above. Thanks!
BION I’m ipmrseesd! Cool post!
great post! when will part 2 of this tutorial be available to finish off the quartz ui?