summaryrefslogtreecommitdiff
path: root/sources/events
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2008-05-25 08:10:13 +0000
committerPaul Buetow <paul@buetow.org>2008-05-25 08:10:13 +0000
commitc015d586d22b69078b6da61858e5675793856b0b (patch)
treeefbc9881cf59363abef52a0beb5eedf9e81a224a /sources/events
parent62fe28f0b0b0c9ebde18a6dc33907889ff3aa21b (diff)
JAutoDoc :)
Diffstat (limited to 'sources/events')
-rw-r--r--sources/events/VSEvent.java70
-rw-r--r--sources/events/VSRegisteredEvents.java92
-rw-r--r--sources/events/implementations/ProcessCrashEvent.java15
-rw-r--r--sources/events/implementations/ProcessRecoverEvent.java15
-rw-r--r--sources/events/internal/MessageReceiveEvent.java21
-rw-r--r--sources/events/internal/ProtocolEvent.java45
6 files changed, 258 insertions, 0 deletions
diff --git a/sources/events/VSEvent.java b/sources/events/VSEvent.java
index d058e33..c5cb5df 100644
--- a/sources/events/VSEvent.java
+++ b/sources/events/VSEvent.java
@@ -1,14 +1,35 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package events;
import core.VSProcess;
import prefs.VSPrefs;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSEvent.
+ */
abstract public class VSEvent extends VSPrefs {
+
+ /** The prefs. */
protected VSPrefs prefs;
+
+ /** The process. */
protected VSProcess process;
+
+ /** The event shortname. */
private String eventShortname;
+
+ /** The event classname. */
private String eventClassname;
+ /**
+ * Inits the.
+ *
+ * @param process the process
+ */
public void init(VSProcess process) {
this.process = process;
this.prefs = process.getPrefs();
@@ -16,6 +37,11 @@ abstract public class VSEvent extends VSPrefs {
onInit();
}
+ /**
+ * Sets the classname.
+ *
+ * @param eventClassname the new classname
+ */
protected final void setClassname(String eventClassname) {
if (eventClassname.startsWith("class "))
eventClassname = eventClassname.substring(6);
@@ -23,18 +49,38 @@ abstract public class VSEvent extends VSPrefs {
this.eventClassname = eventClassname;
}
+ /**
+ * Gets the classname.
+ *
+ * @return the classname
+ */
public String getClassname() {
return eventClassname;
}
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
public String getName() {
return VSRegisteredEvents.getName(eventClassname);
}
+ /**
+ * Sets the shortname.
+ *
+ * @param eventShortname the new shortname
+ */
public void setShortname(String eventShortname) {
this.eventShortname = eventShortname;
}
+ /**
+ * Gets the shortname.
+ *
+ * @return the shortname
+ */
public String getShortname() {
if (eventShortname == null)
return VSRegisteredEvents.getShortname(eventClassname);
@@ -42,18 +88,42 @@ abstract public class VSEvent extends VSPrefs {
return eventShortname;
}
+ /**
+ * Gets the process.
+ *
+ * @return the process
+ */
public VSProcess getProcess() {
return process;
}
+ /**
+ * Logg.
+ *
+ * @param message the message
+ */
public void logg(String message) {
process.logg(/*toString() + "; " + */message);
}
+ /**
+ * Equals.
+ *
+ * @param event the event
+ *
+ * @return true, if successful
+ */
public boolean equals(VSEvent event) {
return super.getID() == event.getID();
}
+ /**
+ * On init.
+ */
abstract protected void onInit();
+
+ /**
+ * On start.
+ */
abstract public void onStart();
}
diff --git a/sources/events/VSRegisteredEvents.java b/sources/events/VSRegisteredEvents.java
index 2643d6f..d41ffea 100644
--- a/sources/events/VSRegisteredEvents.java
+++ b/sources/events/VSRegisteredEvents.java
@@ -1,3 +1,7 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package events;
import java.util.*;
@@ -6,13 +10,32 @@ import prefs.*;
import core.*;
import utils.*;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class VSRegisteredEvents.
+ */
public final class VSRegisteredEvents {
+
+ /** The event classnames. */
private static HashMap<String,String> eventClassnames;
+
+ /** The event shortnames. */
private static HashMap<String,String> eventShortnames;
+
+ /** The event names. */
private static HashMap<String,String> eventNames;
+
+ /** The editable protocols classnames. */
private static ArrayList<String> editableProtocolsClassnames;
+
+ /** The prefs. */
private static VSPrefs prefs;
+ /**
+ * Inits the.
+ *
+ * @param prefs_ the prefs_
+ */
public static void init(VSPrefs prefs_) {
prefs = prefs_;
eventNames = new HashMap<String, String>();
@@ -42,10 +65,20 @@ public final class VSRegisteredEvents {
}
}
+ /**
+ * Gets the editable protocols classnames.
+ *
+ * @return the editable protocols classnames
+ */
public static ArrayList<String> getEditableProtocolsClassnames() {
return editableProtocolsClassnames;
}
+ /**
+ * Gets the protocol names.
+ *
+ * @return the protocol names
+ */
public static Vector<String> getProtocolNames() {
Set<String> set = eventClassnames.keySet();
Vector<String> vector = new Vector<String>();
@@ -59,6 +92,11 @@ public final class VSRegisteredEvents {
return vector;
}
+ /**
+ * Gets the protocol classnames.
+ *
+ * @return the protocol classnames
+ */
public static Vector<String> getProtocolClassnames() {
Set<String> set = eventNames.keySet();
Vector<String> vector = new Vector<String>();
@@ -72,6 +110,11 @@ public final class VSRegisteredEvents {
return vector;
}
+ /**
+ * Gets the non protocol names.
+ *
+ * @return the non protocol names
+ */
public static Vector<String> getNonProtocolNames() {
Set<String> set = eventClassnames.keySet();
Vector<String> vector = new Vector<String>();
@@ -85,6 +128,11 @@ public final class VSRegisteredEvents {
return vector;
}
+ /**
+ * Gets the non protocol classnames.
+ *
+ * @return the non protocol classnames
+ */
public static Vector<String> getNonProtocolClassnames() {
Set<String> set = eventNames.keySet();
Vector<String> vector = new Vector<String>();
@@ -98,18 +146,47 @@ public final class VSRegisteredEvents {
return vector;
}
+ /**
+ * Gets the classname.
+ *
+ * @param eventName the event name
+ *
+ * @return the classname
+ */
public static String getClassname(String eventName) {
return eventClassnames.get(eventName);
}
+ /**
+ * Gets the name.
+ *
+ * @param eventClassname the event classname
+ *
+ * @return the name
+ */
public static String getName(String eventClassname) {
return eventNames.get(eventClassname);
}
+ /**
+ * Gets the shortname.
+ *
+ * @param eventClassname the event classname
+ *
+ * @return the shortname
+ */
public static String getShortname(String eventClassname) {
return eventShortnames.get(eventClassname);
}
+ /**
+ * Creates the event instance by classname.
+ *
+ * @param eventClassname the event classname
+ * @param process the process
+ *
+ * @return the vS event
+ */
public static VSEvent createEventInstanceByClassname(String eventClassname, VSProcess process) {
final Object protocolObj = new VSClassLoader().newInstance(eventClassname);
@@ -122,10 +199,25 @@ public final class VSRegisteredEvents {
return null;
}
+ /**
+ * Creates the event instance by name.
+ *
+ * @param eventName the event name
+ * @param process the process
+ *
+ * @return the vS event
+ */
public static VSEvent createEventInstanceByName(String eventName, VSProcess process) {
return createEventInstanceByClassname(eventClassnames.get(eventName), process);
}
+ /**
+ * Register event.
+ *
+ * @param eventClassname the event classname
+ * @param eventName the event name
+ * @param eventShortname the event shortname
+ */
private static void registerEvent(String eventClassname, String eventName, String eventShortname) {
if (eventShortname == null)
eventShortname = eventName;
diff --git a/sources/events/implementations/ProcessCrashEvent.java b/sources/events/implementations/ProcessCrashEvent.java
index c8a9348..e55d18a 100644
--- a/sources/events/implementations/ProcessCrashEvent.java
+++ b/sources/events/implementations/ProcessCrashEvent.java
@@ -1,12 +1,27 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package events.implementations;
import events.VSEvent;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ProcessCrashEvent.
+ */
public class ProcessCrashEvent extends VSEvent {
+
+ /* (non-Javadoc)
+ * @see events.VSEvent#onInit()
+ */
protected void onInit() {
setClassname(getClass().toString());
}
+ /* (non-Javadoc)
+ * @see events.VSEvent#onStart()
+ */
public void onStart() {
if (!process.isCrashed()) {
process.isCrashed(true);
diff --git a/sources/events/implementations/ProcessRecoverEvent.java b/sources/events/implementations/ProcessRecoverEvent.java
index 00b2164..cae67cb 100644
--- a/sources/events/implementations/ProcessRecoverEvent.java
+++ b/sources/events/implementations/ProcessRecoverEvent.java
@@ -1,12 +1,27 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package events.implementations;
import events.VSEvent;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ProcessRecoverEvent.
+ */
public class ProcessRecoverEvent extends VSEvent {
+
+ /* (non-Javadoc)
+ * @see events.VSEvent#onInit()
+ */
protected void onInit() {
setClassname(getClass().toString());
}
+ /* (non-Javadoc)
+ * @see events.VSEvent#onStart()
+ */
public void onStart() {
if (process.isCrashed()) {
process.isCrashed(false);
diff --git a/sources/events/internal/MessageReceiveEvent.java b/sources/events/internal/MessageReceiveEvent.java
index b59c779..0b4af83 100644
--- a/sources/events/internal/MessageReceiveEvent.java
+++ b/sources/events/internal/MessageReceiveEvent.java
@@ -1,20 +1,41 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package events.internal;
import core.VSMessage;
import events.VSEvent;
import protocols.VSProtocol;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class MessageReceiveEvent.
+ */
public class MessageReceiveEvent extends VSEvent {
+
+ /** The message. */
private VSMessage message;
+ /**
+ * Instantiates a new message receive event.
+ *
+ * @param message the message
+ */
public MessageReceiveEvent(VSMessage message) {
this.message = message;
}
+ /* (non-Javadoc)
+ * @see events.VSEvent#onInit()
+ */
protected void onInit() {
setClassname(getClass().toString());
}
+ /* (non-Javadoc)
+ * @see events.VSEvent#onStart()
+ */
public void onStart() {
String eventName = message.getName();
String protocolClassname = message.getProtocolClassname();
diff --git a/sources/events/internal/ProtocolEvent.java b/sources/events/internal/ProtocolEvent.java
index 0cece54..b29a828 100644
--- a/sources/events/internal/ProtocolEvent.java
+++ b/sources/events/internal/ProtocolEvent.java
@@ -1,37 +1,82 @@
+/*
+ * VS is (c) 2008 by Paul C. Buetow
+ * vs@dev.buetow.org
+ */
package events.internal;
import events.*;
import protocols.VSProtocol;
+// TODO: Auto-generated Javadoc
+/**
+ * The Class ProtocolEvent.
+ */
public class ProtocolEvent extends VSEvent {
+
+ /** The protocol classname. */
private String protocolClassname;
+
+ /** The is client protocol. */
private boolean isClientProtocol; /* true = client, false = server */
+
+ /** The is protocol activation. */
private boolean isProtocolActivation; /* true = activate, false = deactivate */
+ /* (non-Javadoc)
+ * @see events.VSEvent#onInit()
+ */
protected void onInit() {
setClassname(getClass().toString());
}
+ /**
+ * Checks if is client protocol.
+ *
+ * @param isClientProtocol the is client protocol
+ */
public void isClientProtocol(boolean isClientProtocol) {
this.isClientProtocol = isClientProtocol;
}
+ /**
+ * Checks if is client protocol.
+ *
+ * @return true, if is client protocol
+ */
public boolean isClientProtocol() {
return isClientProtocol;
}
+ /**
+ * Checks if is protocol activation.
+ *
+ * @param isProtocolActivation the is protocol activation
+ */
public void isProtocolActivation(boolean isProtocolActivation) {
this.isProtocolActivation = isProtocolActivation;
}
+ /**
+ * Checks if is protocol activation.
+ *
+ * @return true, if is protocol activation
+ */
public boolean isProtocolActivation() {
return isProtocolActivation;
}
+ /**
+ * Sets the protocol classname.
+ *
+ * @param protocolClassname the new protocol classname
+ */
public void setProtocolClassname(String protocolClassname) {
this.protocolClassname = protocolClassname;
}
+ /* (non-Javadoc)
+ * @see events.VSEvent#onStart()
+ */
public void onStart() {
VSProtocol protocol = process.getProtocolObject(protocolClassname);