1 |
18664
|
dimitra.ke
|
package eu.dnetlib.data.search.utils.vocabulary;
|
2 |
|
|
|
3 |
42709
|
katerina.i
|
import org.springframework.beans.factory.annotation.Autowired;
|
4 |
|
|
import org.springframework.web.context.support.WebApplicationContextUtils;
|
5 |
18933
|
antonis.le
|
|
6 |
42709
|
katerina.i
|
import javax.servlet.ServletContextEvent;
|
7 |
|
|
import javax.servlet.ServletContextListener;
|
8 |
|
|
import javax.servlet.annotation.WebListener;
|
9 |
18664
|
dimitra.ke
|
import java.util.concurrent.Executors;
|
10 |
|
|
import java.util.concurrent.ScheduledExecutorService;
|
11 |
|
|
import java.util.concurrent.ScheduledFuture;
|
12 |
|
|
|
13 |
42709
|
katerina.i
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
14 |
|
|
|
15 |
|
|
@WebListener
|
16 |
|
|
public class ResetVocabsScheduler implements ServletContextListener {
|
17 |
|
|
|
18 |
|
|
@Autowired
|
19 |
|
|
private String beautySleep;
|
20 |
|
|
|
21 |
|
|
@Autowired
|
22 |
|
|
private String begin;
|
23 |
|
|
|
24 |
|
|
@Autowired
|
25 |
18664
|
dimitra.ke
|
private VocabularyManager vManager = null;
|
26 |
42709
|
katerina.i
|
|
27 |
18664
|
dimitra.ke
|
public VocabularyManager getvManager() {
|
28 |
|
|
return vManager;
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
public void setvManager(VocabularyManager vManager) {
|
32 |
|
|
this.vManager = vManager;
|
33 |
|
|
}
|
34 |
|
|
|
35 |
42709
|
katerina.i
|
public String getBeautySleep() {
|
36 |
|
|
return beautySleep;
|
37 |
18664
|
dimitra.ke
|
}
|
38 |
|
|
|
39 |
42709
|
katerina.i
|
public void setBeautySleep(String beautySleep) {
|
40 |
|
|
this.beautySleep = beautySleep;
|
41 |
18664
|
dimitra.ke
|
}
|
42 |
|
|
|
43 |
42709
|
katerina.i
|
public String getBegin() {
|
44 |
|
|
return begin;
|
45 |
18664
|
dimitra.ke
|
}
|
46 |
|
|
|
47 |
42709
|
katerina.i
|
public void setBegin(String begin) {
|
48 |
|
|
this.begin = begin;
|
49 |
18664
|
dimitra.ke
|
}
|
50 |
|
|
|
51 |
|
|
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
52 |
|
|
|
53 |
42709
|
katerina.i
|
@Override
|
54 |
|
|
public void contextInitialized(ServletContextEvent servletContextEvent) {
|
55 |
|
|
WebApplicationContextUtils
|
56 |
|
|
.getRequiredWebApplicationContext(servletContextEvent.getServletContext())
|
57 |
|
|
.getAutowireCapableBeanFactory()
|
58 |
|
|
.autowireBean(this);
|
59 |
|
|
|
60 |
|
|
final ResetVocabs reseter = new ResetVocabs();
|
61 |
|
|
reseter.setvManager(vManager);
|
62 |
|
|
final ScheduledFuture<?> resetHandle = scheduler.scheduleAtFixedRate(reseter,Integer.parseInt(begin), Integer.parseInt(beautySleep), SECONDS);
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
@Override
|
66 |
|
|
public void contextDestroyed(ServletContextEvent servletContextEvent) {
|
67 |
|
|
scheduler.shutdown();
|
68 |
|
|
}
|
69 |
43931
|
katerina.i
|
|
70 |
18664
|
dimitra.ke
|
}
|