|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| package org.qedeq.kernel.log; |
|
19 |
| |
|
20 |
| import java.io.PrintStream; |
|
21 |
| import java.util.ArrayList; |
|
22 |
| import java.util.List; |
|
23 |
| |
|
24 |
| import org.qedeq.kernel.bo.module.ModuleProperties; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| public final class ModuleEventLog implements ModuleEventListener { |
|
34 |
| |
|
35 |
| |
|
36 |
| private static ModuleEventLog instance = new ModuleEventLog(); |
|
37 |
| |
|
38 |
| |
|
39 |
| private List loggers = new ArrayList(); |
|
40 |
| |
|
41 |
| |
|
42 |
| |
|
43 |
| |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
51
| public static final ModuleEventLog getInstance() {
|
|
48 |
51
| return instance;
|
|
49 |
| } |
|
50 |
| |
|
51 |
| |
|
52 |
| |
|
53 |
| |
|
54 |
| |
|
55 |
3
| private ModuleEventLog() {
|
|
56 |
| } |
|
57 |
| |
|
58 |
| |
|
59 |
| |
|
60 |
| |
|
61 |
| |
|
62 |
| |
|
63 |
3
| public final void addLog(final ModuleEventListener log) {
|
|
64 |
3
| loggers.add(log);
|
|
65 |
| } |
|
66 |
| |
|
67 |
| |
|
68 |
| |
|
69 |
| |
|
70 |
| |
|
71 |
| |
|
72 |
0
| public final void addLog(final PrintStream out) {
|
|
73 |
0
| final ModuleEventListener log = new DefaultModuleEventListener(out);
|
|
74 |
0
| loggers.add(log);
|
|
75 |
| } |
|
76 |
| |
|
77 |
17
| public void addModule(final ModuleProperties prop) {
|
|
78 |
17
| for (int i = 0; i < loggers.size(); i++) {
|
|
79 |
17
| ((ModuleEventListener) loggers.get(i)).addModule(prop);
|
|
80 |
| } |
|
81 |
| } |
|
82 |
| |
|
83 |
30
| public void stateChanged(final ModuleProperties prop) {
|
|
84 |
30
| for (int i = 0; i < loggers.size(); i++) {
|
|
85 |
30
| ((ModuleEventListener) loggers.get(i)).stateChanged(prop);
|
|
86 |
| } |
|
87 |
| } |
|
88 |
| |
|
89 |
1
| public void removeModule(final ModuleProperties prop) {
|
|
90 |
1
| for (int i = 0; i < loggers.size(); i++) {
|
|
91 |
1
| ((ModuleEventListener) loggers.get(i)).removeModule(prop);
|
|
92 |
| } |
|
93 |
| } |
|
94 |
| |
|
95 |
| |
|
96 |
| } |