package YalpServer; import java.util.ArrayList; import org.apache.log4j.Logger; import org.apache.log4j.PropertyConfigurator; import YalpInterfaces.*; public class OutputPluginHandler { private ArrayList 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(); } 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; } }