summaryrefslogtreecommitdiff
path: root/src/YalpServer/OutputPluginHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/YalpServer/OutputPluginHandler.java')
-rw-r--r--src/YalpServer/OutputPluginHandler.java55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/YalpServer/OutputPluginHandler.java b/src/YalpServer/OutputPluginHandler.java
new file mode 100644
index 0000000..4a12f2b
--- /dev/null
+++ b/src/YalpServer/OutputPluginHandler.java
@@ -0,0 +1,55 @@
+package YalpServer;
+
+import java.util.ArrayList;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.PropertyConfigurator;
+
+import YalpInterfaces.*;
+
+public class OutputPluginHandler {
+
+ private ArrayList<OutputPlugin> plugins;
+ private static int outputIds = 0;
+
+ private String log4jFile = "log4j_server.conf";
+
+ private static Logger logger =
+ Logger.getLogger("Yalp.Server.OutputPluginHandler");
+
+ public OutputPluginHandler() {
+ PropertyConfigurator.configureAndWatch(log4jFile);
+ logger.debug("OutputPluginHandler()");
+ plugins = new ArrayList<OutputPlugin>();
+ }
+
+ public PluginInfo addPlugin(OutputPlugin plugin)
+ {
+ logger.debug("addPlugin("+plugin.info.name+")");
+ plugin.info.id = outputIds++;
+ plugins.add(plugin);
+ return plugin.info;
+ }
+
+ public void control( OutputHolder ctlOutput, YalpErrorHolder err ) {
+
+ logger.debug("control()");
+
+ for( OutputPlugin plugin : plugins ) {
+ if( plugin.info.id == ctlOutput.value.id ) {
+ plugin.itf.control( ctlOutput, err );
+ return;
+ }
+ }
+
+ YalpError error = new YalpError();
+ error.descr = "output plugin not found";
+ error.msg = "selected output plugin is not available";
+ error.code = YalpErrorCode.ERROR_OUTPUT_PLUGIN_NA;
+ error.level = YalpErrorLevel.ERROR_LEVEL_ERROR;
+ err.value = error;
+
+ Output dummy = new Output();
+ ctlOutput.value = dummy;
+ }
+}