View Javadoc

1   /*
2   Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
3   	$Id
4   */
5   package org.directdemocracyportal.democracy.service.governmentloader;
6   
7   import org.quartz.Job;
8   import org.quartz.JobExecutionContext;
9   import org.quartz.JobExecutionException;
10  import org.quartz.SchedulerException;
11  import org.springframework.context.ApplicationContext;
12  
13  /***
14   * The Class GovernmentImporterJob.
15   */
16  public class GovernmentImporterJob implements Job
17  {
18  
19      /*
20       * (non-Javadoc)
21       *
22       * @see org.quartz.Job#execute(org.quartz.JobExecutionContext)
23       */
24      public void execute(JobExecutionContext jobContext)
25              throws JobExecutionException {
26          GovernmentImporter governmentImporter = null;
27          try {
28              ApplicationContext ctx = (ApplicationContext) jobContext
29                      .getScheduler().getContext().get("applicationContext");
30              governmentImporter = (GovernmentImporter) ctx
31                      .getBean("swedishGovernmentImporter");
32          } catch (SchedulerException e) {
33              e.printStackTrace();
34          }
35  
36          if (governmentImporter != null) {
37              governmentImporter.doImport();
38          }
39      }
40  }