package plugin.controller;
import java.io.File;
import java.io.FileFilter;
import java.lang.reflect.Type;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Set;
import java.util.Vector;
import plugin.common.Plugin;
import plugin.communicationdata.taggedtypes.TaggedType;
import plugin.loader.PluginClassLoader;
import plugin.typeinterfaces.DataStreamFilter;
import plugin.typeinterfaces.PluginType;
import backend.controller.BackendLogger;
public class PluginController {
private BackendLogger logger = BackendLogger.getInstance();
// TEST
private File filterDir = new File("filters" + File.separatorChar + "color"
+ File.separatorChar);
private PluginClassLoader pluginLoader = new PluginClassLoader(new File[]{filterDir});
private static PluginController instance_ = new PluginController();
Hashtable<PluginType, Hashtable<String, Class<? extends Plugin>>> plugins;
private PluginController() {
}
public Plugin instatiate(PluginType type, String name) {
logger.info("trying to instatiate filter: " + name);
Plugin ret = null;
try {
ret = this.plugins.get(type).get(name).newInstance();
logger.info("instatiation successful");
} catch (InstantiationException e) {
logger.throwing(this.getClass().toString(), "instatiate()", e);
logger.severe("Plugin must implement empty constructor!!!");
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return ret;
}
public static PluginController getInstance() {
return instance_;
}
public void registerPlugin(PluginType type, Class<Plugin> plg) {
}
public Hashtable<Object, TaggedType[]> getPluginIO(Plugin toAdd) {
// TODO Auto-generated method stub
return null;
}
}