Skip to content
Snippets Groups Projects
Commit 63e61050 authored by Andrea Enrici's avatar Andrea Enrici
Browse files

Added PLUGIN_PKG entry in the config.xml file to specify the main package of the Nokia-TPT plugins

parent 6e2deffc
No related branches found
No related tags found
No related merge requests found
......@@ -150,6 +150,7 @@ public class ConfigurationTTool {
//public static String AttackOntologyWebsite = "";
// PLUGINS
public static String PLUGIN_PKG = "";
public static String PLUGIN_PATH = "";
public static String[] PLUGIN = new String[0];
//public static String PLUGIN_JAVA_CODE_GENERATOR = "";
......@@ -467,6 +468,7 @@ public class ConfigurationTTool {
// Plugins
sb.append("\nPlugins:\n");
sb.append("Plugin path: " + PLUGIN_PKG + "\n");
sb.append("Plugin path: " + PLUGIN_PATH + "\n");
/*sb.append("Plugin for java code generation: " + PLUGIN_JAVA_CODE_GENERATOR + "\n");
for (int i=0; i<PLUGIN_GRAPHICAL_COMPONENT.length; i++) {
......@@ -767,6 +769,10 @@ public class ConfigurationTTool {
if (nl.getLength() > 0)
ExternalCommand2(nl);
nl = doc.getElementsByTagName("PLUGIN_PKG");
if (nl.getLength() > 0)
PluginPkg(nl);
nl = doc.getElementsByTagName("PLUGIN_PATH");
if (nl.getLength() > 0)
PluginPath(nl);
......@@ -1488,6 +1494,16 @@ public class ConfigurationTTool {
}
}
private static void PluginPkg(NodeList nl) throws MalformedConfigurationException {
try {
Element elt = (Element)(nl.item(0));
PLUGIN_PKG = elt.getAttribute("data");
PluginManager.PLUGIN_PKG = PLUGIN_PKG;
} catch (Exception e) {
throw new MalformedConfigurationException(e.getMessage());
}
}
private static void PluginPath(NodeList nl) throws MalformedConfigurationException {
try {
Element elt = (Element)(nl.item(0));
......
......@@ -161,8 +161,9 @@ public class Plugin {
TraceManager.addDev("Loading plugin=" + path + java.io.File.separator + name);
URL[] urls = new URL[] { file.toURI().toURL() };
ClassLoader loader = new URLClassLoader(urls);
//TraceManager.addDev("Loader created");
c = loader.loadClass(_className);
//TraceManager.addDev("getClass() Loader created");
c = loader.loadClass( PluginManager.PLUGIN_PKG + "." + _className);
//TraceManager.addDev("getClass() class loaded");
if (c == null) {
return null;
}
......@@ -171,7 +172,9 @@ public class Plugin {
}
} catch (Exception e) {
//TraceManager.addDev("Exception when using plugin " + name + " with className=" + _className);
TraceManager.addDev( "getClass()\n" );
e.printStackTrace( System.out );
//TraceManager.addDev("Exception when using plugin " + name + " with className=" + _className);
return null;
}
......@@ -184,11 +187,12 @@ public class Plugin {
try {
if (c == null) {
file = new File(path + java.io.File.separator + name);
TraceManager.addDev("Loading plugin=" + path + java.io.File.separator + name);
//TraceManager.addDev("Loading plugin=" + path + java.io.File.separator + name);
URL[] urls = new URL[] { file.toURI().toURL() };
ClassLoader loader = new URLClassLoader(urls);
//TraceManager.addDev("Loader created");
c = loader.loadClass(_className);
c = loader.loadClass( PluginManager.PLUGIN_PKG + "." + _className);
//TraceManager.addDev( "Class loaded" );
if (c == null) {
return null;
}
......@@ -197,7 +201,8 @@ public class Plugin {
return c.getMethod(_methodName);
} catch (Exception e) {
//TraceManager.addDev("Exception when using plugin " + name + " with className=" + _className + " and method " + _methodName);
e.printStackTrace( System.out );
//TraceManager.addDev("Exception when using plugin " + name + " with className=" + _className + " and method " + _methodName);
return null;
}
......
......@@ -56,6 +56,7 @@ import java.awt.*;
public class PluginManager {
public static PluginManager pluginManager;
public static String PLUGIN_PATH = "";
public static String PLUGIN_PKG = "";
public ArrayList<Plugin> plugins;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment