1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.qedeq.kernel.bo.log;
17
18 import java.io.PrintStream;
19 import java.util.ArrayList;
20 import java.util.List;
21
22 import org.qedeq.base.trace.Trace;
23 import org.qedeq.kernel.bo.common.QedeqBo;
24
25
26
27
28
29
30
31
32
33 public final class ModuleEventLog implements ModuleEventListener {
34
35
36 private static final Class CLASS = ModuleEventLog.class;
37
38
39 private static ModuleEventLog instance = new ModuleEventLog();
40
41
42 private List loggers = new ArrayList();
43
44
45
46
47
48
49
50 public static final ModuleEventLog getInstance() {
51 return instance;
52 }
53
54
55
56
57 private ModuleEventLog() {
58
59 }
60
61
62
63
64
65
66 public final void addLog(final ModuleEventListener log) {
67 loggers.add(log);
68 }
69
70
71
72
73
74
75 public final void removeLog(final ModuleEventListener log) {
76 loggers.remove(log);
77 }
78
79
80
81
82
83
84 public final void addLog(final PrintStream out) {
85 final ModuleEventListener log = new DefaultModuleEventListener(out);
86 loggers.add(log);
87 }
88
89 public void addModule(final QedeqBo prop) {
90 for (int i = 0; i < loggers.size(); i++) {
91 try {
92 ((ModuleEventListener) loggers.get(i)).addModule(prop);
93 } catch (RuntimeException e) {
94 Trace.fatal(CLASS, this, "addModule",
95 "ModuleEventListener throwed RuntimeException", e);
96 }
97 }
98 }
99
100 public void stateChanged(final QedeqBo prop) {
101 for (int i = 0; i < loggers.size(); i++) {
102 try {
103 ((ModuleEventListener) loggers.get(i)).stateChanged(prop);
104 } catch (RuntimeException e) {
105 Trace.fatal(CLASS, this, "stateChanged",
106 "ModuleEventListener throwed RuntimeException", e);
107 }
108 }
109 }
110
111 public void removeModule(final QedeqBo prop) {
112 for (int i = 0; i < loggers.size(); i++) {
113 try {
114 ((ModuleEventListener) loggers.get(i)).removeModule(prop);
115 } catch (RuntimeException e) {
116 Trace.fatal(CLASS, this, "removeModule",
117 "ModuleEventListener throwed RuntimeException", e);
118 }
119 }
120 }
121
122
123 }