/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/ReloadTask.java
ViewVC logotype

Annotation of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/ReloadTask.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2993 - (hide annotations) (download)
Tue Mar 29 19:49:38 2016 UTC (8 years, 2 months ago) by torben
File size: 1228 byte(s)
Implement a reload task that triggers the reload and then just blocks the reload queue
1 torben 2993 package dk.daoas.adressevedligehold;
2    
3     import java.io.IOException;
4     import java.util.logging.Logger;
5    
6     import dk.daoas.adressevedligehold.tasks.Task;
7     import dk.daoas.adressevedligehold.util.HttpUtil;
8    
9     /**
10     * Simple class that triggers a data reload and then just blocks the task execution queue for DELAY milliseconds.
11     *
12     */
13     public class ReloadTask extends Task {
14    
15     public final static int DELAY = 120 * 1000;
16    
17     private Logger logger = Logger.getLogger(ReloadTask.class.getName());
18     private String trigger;
19    
20     public ReloadTask(String trigger) {
21     this.trigger = trigger;
22     }
23    
24     @Override
25     protected void taskRun() throws Exception {
26     try {
27     triggerReload();
28    
29     Thread.sleep(DELAY);
30    
31     } catch (Exception e) {
32    
33     }
34     }
35    
36     @Override
37     public String getDescription() {
38     return "Reload Task";
39     }
40    
41     @Override
42     public String getDetail() {
43     return null;
44     }
45    
46     @Override
47     public double getPercentCompleted() {
48     return 0;
49     }
50    
51    
52    
53     private void triggerReload() throws IOException {
54     String trigger_url = ServiceConfig.getInstance().trigger_url;
55    
56     logger.info("Calling trigger URL");
57     trigger = HttpUtil.encode(trigger);
58    
59     String url = trigger_url + "&trigger=" + trigger;
60    
61    
62     HttpUtil.getContentString(url, 1000);
63     }
64    
65     }

  ViewVC Help
Powered by ViewVC 1.1.20