summaryrefslogtreecommitdiff
path: root/sources/events/implementations
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-20 16:36:49 +0000
committerPaul Buetow <paul@buetow.org>2008-05-20 16:36:49 +0000
commit8131638fc01dbde84864656e197b14772ff53346 (patch)
tree04a79601a8aa3d48a6c6c674f6baeafe61170374 /sources/events/implementations
parentda095a0767dfaabe363f2b7ed7d95fb35e066e14 (diff)
A VSMessage is not a VSEvent any more. Instead a MessageReceiveEvent has been introduced.
Diffstat (limited to 'sources/events/implementations')
-rw-r--r--sources/events/implementations/MessageReceiveEvent.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/sources/events/implementations/MessageReceiveEvent.java b/sources/events/implementations/MessageReceiveEvent.java
new file mode 100644
index 0000000..0a99b5f
--- /dev/null
+++ b/sources/events/implementations/MessageReceiveEvent.java
@@ -0,0 +1,52 @@
+package events.implementations;
+
+import core.VSMessage;
+import core.VSProcess;
+import events.VSEvent;
+import protocols.VSProtocol;
+
+public class MessageReceiveEvent extends VSEvent {
+ private VSMessage message;
+
+ public MessageReceiveEvent(VSMessage message) {
+ this.message = message;
+ }
+
+ protected void onInit() {
+ setClassname(getClass().toString());
+ }
+
+ public void onStart() {
+ String eventName = message.getName();
+ String protocolClassname = message.getProtocolClassname();
+
+ process.updateLamportTime(message.getLamportTime()+1);
+ process.updateVectorTime(message.getVectorTime());
+
+ Object protocolObj = null;
+
+ if (process.objectExists(protocolClassname))
+ protocolObj = process.getObject(protocolClassname);
+
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(prefs.getString("lang.message.recv"));
+ buffer.append("; ");
+ buffer.append(prefs.getString("lang.protocol"));
+ buffer.append(": " );
+ buffer.append(eventName);
+ buffer.append("; ");
+ buffer.append(prefs.getString("lang.message"));
+ buffer.append(" ");
+ buffer.append(message);;
+
+ if (protocolObj == null) {
+ logg(buffer.toString());
+
+ } else {
+ final VSProtocol protocol = (VSProtocol) protocolObj;
+ logg(buffer.toString());
+ protocol.onMessageRecv(message);
+ }
+
+ }
+}