%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
net.sf.infrared.collector.impl.persistence.Persister |
|
|
1 | /* |
|
2 | * Copyright 2005 Tavant Technologies and Contributors |
|
3 | * |
|
4 | * Licensed under the Apache License, Version 2.0 (the "License") |
|
5 | * you may not use this file except in compliance with the License. |
|
6 | * You may obtain a copy of the License at |
|
7 | * |
|
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
9 | * |
|
10 | * Unless required by applicable law or agreed to in writing, software |
|
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
13 | * See the License for the specific language governing permissions and |
|
14 | * limitations under the License. |
|
15 | * |
|
16 | * |
|
17 | * |
|
18 | * Original Author: binil.thomas (Tavant Technologies) |
|
19 | * Contributor(s): subin.p; |
|
20 | * |
|
21 | */ |
|
22 | package net.sf.infrared.collector.impl.persistence; |
|
23 | ||
24 | import java.util.Timer; |
|
25 | ||
26 | import net.sf.infrared.collector.CollectorConfig; |
|
27 | import net.sf.infrared.collector.StatisticsRepository; |
|
28 | ||
29 | public class Persister { |
|
30 | private CollectorConfig cfg; |
|
31 | ||
32 | private Timer timer; |
|
33 | ||
34 | private PersistTask task; |
|
35 | ||
36 | private StatisticsRepository statsRepository; |
|
37 | ||
38 | 0 | public Persister(CollectorConfig cfg, StatisticsRepository statsRepository) { |
39 | 0 | this.cfg = cfg; |
40 | 0 | this.statsRepository = statsRepository; |
41 | 0 | } |
42 | ||
43 | public void start() { |
|
44 | 0 | timer = new Timer(true); |
45 | 0 | task = new PersistTask(statsRepository); |
46 | 0 | timer.schedule(task, 0, cfg.getPersistInterval()); |
47 | 0 | } |
48 | ||
49 | public void shutdown() { |
|
50 | 0 | timer.cancel(); |
51 | 0 | if(task != null) { |
52 | 0 | task.shutdown(); |
53 | } |
|
54 | 0 | } |
55 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |