1 |
package dk.thoerup.traininfo.provider; |
package dk.thoerup.traininfo.provider; |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
public class ProviderFactory { |
public class ProviderFactory { |
7 |
private static DepartureProvider departureProvider = null; |
private static DepartureProvider departureProvider = null; |
8 |
private static StationProvider stationProvider = null; |
private static StationProvider stationProvider = null; |
10 |
|
|
11 |
private static final boolean DEBUG = false; |
private static final boolean DEBUG = false; |
12 |
|
|
13 |
|
//TODO: this one really doesn't belong here ... and damn it is ugly code |
14 |
|
public static void purgeOldEntries() { |
15 |
|
synchronized (ProviderFactory.class) { |
16 |
|
if (stationProvider != null && stationProvider instanceof XmlStationProvider) { |
17 |
|
((XmlStationProvider)stationProvider).stationCache.purgeOldEntries(); |
18 |
|
} |
19 |
|
|
20 |
|
if (departureProvider != null && departureProvider instanceof XmlDepartureProvider) { |
21 |
|
((XmlDepartureProvider)departureProvider).departureCache.purgeOldEntries(); |
22 |
|
} |
23 |
|
|
24 |
|
if (timetableProvider != null && timetableProvider instanceof XmlTimetableProvider) { |
25 |
|
((XmlTimetableProvider)timetableProvider).timetableCache.purgeOldEntries(); |
26 |
|
} |
27 |
|
} |
28 |
|
|
29 |
|
} |
30 |
|
|
31 |
public static DepartureProvider getDepartureProvider() { |
public static DepartureProvider getDepartureProvider() { |
32 |
if (departureProvider == null) { |
if (departureProvider == null) { |
33 |
if (!DEBUG) { |
if (!DEBUG) { |