Project

General

Profile

1
package eu.dnetlib.goldoa.service.utils;
2

    
3
import eu.dnetlib.goldoa.service.PublicationManager;
4
import org.springframework.beans.factory.annotation.Autowired;
5

    
6
import javax.annotation.PostConstruct;
7
import javax.sql.DataSource;
8
import java.util.concurrent.Executors;
9
import java.util.concurrent.ScheduledExecutorService;
10
import java.util.concurrent.TimeUnit;
11

    
12
/*
13
 * Created by antleb on 3/7/16.
14
*/
15

    
16
public class Scheduler {
17

    
18
	@Autowired
19
	private DataSource dataSource;
20
	@Autowired
21
	private PublicationManager publicationManager;
22

    
23
	private ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
24

    
25
	@PostConstruct
26
	public void init() {
27

    
28
		executor.scheduleAtFixedRate(new LicenseUpdateTask(dataSource, publicationManager), 0, 3,TimeUnit.HOURS);
29
	}
30

    
31
	public void destroy() {
32
		executor.shutdown();
33
	}
34
}
(7-7/7)