From a4b1007f1e4de9be18bfad1102c2d756fd2fec3a Mon Sep 17 00:00:00 2001 From: Tobias Haupenthal Date: Mon, 11 Mar 2013 19:06:08 +0100 Subject: [PATCH 1/2] Fixed bug in Node: Adding a plugin should add also add a reference to the node creator --- .../de/hsaugsburg/smas/node/SmasNode.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala b/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala index c0ac676..41897ca 100644 --- a/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala +++ b/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala @@ -123,6 +123,24 @@ abstract class SmasNode extends Serializable def registerPlugin(pluginName: String, plugin: SmasPlugin) = { pluginManager.registerPlugin(plugin, pluginName) + var result = true + + plugin.setSurroundingNode(node) + + if(pluginManager.registerPlugin(pluginName, plugin)){ + result = false + } + + /* Should registered plugin start automatically? + * + + if(!plugin.start) + { + log.warn("Plugin was not started: {}", plugin) + result = false + } + */ + result } def unregisterPlugin(plugin: String) = From bfd34c01464bb804bc5810e7a4e974041776191b Mon Sep 17 00:00:00 2001 From: Tobias Haupenthal Date: Mon, 11 Mar 2013 19:16:17 +0100 Subject: [PATCH 2/2] Node can now show all registered plugins. --- src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala | 2 ++ .../scala/de/hsaugsburg/smas/plugin/base/PluginManager.scala | 1 + 2 files changed, 3 insertions(+) diff --git a/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala b/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala index 41897ca..7ee710e 100644 --- a/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala +++ b/src/main/scala/de/hsaugsburg/smas/node/SmasNode.scala @@ -120,6 +120,8 @@ abstract class SmasNode extends Serializable me.getId } + def getAllRegisteredPlugins = pluginManager.getAllRegisteredPluginNames + def registerPlugin(pluginName: String, plugin: SmasPlugin) = { pluginManager.registerPlugin(plugin, pluginName) diff --git a/src/main/scala/de/hsaugsburg/smas/plugin/base/PluginManager.scala b/src/main/scala/de/hsaugsburg/smas/plugin/base/PluginManager.scala index 1cc3576..99f1477 100644 --- a/src/main/scala/de/hsaugsburg/smas/plugin/base/PluginManager.scala +++ b/src/main/scala/de/hsaugsburg/smas/plugin/base/PluginManager.scala @@ -28,6 +28,7 @@ trait PluginManager extends Serializable def registerPlugin(plugin: SmasPlugin, pluginName: String): Boolean def registerPlugin(pluginName: String, plugin: SmasPlugin): Boolean def unRegisterPlugin(pluginName: String): Boolean + def getAllRegisteredPluginNames: List[String] def getAmountOfPlugins: Int = pluginList.size def getAddressForPluginName(name: String): AddressBookEntry def startAllPlugins: Boolean