From 97a3a4f07cdc8437f73f4270b237e85c7739a6be Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 27 May 2008 17:23:45 +0000 Subject: client and server variables are now separate in the editor. --- sources/events/VSAbstractEvent.java | 18 ++++-- sources/events/VSRegisteredEvents.java | 72 +++++++++++++++++----- .../events/implementations/ProcessCrashEvent.java | 2 +- .../implementations/ProcessRecoverEvent.java | 2 +- sources/events/internal/MessageReceiveEvent.java | 2 +- sources/events/internal/ProtocolEvent.java | 2 +- sources/events/internal/ProtocolScheduleEvent.java | 2 +- 7 files changed, 76 insertions(+), 24 deletions(-) (limited to 'sources/events') diff --git a/sources/events/VSAbstractEvent.java b/sources/events/VSAbstractEvent.java index 9562233..27be457 100644 --- a/sources/events/VSAbstractEvent.java +++ b/sources/events/VSAbstractEvent.java @@ -14,10 +14,10 @@ abstract public class VSAbstractEvent extends VSPrefs { private static final long serialVersionUID = 1L; /** The prefs. */ - protected VSPrefs prefs; + public VSPrefs prefs; /** The process. */ - protected VSProcess process; + public VSProcess process; /** The event shortname. */ private String eventShortname; @@ -26,7 +26,7 @@ abstract public class VSAbstractEvent extends VSPrefs { private String eventClassname; /** - * Inits the. + * Inits the event. * * @param process the process */ @@ -34,6 +34,14 @@ abstract public class VSAbstractEvent extends VSPrefs { this.process = process; this.prefs = process.getPrefs(); + init(); + } + + /** + * Inits the event. + * + */ + public void init() { onInit(); } @@ -42,7 +50,7 @@ abstract public class VSAbstractEvent extends VSPrefs { * * @param eventClassname the new classname */ - protected final void setClassname(String eventClassname) { + public final void setClassname(String eventClassname) { if (eventClassname.startsWith("class ")) eventClassname = eventClassname.substring(6); @@ -120,7 +128,7 @@ abstract public class VSAbstractEvent extends VSPrefs { /** * On init. */ - abstract protected void onInit(); + abstract public void onInit(); /** * On start. diff --git a/sources/events/VSRegisteredEvents.java b/sources/events/VSRegisteredEvents.java index 81b68dc..997cc19 100644 --- a/sources/events/VSRegisteredEvents.java +++ b/sources/events/VSRegisteredEvents.java @@ -17,16 +17,26 @@ public final class VSRegisteredEvents { private static final long serialVersionUID = 1L; /** The event classnames. */ - private static HashMap eventClassnames; + private static HashMap eventClassnames = + new HashMap(); /** The event shortnames. */ - private static HashMap eventShortnames; + private static HashMap eventShortnames = + new HashMap(); /** The event names. */ - private static HashMap eventNames; + private static HashMap eventNames = + new HashMap(); /** The editable protocols classnames. */ - private static ArrayList editableProtocolsClassnames; + private static ArrayList editableProtocolsClassnames = + new ArrayList(); + + private static HashMap> clientVariables = + new HashMap>(); + + private static HashMap> serverVariables = + new HashMap>(); /** The prefs. */ private static VSPrefs prefs; @@ -38,10 +48,6 @@ public final class VSRegisteredEvents { */ public static void init(VSPrefs prefs_) { prefs = prefs_; - eventNames = new HashMap(); - eventShortnames = new HashMap(); - eventClassnames = new HashMap(); - editableProtocolsClassnames = new ArrayList(); registerEvent("events.implementations.ProcessCrashEvent", "Prozessabsturz", null); registerEvent("events.implementations.ProcessRecoverEvent", "Prozesswiederbelebung", null); @@ -57,16 +63,36 @@ public final class VSRegisteredEvents { /* Make dummy objects of each protocol, to see if they contain VSPrefs values to edit */ Vector protocolClassnames = getProtocolClassnames(); VSClassLoader classLoader = new VSClassLoader(); + for (String protocolClassname : protocolClassnames) { - Object object = classLoader.newInstance(protocolClassname); - if (object instanceof protocols.VSAbstractProtocol) { - protocols.VSAbstractProtocol protocol = (protocols.VSAbstractProtocol) object; - if (!protocol.isEmpty()) + 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 variables = new ArrayList(); + variables.addAll(serverProtocol.getAllFullKeys()); + serverVariables.put(protocolClassname, variables); + } + + if (!clientProtocol.isEmpty()) { + ArrayList variables = new ArrayList(); + variables.addAll(clientProtocol.getAllFullKeys()); + clientVariables.put(protocolClassname, variables); + } } } - - //Collections.sort(editableProtocolsClassnames); } /** @@ -78,6 +104,24 @@ public final class VSRegisteredEvents { return editableProtocolsClassnames; } + /** + * Gets the protocols server variable names + * + * @return The variable names + */ + public static ArrayList getProtocolServerVariables(String protocolClassname) { + return serverVariables.get(protocolClassname); + } + + /** + * Gets the protocols server variable names + * + * @return The variable names + */ + public static ArrayList getProtocolClientVariables(String protocolClassname) { + return clientVariables.get(protocolClassname); + } + /** * Gets the protocol names. * diff --git a/sources/events/implementations/ProcessCrashEvent.java b/sources/events/implementations/ProcessCrashEvent.java index 873debc..d0db00e 100644 --- a/sources/events/implementations/ProcessCrashEvent.java +++ b/sources/events/implementations/ProcessCrashEvent.java @@ -14,7 +14,7 @@ public class ProcessCrashEvent extends VSAbstractEvent { /* (non-Javadoc) * @see events.VSAbstractEvent#onInit() */ - protected void onInit() { + public void onInit() { setClassname(getClass().toString()); } diff --git a/sources/events/implementations/ProcessRecoverEvent.java b/sources/events/implementations/ProcessRecoverEvent.java index 9d85f13..6ba4276 100644 --- a/sources/events/implementations/ProcessRecoverEvent.java +++ b/sources/events/implementations/ProcessRecoverEvent.java @@ -15,7 +15,7 @@ public class ProcessRecoverEvent extends VSAbstractEvent { /* (non-Javadoc) * @see events.VSAbstractEvent#onInit() */ - protected void onInit() { + public void onInit() { setClassname(getClass().toString()); } diff --git a/sources/events/internal/MessageReceiveEvent.java b/sources/events/internal/MessageReceiveEvent.java index f86b05f..60538df 100644 --- a/sources/events/internal/MessageReceiveEvent.java +++ b/sources/events/internal/MessageReceiveEvent.java @@ -29,7 +29,7 @@ public class MessageReceiveEvent extends VSAbstractEvent { /* (non-Javadoc) * @see events.VSAbstractEvent#onInit() */ - protected void onInit() { + public void onInit() { setClassname(getClass().toString()); } diff --git a/sources/events/internal/ProtocolEvent.java b/sources/events/internal/ProtocolEvent.java index 7001394..108bfb8 100644 --- a/sources/events/internal/ProtocolEvent.java +++ b/sources/events/internal/ProtocolEvent.java @@ -25,7 +25,7 @@ public class ProtocolEvent extends VSAbstractEvent { /* (non-Javadoc) * @see events.VSAbstractEvent#onInit() */ - protected void onInit() { + public void onInit() { setClassname(getClass().toString()); } diff --git a/sources/events/internal/ProtocolScheduleEvent.java b/sources/events/internal/ProtocolScheduleEvent.java index 12fbd7b..bbb776c 100644 --- a/sources/events/internal/ProtocolScheduleEvent.java +++ b/sources/events/internal/ProtocolScheduleEvent.java @@ -33,7 +33,7 @@ public class ProtocolScheduleEvent extends VSAbstractEvent { /* (non-Javadoc) * @see events.VSAbstractEvent#onInit() */ - protected void onInit() { + public void onInit() { setClassname(getClass().toString()); } -- cgit v1.2.3