1
2
3
4
5
6 package com.hack23.cia.service.impl.admin;
7
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10 import org.quartz.Job;
11 import org.quartz.JobExecutionContext;
12 import org.quartz.JobExecutionException;
13 import org.quartz.SchedulerException;
14 import org.springframework.context.ApplicationContext;
15
16 /***
17 * The Class LoaderJob.
18 */
19 public class LoaderJob implements Job {
20
21 /*** The Constant ADMIN_SERVICE. */
22 private static final String ADMIN_SERVICE = "adminService";
23
24 /*** The Constant APPLICATION_CONTEXT. */
25 private static final String APPLICATION_CONTEXT = "applicationContext";
26
27 /*** The Constant LOGGER. */
28 private static final Log LOGGER = LogFactory.getLog(LoaderJob.class);
29
30
31
32
33
34
35 @Override
36 public final void execute(final JobExecutionContext context)
37 throws JobExecutionException {
38 AdminService adminService = null;
39 try {
40 final ApplicationContext ctx = (ApplicationContext) context
41 .getScheduler().getContext().get(APPLICATION_CONTEXT);
42 adminService = (AdminService) ctx.getBean(ADMIN_SERVICE);
43 } catch (final SchedulerException e) {
44 LOGGER.error("Quartz Scheduling", e);
45 }
46
47 if (adminService != null) {
48 LOGGER.info("Quartz job started");
49 adminService.startUpdateJob();
50 LOGGER.info("Quartz job completed");
51 }
52 }
53 }