Permalink
Browse files

Added abstract plugin impl. Reworked plugin presets.

  • Loading branch information...
sebinside committed Sep 12, 2018
1 parent ccf88a7 commit ec5842ea7d5fe947b33b9b02c14d65cd59747458
@@ -2,6 +2,7 @@
<configuration default="false" name="[Simple] Rebuild plugins and Run ChatOverflow" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="org.codeoverflow.chatoverflow.Launcher" />
<module name="ChatOverflow" />
<option name="PROGRAM_PARAMETERS" value="runPlugins -p halloandre" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="org.codeoverflow.chatoverflow.service.*" />
@@ -59,7 +59,7 @@ class PluginInstanceRegistry(pluginManager: PluginManager) {
// Always escape!
if (!pluginInstances.contains(instanceName)) {
logger warn s"Plugin '$instanceName' was not loaded. Unable to start."
logger warn s"Instance '$instanceName' was not loaded. Unable to start."
} else {
logger info s"Starting plugin '$instanceName' in new thread!"
val loadedPlugin = pluginInstances(instanceName)
@@ -75,7 +75,19 @@ class PluginInstanceRegistry(pluginManager: PluginManager) {
// TODO: Manage all threads, passing arguments, maybe using actors rather than threads
new Thread(() => {
try {
loadedPlugin.start()
// Execute plugin setup
loadedPlugin.setup()
// Execute loop, if an interval is set
if (loadedPlugin.getLoopInterval > 0) {
while (true) {
loadedPlugin.loop()
Thread.sleep(loadedPlugin.getLoopInterval)
}
}
// FIXME: shutdown method should work
} catch {
case e: AbstractMethodError => logger.error(s"Plugin '$instanceName' just crashed. Looks like a plugin version error.", e)
case e: Exception => logger.error(s"Plugin '$instanceName' just had an exception. Might be a plugin implementation fault.", e)
@@ -21,11 +21,11 @@ object IO {
val input = new TwitchChatInputImpl
input.setSourceConnector(serialized)
input.init()
requirement.setValue(input)
requirement.set(input)
requirement
}, {
requirement: Requirement[_] =>
requirement.asInstanceOf[Requirement[TwitchChatInputImpl]].getValue.getSourceIdentifier
requirement.asInstanceOf[Requirement[TwitchChatInputImpl]].get.getSourceIdentifier
})
)
@@ -36,11 +36,12 @@ object IO {
val requirement = requirements.output.twitchChat(id, null, false)
val output = new TwitchChatOutputImpl
output.setSourceConnector(serialized)
requirement.setValue(output)
output.init()
requirement.set(output)
requirement
}, {
requirement: Requirement[_] =>
requirement.asInstanceOf[Requirement[TwitchChatOutputImpl]].getValue.getSourceIdentifier
requirement.asInstanceOf[Requirement[TwitchChatOutputImpl]].get.getSourceIdentifier
})
)
@@ -49,11 +50,11 @@ object IO {
("java.lang.String", {
(requirements: Requirements, id: String, serialized: String) =>
val requirement = requirements.parameter.string(id, null, false)
requirement.setValue(serialized)
requirement.set(serialized)
requirement
}, {
requirement: Requirement[_] =>
requirement.asInstanceOf[Requirement[String]].getValue
requirement.asInstanceOf[Requirement[String]].get
})
)
}

0 comments on commit ec5842e

Please sign in to comment.