1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
package events;
import java.util.*;
import prefs.*;
import core.*;
import utils.*;
public final class VSRegisteredEvents {
private static HashMap<String,String> eventClassnames;
private static HashMap<String,String> eventShortnames;
private static HashMap<String,String> eventNames;
private static ArrayList<String> editableProtocolsClassnames;
private static VSPrefs prefs;
public static void init(VSPrefs prefs_) {
prefs = prefs_;
eventNames = new HashMap<String, String>();
eventShortnames = new HashMap<String, String>();
eventClassnames = new HashMap<String, String>();
editableProtocolsClassnames = new ArrayList<String>();
registerEvent("events.implementations.ProcessCrashEvent", "Prozessabsturz", null);
registerEvent("events.implementations.ProcessRecoverEvent", "Prozesswiederbelebung", null);
registerEvent("protocols.implementations.BerkelyTimeProtocol", "Berkeley Algorithmus zur internen Sync.", "Berkeley");
registerEvent("protocols.implementations.BroadcastSturmProtocol", "Broadcaststurm", null);
registerEvent("protocols.implementations.DummyProtocol", "Beispiel/Dummy", null);
registerEvent("protocols.implementations.ExternalTimeSyncProtocol", "Christians Methode zur externen Sync.", "Christians");
registerEvent("protocols.implementations.InternalTimeSyncProtocol", "Interne Synchronisation", "Interne Sync.");
registerEvent("protocols.implementations.PingPongProtocol", "Ping Pong", null);
/* Make dummy objects of each protocol, to see if they contain VSPrefs values to edit */
Vector<String> protocolClassnames = getProtocolClassnames();
VSClassLoader classLoader = new VSClassLoader();
for (String protocolClassname : protocolClassnames) {
Object object = classLoader.newInstance(protocolClassname);
if (object instanceof protocols.VSProtocol) {
protocols.VSProtocol protocol = (protocols.VSProtocol) object;
if (!protocol.isEmpty())
editableProtocolsClassnames.add(protocolClassname);
}
}
}
public static ArrayList<String> getEditableProtocolsClassnames() {
return editableProtocolsClassnames;
}
public static Vector<String> getProtocolNames() {
Set<String> set = eventClassnames.keySet();
Vector<String> vector = new Vector<String>();
for (String eventName : set)
if (getClassname(eventName).startsWith("protocols.implementations"))
vector.add(eventName);
Collections.sort(vector);
return vector;
}
public static Vector<String> getProtocolClassnames() {
Set<String> set = eventNames.keySet();
Vector<String> vector = new Vector<String>();
for (String eventClassname : set)
if (eventClassname.startsWith("protocols.implementations"))
vector.add(eventClassname);
Collections.sort(vector);
return vector;
}
public static Vector<String> getNonProtocolNames() {
Set<String> set = eventClassnames.keySet();
Vector<String> vector = new Vector<String>();
for (String eventName : set)
if (getClassname(eventName).startsWith("events.implementations"))
vector.add(eventName);
Collections.sort(vector);
return vector;
}
public static Vector<String> getNonProtocolClassnames() {
Set<String> set = eventNames.keySet();
Vector<String> vector = new Vector<String>();
for (String eventClassname : set)
if (eventClassname.startsWith("events.implementations"))
vector.add(eventClassname);
Collections.sort(vector);
return vector;
}
public static String getClassname(String eventName) {
return eventClassnames.get(eventName);
}
public static String getName(String eventClassname) {
return eventNames.get(eventClassname);
}
public static String getShortname(String eventClassname) {
return eventShortnames.get(eventClassname);
}
public static VSEvent createEventInstanceByClassname(String eventClassname, VSProcess process) {
final Object protocolObj = new VSClassLoader().newInstance(eventClassname);
if (protocolObj instanceof VSEvent) {
VSEvent event = (VSEvent) protocolObj;
event.init(process);
return event;
}
return null;
}
public static VSEvent createEventInstanceByName(String eventName, VSProcess process) {
return createEventInstanceByClassname(eventClassnames.get(eventName), process);
}
private static void registerEvent(String eventClassname, String eventName, String eventShortname) {
if (eventShortname == null)
eventShortname = eventName;
//System.out.println(eventClassname);
eventNames.put(eventClassname, eventName);
eventShortnames.put(eventClassname, eventShortname);
eventClassnames.put(eventName, eventClassname);
}
}
|