commit | author | age
|
8e2038
|
1 |
|
U |
2 |
package de.uhilger.avdirektor; |
|
3 |
|
|
4 |
import java.util.logging.Logger; |
|
5 |
import java.util.logging.Level; |
|
6 |
import java.util.List; |
|
7 |
import java.util.ArrayList; |
|
8 |
import java.util.Iterator; |
|
9 |
|
|
10 |
public class MeldeThread extends Thread { |
|
11 |
|
|
12 |
private static final Logger logger = Logger.getLogger(MeldeThread.class.getName()); |
|
13 |
|
|
14 |
private Process omxplayer; |
|
15 |
private int exitValue; |
|
16 |
private List<ProzessLauscher> lauscher = new ArrayList<>(); |
|
17 |
private String meldeUrlStr; |
|
18 |
|
|
19 |
public void setProcess(Process p) { |
|
20 |
this.omxplayer = p; |
|
21 |
} |
|
22 |
|
|
23 |
public int getExitValue() { |
|
24 |
return exitValue; |
|
25 |
} |
|
26 |
|
|
27 |
public void setMeldeUrl(String meldeUrlStr) { |
|
28 |
this.meldeUrlStr = meldeUrlStr; |
|
29 |
} |
|
30 |
|
|
31 |
public void run() { |
|
32 |
try { |
|
33 |
exitValue = omxplayer.waitFor(); |
|
34 |
prozessBeendetMelden(); |
|
35 |
} catch(Exception ex) { |
|
36 |
logger.log(Level.FINE, ex.getMessage(), ex); |
|
37 |
} finally { |
|
38 |
aufraeumen(); |
|
39 |
} |
|
40 |
} |
|
41 |
|
|
42 |
private void aufraeumen() { |
|
43 |
lauscher.clear(); |
|
44 |
lauscher = null; |
|
45 |
} |
|
46 |
|
|
47 |
public void lauscherHinzufuegen(ProzessLauscher l) { |
|
48 |
lauscher.add(l); |
|
49 |
} |
|
50 |
|
|
51 |
public void lauscherEntfernen(ProzessLauscher l) { |
|
52 |
lauscher.remove(l); |
|
53 |
} |
|
54 |
|
|
55 |
private void prozessBeendetMelden() { |
|
56 |
Iterator<ProzessLauscher> i = lauscher.iterator(); |
|
57 |
while(i.hasNext()) { |
|
58 |
ProzessLauscher l = i.next(); |
|
59 |
l.prozessBeendet(meldeUrlStr); |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
} |