diff options
| author | Paul Buetow (centauri) <puppet@mx.buetow.org> | 2015-05-23 21:59:43 +0100 |
|---|---|---|
| committer | Paul Buetow (centauri) <puppet@mx.buetow.org> | 2015-05-23 21:59:43 +0100 |
| commit | 9fc2fc3ccdedf1b7e48f8dfb618ca6cb6a2a662e (patch) | |
| tree | 0fa92fe4e75cb53ffbf7eb56b5455eb9457bb06c /sources/events | |
| parent | f7873669a43421331e14b8921ebdaa8af4393bd5 (diff) | |
| parent | 32749241efc1f5f70056d74a90237388f57ea350 (diff) | |
Merge remote-tracking branch 'remotes/github/packages' into packagespackages
Diffstat (limited to 'sources/events')
| -rw-r--r-- | sources/events/VSAbstractEvent.java | 266 | ||||
| -rw-r--r-- | sources/events/VSCopyableEvent.java | 40 | ||||
| -rw-r--r-- | sources/events/VSRegisteredEvents.java | 409 | ||||
| -rw-r--r-- | sources/events/implementations/VSProcessCrashEvent.java | 69 | ||||
| -rw-r--r-- | sources/events/implementations/VSProcessRecoverEvent.java | 70 | ||||
| -rw-r--r-- | sources/events/internal/VSAbstractInternalEvent.java | 84 | ||||
| -rw-r--r-- | sources/events/internal/VSMessageReceiveEvent.java | 112 | ||||
| -rw-r--r-- | sources/events/internal/VSProtocolEvent.java | 199 | ||||
| -rw-r--r-- | sources/events/internal/VSProtocolScheduleEvent.java | 151 |
9 files changed, 0 insertions, 1400 deletions
diff --git a/sources/events/VSAbstractEvent.java b/sources/events/VSAbstractEvent.java deleted file mode 100644 index ac9a61f..0000000 --- a/sources/events/VSAbstractEvent.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * VS-Simulator (http://vs-sim.buetow.org) - * Copyright (c) 2008 - 2009 by Dipl.-Inform. (FH) Paul C. Buetow - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events; - -import java.io.*; - -import core.VSAbstractProcess; -import core.VSInternalProcess; -import exceptions.*; -import prefs.*; -import serialize.*; - -/** - * The class VSAbstractEvent. This abstract class defines the basic framework - * of each event. an event is used to fullfill a specific task. An event object - * will get stored in a VSTask object. - * - * @author Paul C. Buetow - */ -abstract public class VSAbstractEvent extends VSSerializablePrefs { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The prefs. */ - public VSPrefs prefs; - - /** The process. */ - public VSAbstractProcess process; - - /** The event shortname. */ - private String eventShortname; - - /** The event classname. */ - private String eventClassname; - - /** - * Creates a copy of the event and using a new process. - * - * @param theProcess The new process - * @return The copy - */ - final public VSAbstractEvent getCopy(VSInternalProcess theProcess) - throws VSEventNotCopyableException { - - if (theProcess == null) - theProcess = (VSInternalProcess) process; - - if (!(this instanceof VSCopyableEvent)) - throw new VSEventNotCopyableException( - eventShortname + " (" + eventClassname + ")"); - - VSAbstractEvent copy = - VSRegisteredEvents.createEventInstanceByClassname( - eventClassname, theProcess); - - ((VSCopyableEvent) this).initCopy(copy); - copy.setShortname(eventShortname); - - return copy; - } - - /** - * Creates a copy of the event. - * - * @return The copy - */ - final public VSAbstractEvent getCopy() throws VSEventNotCopyableException { - return getCopy(null); - } - - /** - * Inits the event. - * - * @param process the process - */ - public void init(VSInternalProcess process) { - if (this.process == null) { - this.process = process; - this.prefs = process.getPrefs(); - init(); - } - } - - /** - * Inits the event without setting the processes and prefs variables - * of the object. - */ - public void init() { - onInit(); - } - - /** - * Sets the classname. - * - * @param eventClassname the new classname - */ - public final void setClassname(String eventClassname) { - if (eventClassname.startsWith("class ")) - eventClassname = eventClassname.substring(6); - - 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.getNameByClassname(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.getShortnameByClassname(eventClassname); - - return eventShortname; - } - - /** - * Gets the process. - * - * @return the process - */ - public VSAbstractProcess getProcess() { - return process; - } - - /** - * Logg a specific message. - * - * @param message the loging message - */ - public void log(String message) { - process.log(/*toString() + "; " + */message); - } - - /** - * Checks if the event equals to another event.. - * - * @param event the event to compare against. - * - * @return true, if the events are the same (have the same event id) - */ - public boolean equals(VSAbstractEvent event) { - return super.getID() == event.getID(); - } - - /** - * Every event has its own initialize method. - */ - abstract public void onInit(); - - /** - * Every event can get started. This method get's executed if the event - * takes place. - */ - abstract public void onStart(); - - /** - * Every event has to be able to set its own shortname - * - * @param shortName The saved short name. May be overwritten due wrong lang - * - * @return The event's shortname - */ - abstract protected String createShortname(String savedShortname); - - /* (non-Javadoc) - * @see serialize.VSSerializable#serialize(serialize.VSSerialize, - * java.io.ObjectOutputStream) - */ - public synchronized void serialize(VSSerialize serialize, - ObjectOutputStream objectOutputStream) - throws IOException { - super.serialize(serialize, objectOutputStream); - - if (VSSerialize.DEBUG) - System.out.println("Serializing: VSAbstractEvent; id="+getID()); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - - objectOutputStream.writeObject(new Integer(super.getID())); - objectOutputStream.writeObject(eventShortname); - objectOutputStream.writeObject(eventClassname); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, - * java.io.ObjectInputStream) - */ - @SuppressWarnings("unchecked") - public synchronized void deserialize(VSSerialize serialize, - ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - super.deserialize(serialize, objectInputStream); - - if (VSSerialize.DEBUG) - System.out.print("Deserializing: VSAbstractEvent "); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - - int id = ((Integer) objectInputStream.readObject()).intValue(); - String savedEventShortname = (String) objectInputStream.readObject(); - this.eventClassname = (String) objectInputStream.readObject(); - this.eventShortname = createShortname(savedEventShortname); - - if (VSSerialize.DEBUG) - System.out.println(eventClassname); - - serialize.setObject(id, "event", this); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - } -} diff --git a/sources/events/VSCopyableEvent.java b/sources/events/VSCopyableEvent.java deleted file mode 100644 index 0ad6b24..0000000 --- a/sources/events/VSCopyableEvent.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events; - - -/** - * The interface VSCopyableEvent, all events which implement this class - * are copyable. - * - * @author Paul C. Buetow - */ -public interface VSCopyableEvent { - /** - * Fills a copy of this event with its values - * - * @param copy The copy - */ - public void initCopy(VSAbstractEvent copy); -} diff --git a/sources/events/VSRegisteredEvents.java b/sources/events/VSRegisteredEvents.java deleted file mode 100644 index 9d022d9..0000000 --- a/sources/events/VSRegisteredEvents.java +++ /dev/null @@ -1,409 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events; - -import java.util.*; - -import prefs.*; -import core.*; -import utils.*; - -/** - * The class VSRegisteredEvents. This class is responsible to manage all - * events. It manages the event classnames, the event shortnames and the event - * names. It also checks if a protocol (which is an event as well) has - * variables which are editable through the GUI of the simulator. - * - * @author Paul C. Buetow - */ -public final class VSRegisteredEvents { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The event classnames by eventnames. */ - private static HashMap<String,String> eventClassnamesByNames = - new HashMap<String,String>(); - - /** The event shortnames by classnames. */ - private static HashMap<String,String> eventShortnamesByClassnames = - new HashMap<String,String>(); - - /** The event names by classnames. */ - private static HashMap<String,String> eventNamesByClassnames = - new HashMap<String,String>(); - - /** The event classnames by shortnames. */ - private static HashMap<String,String> eventClassnamesByShortnames = - new HashMap<String,String>(); - - /** The editable protocols classnames. */ - private static ArrayList<String> editableProtocolsClassnames = - new ArrayList<String>(); - - private static HashMap<String,ArrayList<String>> clientVariables = - new HashMap<String,ArrayList<String>>(); - - private static HashMap<String,ArrayList<String>> serverVariables = - new HashMap<String,ArrayList<String>>(); - - private static HashMap<String,Boolean> isOnServerStartProtocol = - new HashMap<String,Boolean>(); - - /** The prefs. */ - private static VSPrefs prefs; - - /** - * Registers available events. - * - * @param prefs_ the prefs_ - */ - public static void init(VSPrefs prefs_) { - prefs = prefs_; - - /* - registerEvent("events.implementations.VSProcessCrashEvent", - "Prozessabsturz"); - registerEvent("events.implementations.VSProcessRecoverEvent", - "Prozesswiederbelebung"); - registerEvent("protocols.implementations.VSBasicMulticastProtocol", - "Basic Multicast", "Basic Multicast"); - registerEvent("protocols.implementations.VSBerkelyTimeProtocol", - "Berkeley Algorithmus zur internen Sync.", "Berkeley"); - registerEvent("protocols.implementations.VSBroadcastProtocol", - "Broadcast"); - registerEvent("protocols.implementations.VSDummyProtocol", - "Beispiel/Dummy"); - registerEvent("protocols.implementations.VSExternalTimeSyncProtocol", - "Christians Methode zur externen Sync.", "Christians"); - registerEvent("protocols.implementations.VSInternalTimeSyncProtocol", - "Interne Synchronisation", "Interne Sync."); - registerEvent("protocols.implementations.VSOnePhaseCommitProtocol", - "Ein-Phasen Commit", "1-Phasen Commit"); - registerEvent("protocols.implementations.VSPingPongProtocol", - "Ping Pong"); - registerEvent("protocols.implementations.VSReliableMulticastProtocol", - "Reliable Multicast", "Reliable Multicast"); - registerEvent("protocols.implementations.VSTwoPhaseCommitProtocol", - "Zwei-Phasen Commit", "2-Phasen Commit"); - */ - - /* Using the NEW way. The old way above (specifying protocol names - in this file still works as well */ - - registerEvent("events.implementations.VSProcessCrashEvent"); - registerEvent("events.implementations.VSProcessRecoverEvent"); - registerEvent("protocols.implementations.VSBasicMulticastProtocol"); - registerEvent("protocols.implementations.VSBerkelyTimeProtocol"); - registerEvent("protocols.implementations.VSBroadcastProtocol"); - registerEvent("protocols.implementations.VSDummyProtocol"); - registerEvent("protocols.implementations.VSExternalTimeSyncProtocol"); - registerEvent("protocols.implementations.VSInternalTimeSyncProtocol"); - registerEvent("protocols.implementations.VSOnePhaseCommitProtocol"); - registerEvent("protocols.implementations.VSPingPongProtocol"); - registerEvent("protocols.implementations.VSReliableMulticastProtocol"); - registerEvent("protocols.implementations.VSTwoPhaseCommitProtocol"); - - /* 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 serverObject = classLoader.newInstance(protocolClassname); - Object clientObject = classLoader.newInstance(protocolClassname); - - if (clientObject instanceof protocols.VSAbstractProtocol && - serverObject instanceof protocols.VSAbstractProtocol) { - - protocols.VSAbstractProtocol serverProtocol = - (protocols.VSAbstractProtocol) serverObject; - protocols.VSAbstractProtocol clientProtocol = - (protocols.VSAbstractProtocol) clientObject; - - serverProtocol.onServerInit(); - clientProtocol.onClientInit(); - - if (!serverProtocol.isEmpty() || !clientProtocol.isEmpty()) - editableProtocolsClassnames.add(protocolClassname); - - if (!serverProtocol.isEmpty()) { - ArrayList<String> variables = new ArrayList<String>(); - variables.addAll(serverProtocol.getAllFullKeys()); - serverVariables.put(protocolClassname, variables); - } - - if (!clientProtocol.isEmpty()) { - ArrayList<String> variables = new ArrayList<String>(); - variables.addAll(clientProtocol.getAllFullKeys()); - clientVariables.put(protocolClassname, variables); - } - - if (serverProtocol.hasOnServerStart()) - isOnServerStartProtocol.put(protocolClassname, - new Boolean(true)); - } - } - } - - /** - * Gets the editable protocols classnames. - * - * @return the editable protocols classnames - */ - public static ArrayList<String> getEditableProtocolsClassnames() { - return editableProtocolsClassnames; - } - - /** - * Gets the protocols server variable names. - * - * @return The variable names - */ - public static ArrayList<String> getProtocolServerVariables( - String protocolClassname) { - return serverVariables.get(protocolClassname); - } - - /** - * Gets the protocols server variable names. - * - * @return The variable names - */ - public static ArrayList<String> getProtocolClientVariables( - String protocolClassname) { - return clientVariables.get(protocolClassname); - } - - /** - * Gets the protocol names. - * - * @return the protocol names - */ - public static Vector<String> getProtocolNames() { - Set<String> set = eventClassnamesByNames.keySet(); - Vector<String> vector = new Vector<String>(); - - for (String eventName : set) - if (getClassnameByEventname(eventName).startsWith( - "protocols.implementations")) - vector.add(eventName); - - Collections.sort(vector); - - return vector; - } - - /** - * Gets the protocol classnames. - * - * @return the protocol classnames - */ - public static Vector<String> getProtocolClassnames() { - ArrayList<String> shortnames = new ArrayList<String>(); - shortnames.addAll(eventClassnamesByShortnames.keySet()); - Collections.sort(shortnames); - Vector<String> vector = new Vector<String>(); - - for (String eventShortname : shortnames) { - String eventClassname = getClassnameByShortname(eventShortname); - if (eventClassname.startsWith("protocols.implementations")) - vector.add(eventClassname); - } - - return vector; - } - - /** - * Gets the non protocol names. - * - * @return the non protocol names - */ - public static Vector<String> getNonProtocolNames() { - Set<String> set = eventClassnamesByNames.keySet(); - Vector<String> vector = new Vector<String>(); - - for (String eventName : set) - if (getClassnameByEventname(eventName).startsWith( - "events.implementations")) - vector.add(eventName); - - Collections.sort(vector); - - return vector; - } - - /** - * Gets the non protocol classnames. - * - * @return the non protocol classnames - */ - public static Vector<String> getNonProtocolClassnames() { - Set<String> set = eventNamesByClassnames.keySet(); - Vector<String> vector = new Vector<String>(); - - for (String eventClassname : set) - if (eventClassname.startsWith("events.implementations")) - vector.add(eventClassname); - - Collections.sort(vector); - - return vector; - } - - /** - * Gets the classname. - * - * @param eventName the event name - * - * @return the classname - */ - public static String getClassnameByEventname(String eventName) { - return eventClassnamesByNames.get(eventName); - } - - /** - * Gets the name. - * - * @param eventClassname the event classname - * - * @return the name - */ - public static String getNameByClassname(String eventClassname) { - return eventNamesByClassnames.get(eventClassname); - } - - /** - * Gets the shortname. - * - * @param eventClassname the event classname - * - * @return the shortname - */ - public static String getShortnameByClassname(String eventClassname) { - return eventShortnamesByClassnames.get(eventClassname); - } - - /** - * Gets the classname. - * - * @param eventShortname the event shortname - * - * @return the shortname - */ - public static String getClassnameByShortname(String eventShortname) { - return eventClassnamesByShortnames.get(eventShortname); - } - - /** - * Checks if the protocol uses onServerStart or onClientStart - * - * @param protocolClassname the protocol's classname - * - * @return true if onServerStart, false if onClientStart - */ - public static boolean isOnServerStartProtocol(String protocolClassname) { - if (isOnServerStartProtocol.containsKey(protocolClassname)) { - Boolean bool = isOnServerStartProtocol.get(protocolClassname); - return bool.booleanValue(); - } - - return false; - } - - /** - * Creates the event instance by classname. - * - * @param eventClassname the event classname - * @param process the process - * - * @return An instance of the event classname, if exists. Else null. - */ - public static VSAbstractEvent createEventInstanceByClassname( - String eventClassname, VSInternalProcess process) { - Object protocolObj = new VSClassLoader().newInstance(eventClassname); - - if (protocolObj instanceof VSAbstractEvent) { - VSAbstractEvent event = (VSAbstractEvent) protocolObj; - event.init(process); - return event; - } - - return null; - } - - /** - * Creates the event instance by name. - * - * @param eventName the event name - * @param process the process - * - * @return An instance of the event, if exists. Else null. - */ - public static VSAbstractEvent createEventInstanceByName(String eventName, - VSInternalProcess process) { - return createEventInstanceByClassname( - eventClassnamesByNames.get(eventName), process); - } - - /** - * Registers an event. Use the language settings of VSPrefs. - * - * @param eventClassname the event classname - */ - private static void registerEvent(String eventClassname) { - String eventName = - prefs.getString("lang.en." + eventClassname); - String eventShortname = - prefs.getString("lang.en." + eventClassname + ".short"); - registerEvent(eventClassname, eventName, eventShortname); - } - - /** - * Registers an event. - * - * @param eventClassname the event classname - * @param eventName the event name - */ - private static void registerEvent(String eventClassname, String eventName) { - registerEvent(eventClassname, eventName, null); - } - - /** - * Registers an 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; - - eventNamesByClassnames.put(eventClassname, eventName); - eventShortnamesByClassnames.put(eventClassname, eventShortname); - eventClassnamesByNames.put(eventName, eventClassname); - eventClassnamesByShortnames.put(eventShortname, eventClassname); - } -} diff --git a/sources/events/implementations/VSProcessCrashEvent.java b/sources/events/implementations/VSProcessCrashEvent.java deleted file mode 100644 index 382906b..0000000 --- a/sources/events/implementations/VSProcessCrashEvent.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * VS-Simulator (http://vs-sim.buetow.org) - * Copyright (c) 2008 - 2009 by Dipl.-Inform. (FH) Paul C. Buetow - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events.implementations; - -import events.*; -import simulator.*; - -/** - * The class VSProcessCrashEvent. This event makes a process to crash. - * - * @author Paul C. Buetow - */ -public class VSProcessCrashEvent extends VSAbstractEvent - implements VSCopyableEvent { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /* (non-Javadoc) - * @see events.VSCopyableEvent#initCopy(events.VSAbstractEvent) - */ - public void initCopy(VSAbstractEvent copy) { - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onInit() - */ - public void onInit() { - setClassname(getClass().toString()); - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#createShortname()() - */ - protected String createShortname(String savedShortname) { - return VSMain.prefs.getString("lang.en.process.crash"); - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onStart() - */ - public void onStart() { - if (!process.isCrashed()) { - process.isCrashed(true); - log(prefs.getString("lang.en.crashed")); - } - } -} diff --git a/sources/events/implementations/VSProcessRecoverEvent.java b/sources/events/implementations/VSProcessRecoverEvent.java deleted file mode 100644 index e7c87db..0000000 --- a/sources/events/implementations/VSProcessRecoverEvent.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * VS-Simulator (http://vs-sim.buetow.org) - * Copyright (c) 2008 - 2009 by Dipl.-Inform. (FH) Paul C. Buetow - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events.implementations; - -import events.*; -import simulator.*; - -/** - * The class VSProcessRecoverEvent. This event makes a process to recover if - * it is crashed. - * - * @author Paul C. Buetow - */ -public class VSProcessRecoverEvent extends VSAbstractEvent - implements VSCopyableEvent { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /* (non-Javadoc) - * @see events.VSCopyableEvent#initCopy(events.VSAbstractEvent) - */ - public void initCopy(VSAbstractEvent copy) { - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onInit() - */ - public void onInit() { - setClassname(getClass().toString()); - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#createShortname()() - */ - protected String createShortname(String savedShortname) { - return VSMain.prefs.getString("lang.en.process.recover"); - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onStart() - */ - public void onStart() { - if (process.isCrashed()) { - process.isCrashed(false); - log(prefs.getString("lang.en.recovered")); - } - } -} diff --git a/sources/events/internal/VSAbstractInternalEvent.java b/sources/events/internal/VSAbstractInternalEvent.java deleted file mode 100644 index ae0e2b8..0000000 --- a/sources/events/internal/VSAbstractInternalEvent.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * VS-Simulator (http://vs-sim.buetow.org) - * Copyright (c) 2008 - 2009 by Dipl.-Inform. (FH) Paul C. Buetow - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events.internal; - -import java.io.*; - -import events.VSAbstractEvent; -import serialize.VSSerialize; - -/** - * The class VSAbstractInternalEvent, this class if for destinguishing between - * internal and non-internal events. Internal usage only. - * - * @author Paul C. Buetow - */ -abstract public class VSAbstractInternalEvent extends VSAbstractEvent { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /* (non-Javadoc) - * @see events.VSAbstractEvent#createShortname()() - */ - protected String createShortname(String savedShortname) { - return savedShortname; - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#serialize(serialize.VSSerialize, - * java.io.ObjectOutputStream) - */ - public synchronized void serialize(VSSerialize serialize, - ObjectOutputStream objectOutputStream) - throws IOException { - super.serialize(serialize, objectOutputStream); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, - * java.io.ObjectInputStream) - */ - @SuppressWarnings("unchecked") - public synchronized void deserialize(VSSerialize serialize, - ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - super.deserialize(serialize, objectInputStream); - - if (VSSerialize.DEBUG) - System.out.println("Deserializing: VSAbstractInternalEvent"); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - } -} diff --git a/sources/events/internal/VSMessageReceiveEvent.java b/sources/events/internal/VSMessageReceiveEvent.java deleted file mode 100644 index ab8c929..0000000 --- a/sources/events/internal/VSMessageReceiveEvent.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events.internal; - -//import java.io.*; - -import core.VSMessage; -import protocols.VSAbstractProtocol; -import serialize.VSNotSerializable; - -/** - * The class VSMessageReceiveEvent, this event is used if a process receives - * a message. - * - * @author Paul C. Buetow - */ -public class VSMessageReceiveEvent extends VSAbstractInternalEvent - implements VSNotSerializable { - /** The serioal version uid */ - private static final long serialVersionUID = 1L; - - /** The message. */ - private VSMessage message; - - /** - * Instantiates a new message receive event. - * - * @param message the message - */ - public VSMessageReceiveEvent(VSMessage message) { - this.message = message; - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onInit() - */ - public void onInit() { - setClassname(getClass().toString()); - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onStart() - */ - public void onStart() { - boolean onlyRelevantMessages = process.getPrefs().getBoolean( - "sim.messages.relevant"); - - //String eventName = message.getName(); - String protocolClassname = message.getProtocolClassname(); - - if (onlyRelevantMessages && !isRelevantMessage()) - return; - - Object protocolObj = null; - - if (process.objectExists(protocolClassname)) - protocolObj = process.getObject(protocolClassname); - - process.updateLamportTime(message.getLamportTime()+1); - process.updateVectorTime(message.getVectorTime()); - - StringBuffer buffer = new StringBuffer(); - buffer.append(prefs.getString("lang.en.message.recv")); - buffer.append("; "); - buffer.append(message);; - log(buffer.toString()); - - if (protocolObj != null) - ((VSAbstractProtocol) protocolObj).onMessageRecvStart(message); - } - - /** - * Checks if the message delivering is relevant. - * - * @return true, if relevant - */ - public boolean isRelevantMessage() { - String protocolClassname = message.getProtocolClassname(); - Object protocolObj = null; - - if (process.objectExists(protocolClassname)) - protocolObj = process.getObject(protocolClassname); - else - return false; - - if (!((VSAbstractProtocol) protocolObj).isRelevantMessage(message)) - return false; - - return true; - } -} diff --git a/sources/events/internal/VSProtocolEvent.java b/sources/events/internal/VSProtocolEvent.java deleted file mode 100644 index 92af81e..0000000 --- a/sources/events/internal/VSProtocolEvent.java +++ /dev/null @@ -1,199 +0,0 @@ -/* - * VS-Simulator (http://vs-sim.buetow.org) - * Copyright (c) 2008 - 2009 by Dipl.-Inform. (FH) Paul C. Buetow - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events.internal; - -import java.io.*; - -import core.VSInternalProcess; -import events.*; -import protocols.VSAbstractProtocol; -import serialize.VSSerialize; - -/** - * The class VSProtocolEvent, this event is used if a protocol (server or - * client part) of a process gets enabled or disabled, an object of this class - * can be for 4 different purporses! Activation of the client protocol, - * deactivation of the client protocol, activation of the server protocol, - * deactivation of the server protocol. - * - * @author Paul C. Buetow - */ -public class VSProtocolEvent extends VSAbstractInternalEvent - implements VSCopyableEvent { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The protocol classname. */ - private String protocolClassname; - - /** The event is a client protocol if true. Else it is a server protocol */ - private boolean isClientProtocol; - - /** The event is a protocol activation if true. Else it is a deactivation */ - private boolean isProtocolActivation; - - /* (non-Javadoc) - * @see events.VSCopyableEvent#initCopy(events.VSAbstractEvent) - */ - public void initCopy(VSAbstractEvent copy) { - VSProtocolEvent protocolEventCopy = (VSProtocolEvent) copy; - protocolEventCopy.isClientProtocol(isClientProtocol); - protocolEventCopy.isProtocolActivation(isProtocolActivation); - protocolEventCopy.setProtocolClassname(protocolClassname); - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onInit() - */ - public void onInit() { - setClassname(getClass().toString()); - } - - /** - * Sets if it is a client protocol activation/deactivation. - * - * @param isClientProtocol the event is client protocol if true. the event - * is a server protocol if false. - */ - public void isClientProtocol(boolean isClientProtocol) { - this.isClientProtocol = isClientProtocol; - } - - /** - * Checks if it is a client protocol activation/deactivation. - * - * @return the event is client protocol if true. the event - * is a server protocol if false. - */ - public boolean isClientProtocol() { - return isClientProtocol; - } - - /** - * Sets if it is protocol activation. - * - * @param isProtocolActivation true, if it is a protocol activation. false, - * if it is a protocol deactivation. - */ - public void isProtocolActivation(boolean isProtocolActivation) { - this.isProtocolActivation = isProtocolActivation; - } - - /** - * Checks if it is protocol activation. - * - * @return true, if it is a protocol activation. false, if it is a protocol - * deactivation. - */ - 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.VSAbstractEvent#onStart() - */ - public void onStart() { - VSInternalProcess internalProcess = (VSInternalProcess) process; - VSAbstractProtocol protocol = - internalProcess.getProtocolObject(protocolClassname); - - if (isClientProtocol) - protocol.isClient(isProtocolActivation); - else - protocol.isServer(isProtocolActivation); - - StringBuffer buffer = new StringBuffer(); - buffer.append(VSRegisteredEvents.getShortnameByClassname( - protocolClassname)); - - buffer.append(" "); - buffer.append(isClientProtocol - ? prefs.getString("lang.en.client") - : prefs.getString("lang.en.server")); - - buffer.append(" "); - buffer.append(isProtocolActivation - ? prefs.getString("lang.en.activated") - : prefs.getString("lang.en.deactivated")); - - log(buffer.toString()); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#serialize(serialize.VSSerialize, - * java.io.ObjectOutputStream) - */ - public synchronized void serialize(VSSerialize serialize, - ObjectOutputStream objectOutputStream) - throws IOException { - super.serialize(serialize, objectOutputStream); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - - objectOutputStream.writeObject(protocolClassname); - objectOutputStream.writeObject(new Boolean(isClientProtocol)); - objectOutputStream.writeObject(new Boolean(isProtocolActivation)); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, - * java.io.ObjectInputStream) - */ - @SuppressWarnings("unchecked") - public synchronized void deserialize(VSSerialize serialize, - ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - super.deserialize(serialize, objectInputStream); - - if (VSSerialize.DEBUG) - System.out.println("Deserializing: VSProtocolEvent"); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - - protocolClassname = (String) objectInputStream.readObject(); - - isClientProtocol = ((Boolean) - objectInputStream.readObject()).booleanValue();; - isProtocolActivation = ((Boolean) - objectInputStream.readObject()).booleanValue();; - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - } -} diff --git a/sources/events/internal/VSProtocolScheduleEvent.java b/sources/events/internal/VSProtocolScheduleEvent.java deleted file mode 100644 index 83b5505..0000000 --- a/sources/events/internal/VSProtocolScheduleEvent.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2008 Paul C. Buetow, vs@dev.buetow.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * All icons of the icons/ folder are under a Creative Commons - * Attribution-Noncommercial-Share Alike License a CC-by-nc-sa. - * - * The icon's homepage is http://code.google.com/p/ultimate-gnome/ - */ - -package events.internal; - -import java.io.*; - -//import events.*; -import protocols.VSAbstractProtocol; -import serialize.*; - -/** - * The class VSProtocolScheduleEvent, this event is used if a protocol (which - * is a subclass of VSAbstractProtocol) reschedules itself to run again on a - * specific time. - * - * @author Paul C. Buetow - */ -public class VSProtocolScheduleEvent extends VSAbstractInternalEvent - implements VSNotSerializable { - /** The serial version uid */ - private static final long serialVersionUID = 1L; - - /** The event is a server protocol schedule. */ - private boolean isServerSchedule; /* true = server, false = client */ - - /** The reference to the protocol object to schedule. */ - private VSAbstractProtocol protocol; - - /** - * Create a VSProtocolScheduleEvent object - * - * @param protocol the protocol - * @param isServerSchedule the event is a client protocol schedule if - * false, else server schedule - */ - public VSProtocolScheduleEvent(VSAbstractProtocol protocol, - boolean isServerSchedule) { - this.protocol = protocol; - this.isServerSchedule = isServerSchedule; - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onInit() - */ - public void onInit() { - setClassname(getClass().toString()); - } - - /** - * Sets if it is client protocol schedule. - * - * @param isServerSchedule false, if the event is a client protocol - * schedule. true, if server. - */ - public void isServerSchedule(boolean isServerSchedule) { - this.isServerSchedule = isServerSchedule; - } - - /** - * Sets if it is client protocol schedule. - * - * @return false, if the event is a client protocol schedule. true, if - * server. - */ - public boolean isServerSchedule() { - return isServerSchedule; - } - - /** - * Sets the protocol. - * - * @param protocol the protocol - */ - public void setProtocol(VSAbstractProtocol protocol) { - this.protocol = protocol; - } - - /** - * Gets the protocol. - * - * @return the protocol - */ - public VSAbstractProtocol getProtocol() { - return protocol; - } - - /* (non-Javadoc) - * @see events.VSAbstractEvent#onStart() - */ - public void onStart() { - if (isServerSchedule) - protocol.onServerScheduleStart(); - else - protocol.onClientScheduleStart(); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#serialize(serialize.VSSerialize, - * java.io.ObjectOutputStream) - */ - public synchronized void serialize(VSSerialize serialize, - ObjectOutputStream objectOutputStream) - throws IOException { - super.serialize(serialize, objectOutputStream); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - - /** For later backwards compatibility, to add more stuff */ - objectOutputStream.writeObject(new Boolean(false)); - } - - /* (non-Javadoc) - * @see serialize.VSSerializable#deserialize(serialize.VSSerialize, - * java.io.ObjectInputStream) - */ - @SuppressWarnings("unchecked") - public synchronized void deserialize(VSSerialize serialize, - ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - super.deserialize(serialize, objectInputStream); - - if (VSSerialize.DEBUG) - System.out.println("Deserializing: VSProtocolEvent"); - - /** For later backwards compatibility, to add more stuff */ - objectInputStream.readObject(); - - } -} |
