Author: nextgens
Date: 2008-03-11 14:07:50 +0000 (Tue, 11 Mar 2008)
New Revision: 18452
Added:
tags/Thaw/0.8.4/
tags/Thaw/0.8.4/src/thaw/core/Main.java
tags/Thaw/0.8.4/src/thaw/core/PluginManager.java
Removed:
tags/Thaw/0.8.4/src/thaw/core/Main.java
tags/Thaw/0.8.4/src/thaw/core/PluginManager.java
Log:
Release Thaw 0.8.4
Copied: tags/Thaw/0.8.4 (from rev 18449, trunk/apps/Thaw)
Deleted: tags/Thaw/0.8.4/src/thaw/core/Main.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Main.java 2008-03-11 03:58:25 UTC (rev 18449)
+++ tags/Thaw/0.8.4/src/thaw/core/Main.java 2008-03-11 14:07:50 UTC (rev 18452)
@@ -1,209 +0,0 @@
-package thaw.core;
-
-import java.util.Locale;
-
-import javax.swing.UIManager;
-import java.util.Vector;
-import java.util.Iterator;
-
-import java.util.zip.ZipFile;
-import java.util.zip.ZipEntry;
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-
-
-
-/**
- * Main class. Only used to display some informations and init the core.
- *
- * @author <a href="mailto:jflesch@???">Jerome Flesch</a>
- */
-public class Main {
-
- public final static int
- _major = 0,
- _minor = 8,
- _update = 3;
- public final static String
- _svnBuildNumber = "@custom@";
-
- public final static String
- VERSION = Main._major + "." + Main._minor + "." + Main._update + " r"+Main._svnBuildNumber;
-
-
- /**
- * Look & feel use by GUI front end
- */
- private static String lookAndFeel = null;
-
-
- /**
- * Locale (null = default)
- */
- private static String locale = null;
-
-
- private Main() {
-
- }
-
-
- /**
- * Used to start the program
- *
- * @param args "-?", "-help", "--help", "/?", "/help", "-lf lookandfeel"
- */
- public static void main(final String[] args) {
- Core core;
-
- Main.extractDeps();
-
- Main.parseCommandLine(args);
-
- if(Main.locale != null)
- I18n.setLocale(new Locale(Main.locale));
-
- core = new Core();
-
- /* we specify to the core what lnf to use */
- core.setLookAndFeel(Main.lookAndFeel);
-
- /* and we force it to refresh change it right now */
- if (Main.lookAndFeel != null)
- core.setTheme(Main.lookAndFeel);
-
- core.initAll();
- }
-
-
-
-
- /**
- * This method parses the command line arguments
- *
- * @param args the arguments
- */
- private static void parseCommandLine(final String[] args) {
-
- int count = 0;
-
- try {
- while (args.length > count) {
- if ("-?".equals( args[count] ) || "-help".equals( args[count] )
- || "--help".equals( args[count] )
- || "/?".equals( args[count] )
- || "/help".equals( args[count] )) {
- Main.showHelp();
- count++;
- } else if ("-lf".equals( args[count] )) {
- Main.lookAndFeel = args[count + 1];
- count = count + 2;
- } else if ("-lc".equals( args[count] )) {
- Main.locale = args[count + 1];
- count = count + 2;
- } else {
- Main.showHelp();
- }
- }
- } catch (final ArrayIndexOutOfBoundsException exception) {
- Main.showHelp();
- }
-
- }
-
- /**
- * This method shows a help message on the standard output and exits the
- * program.
- */
- private static void showHelp() {
-
- System.out.println("java -jar thaw.jar [-lf lookAndFeel]\n");
- System.out.println("-lf Sets the 'Look and Feel' will use.");
- System.out.println(" (overriden by the skins preferences)\n");
- System.out.println(" These ones are currently available:");
- Vector feels = thaw.plugins.ThemeSelector.getPossibleThemes();
-
- for (Iterator it = feels.iterator() ; it.hasNext(); ) {
- String str = (String)it.next();
-
- System.out.println(" " + str);
- }
- System.out.println("\n And this one is used by default:");
- System.out.println(" " + UIManager.getSystemLookAndFeelClassName() + "\n");
-
- System.out.println("\n-lc Sets the locale to use: 'en' for english,");
- System.out.println(" 'fr' for french, etc.");
- System.out.println(" see
http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt");
- System.out.println(" for the complete list");
-
- System.exit(0);
- }
-
-
- /**
- * need a non-static context
- */
- public void extractFileFromJar(String src, String dst) {
- try {
- String realHome = this.getClass().getProtectionDomain().
- getCodeSource().getLocation().toString();
-
- String home = java.net.URLDecoder.decode(realHome.substring(5), "UTF-8");
-
- Logger.info(this, "Extracting : "+realHome+" ; "+src+" ; "+dst);
-
- ZipFile jar = new ZipFile(home);
- ZipEntry entry = jar.getEntry(src);
-
- File jarFile = new File(dst);
-
-
- InputStream in = new BufferedInputStream(jar.getInputStream(entry));
- OutputStream out = new BufferedOutputStream(new FileOutputStream(jarFile));
-
- byte[] buffer = new byte[2048];
-
- int nBytes;
-
- while( (nBytes = in.read(buffer)) > 0) {
- out.write(buffer, 0, nBytes);
- }
-
- out.flush();
- out.close();
- in.close();
-
- return;
- } catch(java.io.IOException e) {
- Logger.warning(this, "Can't extract '"+src+"' because : "+e.toString());
- if (e.getCause() != null)
- Logger.warning(this, "Cause : "+e.getCause().toString());
- e.printStackTrace();
- }
-
- Logger.warning(this, "Will try to continue anyway");
- //System.exit(1);
- }
-
-
- public final static String[] DEPS = new String[] {
- "jmdns.jar",
- "hsqldb.jar",
- "BouncyCastle.jar"
- };
-
- public static void extractDeps() {
- Main main = new Main();
-
- /* we erase each time the files to be sure that they are always up to date */
- for (int i = 0 ; i < DEPS.length ; i++) {
- main.extractFileFromJar("lib/"+DEPS[i], DEPS[i]);
- }
- }
-
-}
-
Copied: tags/Thaw/0.8.4/src/thaw/core/Main.java (from rev 18451, trunk/apps/Thaw/src/thaw/core/Main.java)
===================================================================
--- tags/Thaw/0.8.4/src/thaw/core/Main.java (rev 0)
+++ tags/Thaw/0.8.4/src/thaw/core/Main.java 2008-03-11 14:07:50 UTC (rev 18452)
@@ -0,0 +1,209 @@
+package thaw.core;
+
+import java.util.Locale;
+
+import javax.swing.UIManager;
+import java.util.Vector;
+import java.util.Iterator;
+
+import java.util.zip.ZipFile;
+import java.util.zip.ZipEntry;
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+
+
+
+/**
+ * Main class. Only used to display some informations and init the core.
+ *
+ * @author <a href="mailto:jflesch@???">Jerome Flesch</a>
+ */
+public class Main {
+
+ public final static int
+ _major = 0,
+ _minor = 8,
+ _update = 4;
+ public final static String
+ _svnBuildNumber = "@custom@";
+
+ public final static String
+ VERSION = Main._major + "." + Main._minor + "." + Main._update + " r"+Main._svnBuildNumber;
+
+
+ /**
+ * Look & feel use by GUI front end
+ */
+ private static String lookAndFeel = null;
+
+
+ /**
+ * Locale (null = default)
+ */
+ private static String locale = null;
+
+
+ private Main() {
+
+ }
+
+
+ /**
+ * Used to start the program
+ *
+ * @param args "-?", "-help", "--help", "/?", "/help", "-lf lookandfeel"
+ */
+ public static void main(final String[] args) {
+ Core core;
+
+ Main.extractDeps();
+
+ Main.parseCommandLine(args);
+
+ if(Main.locale != null)
+ I18n.setLocale(new Locale(Main.locale));
+
+ core = new Core();
+
+ /* we specify to the core what lnf to use */
+ core.setLookAndFeel(Main.lookAndFeel);
+
+ /* and we force it to refresh change it right now */
+ if (Main.lookAndFeel != null)
+ core.setTheme(Main.lookAndFeel);
+
+ core.initAll();
+ }
+
+
+
+
+ /**
+ * This method parses the command line arguments
+ *
+ * @param args the arguments
+ */
+ private static void parseCommandLine(final String[] args) {
+
+ int count = 0;
+
+ try {
+ while (args.length > count) {
+ if ("-?".equals( args[count] ) || "-help".equals( args[count] )
+ || "--help".equals( args[count] )
+ || "/?".equals( args[count] )
+ || "/help".equals( args[count] )) {
+ Main.showHelp();
+ count++;
+ } else if ("-lf".equals( args[count] )) {
+ Main.lookAndFeel = args[count + 1];
+ count = count + 2;
+ } else if ("-lc".equals( args[count] )) {
+ Main.locale = args[count + 1];
+ count = count + 2;
+ } else {
+ Main.showHelp();
+ }
+ }
+ } catch (final ArrayIndexOutOfBoundsException exception) {
+ Main.showHelp();
+ }
+
+ }
+
+ /**
+ * This method shows a help message on the standard output and exits the
+ * program.
+ */
+ private static void showHelp() {
+
+ System.out.println("java -jar thaw.jar [-lf lookAndFeel]\n");
+ System.out.println("-lf Sets the 'Look and Feel' will use.");
+ System.out.println(" (overriden by the skins preferences)\n");
+ System.out.println(" These ones are currently available:");
+ Vector feels = thaw.plugins.ThemeSelector.getPossibleThemes();
+
+ for (Iterator it = feels.iterator() ; it.hasNext(); ) {
+ String str = (String)it.next();
+
+ System.out.println(" " + str);
+ }
+ System.out.println("\n And this one is used by default:");
+ System.out.println(" " + UIManager.getSystemLookAndFeelClassName() + "\n");
+
+ System.out.println("\n-lc Sets the locale to use: 'en' for english,");
+ System.out.println(" 'fr' for french, etc.");
+ System.out.println(" see
http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt");
+ System.out.println(" for the complete list");
+
+ System.exit(0);
+ }
+
+
+ /**
+ * need a non-static context
+ */
+ public void extractFileFromJar(String src, String dst) {
+ try {
+ String realHome = this.getClass().getProtectionDomain().
+ getCodeSource().getLocation().toString();
+
+ String home = java.net.URLDecoder.decode(realHome.substring(5), "UTF-8");
+
+ Logger.info(this, "Extracting : "+realHome+" ; "+src+" ; "+dst);
+
+ ZipFile jar = new ZipFile(home);
+ ZipEntry entry = jar.getEntry(src);
+
+ File jarFile = new File(dst);
+
+
+ InputStream in = new BufferedInputStream(jar.getInputStream(entry));
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(jarFile));
+
+ byte[] buffer = new byte[2048];
+
+ int nBytes;
+
+ while( (nBytes = in.read(buffer)) > 0) {
+ out.write(buffer, 0, nBytes);
+ }
+
+ out.flush();
+ out.close();
+ in.close();
+
+ return;
+ } catch(java.io.IOException e) {
+ Logger.warning(this, "Can't extract '"+src+"' because : "+e.toString());
+ if (e.getCause() != null)
+ Logger.warning(this, "Cause : "+e.getCause().toString());
+ e.printStackTrace();
+ }
+
+ Logger.warning(this, "Will try to continue anyway");
+ //System.exit(1);
+ }
+
+
+ public final static String[] DEPS = new String[] {
+ "jmdns.jar",
+ "hsqldb.jar",
+ "BouncyCastle.jar"
+ };
+
+ public static void extractDeps() {
+ Main main = new Main();
+
+ /* we erase each time the files to be sure that they are always up to date */
+ for (int i = 0 ; i < DEPS.length ; i++) {
+ main.extractFileFromJar("lib/"+DEPS[i], DEPS[i]);
+ }
+ }
+
+}
+
Deleted: tags/Thaw/0.8.4/src/thaw/core/PluginManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginManager.java 2008-03-11 03:58:25 UTC (rev 18449)
+++ tags/Thaw/0.8.4/src/thaw/core/PluginManager.java 2008-03-11 14:07:50 UTC (rev 18452)
@@ -1,275 +0,0 @@
-package thaw.core;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Vector;
-
-/**
- * Manages plugins :)
- */
-public class PluginManager {
- private final static String[] defaultPlugins = {
- "thaw.plugins.QueueWatcher",
- "thaw.plugins.FetchPlugin",
- "thaw.plugins.InsertPlugin",
- "thaw.plugins.StatusBar",
- "thaw.plugins.ThemeSelector",
- "thaw.plugins.Hsqldb",
- "thaw.plugins.IndexBrowser",
- "thaw.plugins.IndexExporter",
- "thaw.plugins.MiniFrost",
- "thaw.plugins.TransferLogs"
- };
-
- private final static String[] knownPlugins = {
- "thaw.plugins.PeerMonitor",
- "thaw.plugins.QueueWatcher",
- "thaw.plugins.FetchPlugin",
- "thaw.plugins.InsertPlugin",
- "thaw.plugins.StatusBar",
- "thaw.plugins.TrayIcon",
- "thaw.plugins.ThemeSelector",
- "thaw.plugins.Hsqldb",
- "thaw.plugins.Signatures",
- "thaw.plugins.WebOfTrust",
- "thaw.plugins.WebOfTrustViewer",
- "thaw.plugins.IndexBrowser",
- "thaw.plugins.IndexExporter",
- //"thaw.plugins.IndexTreeRebuilder",
- "thaw.plugins.MiniFrost",
- //"thaw.plugins.Restarter",
- "thaw.plugins.TransferLogs",
- "thaw.plugins.NodeConfigurator",
- "thaw.plugins.MDns",
- //"thaw.plugins.IndexWebGrapher",
- "thaw.plugins.SqlConsole",
- "thaw.plugins.LogConsole"
- };
-
- private Core core = null;
-
- // LinkedHashMap because I want to keep a predictible plugin order.
- private LinkedHashMap plugins = null; // String (pluginName) -> Plugin
-
- public final static Object pluginLock = new Object();
-
- /**
- * Need a ref to the core to pass it to the plugins (and to access config)
- */
- public PluginManager(final Core core) {
- this.core = core;
- plugins = new LinkedHashMap();
- }
-
-
- /**
- * Returns the whole loaded plugin list.
- */
- public LinkedHashMap getPlugins() {
- return plugins;
- }
-
-
- public static String[] getKnownPlugins() {
- return knownPlugins;
- }
-
-
- /**
- * Load plugin from config or from default list.
- * Reload if already loaded.
- */
- public boolean loadAndRunPlugins() {
- synchronized(pluginLock) {
- plugins = new LinkedHashMap();
-
- Vector pluginNames;
-
- if(core.getConfig().getPluginNames().size() == 0) {
- Logger.notice(this, "Loading default plugin list");
- /* Then we load the config with the default plugins */
- for(int i = 0 ; i < PluginManager.defaultPlugins.length ; i++) {
- core.getConfig().addPlugin(PluginManager.defaultPlugins[i]);
- }
- }
-
- /* we duplicate the vector to avoid collisions */
- /* (remember : plugins can load other plugins */
- pluginNames = new Vector(core.getConfig().getPluginNames());
-
- final Iterator pluginIt = pluginNames.iterator();
-
- final int progressJump = (100-40) / pluginNames.size();
-
- if (core.getSplashScreen() != null)
- core.getSplashScreen().setProgression(40);
-
- while(pluginIt.hasNext()) {
- final String pluginName = (String)pluginIt.next();
-
- if (core.getSplashScreen() != null)
- core.getSplashScreen().setProgressionAndStatus(core.getSplashScreen().getProgression()+progressJump,
- "Loading plugin '"+pluginName.replaceFirst("thaw.plugins.", "")+"' ...");
-
- if (loadPlugin(pluginName) == null) {
- Logger.notice(this, "Plugin alread loaded");
- } else {
- runPlugin(pluginName);
- }
- }
- }
-
- return true;
- }
-
-
- /**
- * Stop all plugins.
- */
- public boolean stopPlugins() {
- synchronized(pluginLock) {
- Iterator pluginIt;
-
- if (plugins == null) {
- Logger.error(this, "No plugin to stop ?!");
- return false;
- }
-
-
- pluginIt = plugins.values().iterator();
-
- while(pluginIt.hasNext()) {
- final Plugin plugin = (Plugin)pluginIt.next();
-
- try {
- Logger.info(this, "Stopping plugin '"+plugin.getClass().getName()+"'");
-
- if (plugin != null)
- plugin.stop();
- else
- Logger.error(this, "Plugin == null !?");
- } catch(final Exception e) {
- Logger.error(this, "Unable to stop the plugin "+
- "'"+plugin.getClass().getName()+"'"+
- ", because: "+e.toString());
- e.printStackTrace();
- }
- }
-
- return true;
- }
- }
-
- /**
- * Load a given plugin (without adding it to the config or running it).
- */
- public Plugin loadPlugin(final String className) {
- synchronized(pluginLock) {
- Plugin plugin = null;
-
- Logger.info(this, "Loading plugin: '"+className+"'");
-
- try {
- if ( plugins.get(className) != null) {
- Logger.debug(this, "loadPlugin(): Plugin '"+className+"' already loaded");
- return null;
- }
-
- //Logger.info(this, "Loading plugin '"+className+"'");
-
- plugin = (Plugin)Class.forName(className).newInstance();
-
- plugins.put(className, plugin);
-
- } catch(final Exception e) {
- Logger.error(this, "loadPlugin('"+className+"'): Exception: "+e);
- e.printStackTrace();
- return null;
- }
-
- return plugin;
- }
- }
-
-
- /**
- * Run a given plugin.
- */
- public boolean runPlugin(final String className) {
- synchronized(pluginLock) {
- Logger.info(this, "Starting plugin: '"+className+"'");
-
- try {
- Plugin plugin = (Plugin)plugins.get(className);
-
- javax.swing.ImageIcon icon;
-
- if (core.getSplashScreen() != null) {
- if ((icon = plugin.getIcon()) != null)
- core.getSplashScreen().addIcon(icon);
- else
- core.getSplashScreen().addIcon(thaw.gui.IconBox.add);
- }
-
- plugin.run(core);
-
- } catch(final Exception e) {
- Logger.error(this, "runPlugin('"+className+"'): Exception: "+e);
- e.printStackTrace();
- return false;
- }
-
- return true;
- }
- }
-
-
- /**
- * Stop a given plugin.
- */
- public boolean stopPlugin(final String className) {
- synchronized(pluginLock) {
- Logger.info(this, "Stopping plugin: '"+className+"'");
-
- try {
- ((Plugin)plugins.get(className)).stop();
-
- } catch(final Exception e) {
- Logger.error(this, "stopPlugin('"+className+"'): Exception: "+e);
- e.printStackTrace();
- return false;
- }
-
- return true;
- }
- }
-
-
- /**
- * Unload a given plugin (without adding it to the config or running it).
- */
- public boolean unloadPlugin(final String className) {
- synchronized(pluginLock) {
- try {
- if(plugins.get(className) == null) {
- Logger.notice(this, "unloadPlugin(): Plugin '"+className+"' already unloaded");
- return false;
- }
-
- plugins.remove(className);
- core.getConfig().removePlugin(className);
-
- } catch(final Exception e) {
- Logger.error(this, "unloadPlugin('"+className+"'): Exception: "+e);
- e.printStackTrace();
- return false;
- }
-
- return true;
- }
- }
-
- public Plugin getPlugin(final String className) {
- return (Plugin)plugins.get(className);
- }
-}
Copied: tags/Thaw/0.8.4/src/thaw/core/PluginManager.java (from rev 18450, trunk/apps/Thaw/src/thaw/core/PluginManager.java)
===================================================================
--- tags/Thaw/0.8.4/src/thaw/core/PluginManager.java (rev 0)
+++ tags/Thaw/0.8.4/src/thaw/core/PluginManager.java 2008-03-11 14:07:50 UTC (rev 18452)
@@ -0,0 +1,274 @@
+package thaw.core;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Vector;
+
+/**
+ * Manages plugins :)
+ */
+public class PluginManager {
+ private final static String[] defaultPlugins = {
+ "thaw.plugins.QueueWatcher",
+ "thaw.plugins.FetchPlugin",
+ "thaw.plugins.InsertPlugin",
+ "thaw.plugins.StatusBar",
+ "thaw.plugins.ThemeSelector",
+ "thaw.plugins.Hsqldb",
+ "thaw.plugins.IndexBrowser",
+ "thaw.plugins.IndexExporter",
+ "thaw.plugins.TransferLogs"
+ };
+
+ private final static String[] knownPlugins = {
+ "thaw.plugins.PeerMonitor",
+ "thaw.plugins.QueueWatcher",
+ "thaw.plugins.FetchPlugin",
+ "thaw.plugins.InsertPlugin",
+ "thaw.plugins.StatusBar",
+ "thaw.plugins.TrayIcon",
+ "thaw.plugins.ThemeSelector",
+ "thaw.plugins.Hsqldb",
+ "thaw.plugins.Signatures",
+ "thaw.plugins.WebOfTrust",
+ "thaw.plugins.WebOfTrustViewer",
+ "thaw.plugins.IndexBrowser",
+ "thaw.plugins.IndexExporter",
+ //"thaw.plugins.IndexTreeRebuilder",
+ "thaw.plugins.MiniFrost",
+ //"thaw.plugins.Restarter",
+ "thaw.plugins.TransferLogs",
+ "thaw.plugins.NodeConfigurator",
+ "thaw.plugins.MDns",
+ //"thaw.plugins.IndexWebGrapher",
+ "thaw.plugins.SqlConsole",
+ "thaw.plugins.LogConsole"
+ };
+
+ private Core core = null;
+
+ // LinkedHashMap because I want to keep a predictible plugin order.
+ private LinkedHashMap plugins = null; // String (pluginName) -> Plugin
+
+ public final static Object pluginLock = new Object();
+
+ /**
+ * Need a ref to the core to pass it to the plugins (and to access config)
+ */
+ public PluginManager(final Core core) {
+ this.core = core;
+ plugins = new LinkedHashMap();
+ }
+
+
+ /**
+ * Returns the whole loaded plugin list.
+ */
+ public LinkedHashMap getPlugins() {
+ return plugins;
+ }
+
+
+ public static String[] getKnownPlugins() {
+ return knownPlugins;
+ }
+
+
+ /**
+ * Load plugin from config or from default list.
+ * Reload if already loaded.
+ */
+ public boolean loadAndRunPlugins() {
+ synchronized(pluginLock) {
+ plugins = new LinkedHashMap();
+
+ Vector pluginNames;
+
+ if(core.getConfig().getPluginNames().size() == 0) {
+ Logger.notice(this, "Loading default plugin list");
+ /* Then we load the config with the default plugins */
+ for(int i = 0 ; i < PluginManager.defaultPlugins.length ; i++) {
+ core.getConfig().addPlugin(PluginManager.defaultPlugins[i]);
+ }
+ }
+
+ /* we duplicate the vector to avoid collisions */
+ /* (remember : plugins can load other plugins */
+ pluginNames = new Vector(core.getConfig().getPluginNames());
+
+ final Iterator pluginIt = pluginNames.iterator();
+
+ final int progressJump = (100-40) / pluginNames.size();
+
+ if (core.getSplashScreen() != null)
+ core.getSplashScreen().setProgression(40);
+
+ while(pluginIt.hasNext()) {
+ final String pluginName = (String)pluginIt.next();
+
+ if (core.getSplashScreen() != null)
+ core.getSplashScreen().setProgressionAndStatus(core.getSplashScreen().getProgression()+progressJump,
+ "Loading plugin '"+pluginName.replaceFirst("thaw.plugins.", "")+"' ...");
+
+ if (loadPlugin(pluginName) == null) {
+ Logger.notice(this, "Plugin alread loaded");
+ } else {
+ runPlugin(pluginName);
+ }
+ }
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Stop all plugins.
+ */
+ public boolean stopPlugins() {
+ synchronized(pluginLock) {
+ Iterator pluginIt;
+
+ if (plugins == null) {
+ Logger.error(this, "No plugin to stop ?!");
+ return false;
+ }
+
+
+ pluginIt = plugins.values().iterator();
+
+ while(pluginIt.hasNext()) {
+ final Plugin plugin = (Plugin)pluginIt.next();
+
+ try {
+ Logger.info(this, "Stopping plugin '"+plugin.getClass().getName()+"'");
+
+ if (plugin != null)
+ plugin.stop();
+ else
+ Logger.error(this, "Plugin == null !?");
+ } catch(final Exception e) {
+ Logger.error(this, "Unable to stop the plugin "+
+ "'"+plugin.getClass().getName()+"'"+
+ ", because: "+e.toString());
+ e.printStackTrace();
+ }
+ }
+
+ return true;
+ }
+ }
+
+ /**
+ * Load a given plugin (without adding it to the config or running it).
+ */
+ public Plugin loadPlugin(final String className) {
+ synchronized(pluginLock) {
+ Plugin plugin = null;
+
+ Logger.info(this, "Loading plugin: '"+className+"'");
+
+ try {
+ if ( plugins.get(className) != null) {
+ Logger.debug(this, "loadPlugin(): Plugin '"+className+"' already loaded");
+ return null;
+ }
+
+ //Logger.info(this, "Loading plugin '"+className+"'");
+
+ plugin = (Plugin)Class.forName(className).newInstance();
+
+ plugins.put(className, plugin);
+
+ } catch(final Exception e) {
+ Logger.error(this, "loadPlugin('"+className+"'): Exception: "+e);
+ e.printStackTrace();
+ return null;
+ }
+
+ return plugin;
+ }
+ }
+
+
+ /**
+ * Run a given plugin.
+ */
+ public boolean runPlugin(final String className) {
+ synchronized(pluginLock) {
+ Logger.info(this, "Starting plugin: '"+className+"'");
+
+ try {
+ Plugin plugin = (Plugin)plugins.get(className);
+
+ javax.swing.ImageIcon icon;
+
+ if (core.getSplashScreen() != null) {
+ if ((icon = plugin.getIcon()) != null)
+ core.getSplashScreen().addIcon(icon);
+ else
+ core.getSplashScreen().addIcon(thaw.gui.IconBox.add);
+ }
+
+ plugin.run(core);
+
+ } catch(final Exception e) {
+ Logger.error(this, "runPlugin('"+className+"'): Exception: "+e);
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+
+ /**
+ * Stop a given plugin.
+ */
+ public boolean stopPlugin(final String className) {
+ synchronized(pluginLock) {
+ Logger.info(this, "Stopping plugin: '"+className+"'");
+
+ try {
+ ((Plugin)plugins.get(className)).stop();
+
+ } catch(final Exception e) {
+ Logger.error(this, "stopPlugin('"+className+"'): Exception: "+e);
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+
+ /**
+ * Unload a given plugin (without adding it to the config or running it).
+ */
+ public boolean unloadPlugin(final String className) {
+ synchronized(pluginLock) {
+ try {
+ if(plugins.get(className) == null) {
+ Logger.notice(this, "unloadPlugin(): Plugin '"+className+"' already unloaded");
+ return false;
+ }
+
+ plugins.remove(className);
+ core.getConfig().removePlugin(className);
+
+ } catch(final Exception e) {
+ Logger.error(this, "unloadPlugin('"+className+"'): Exception: "+e);
+ e.printStackTrace();
+ return false;
+ }
+
+ return true;
+ }
+ }
+
+ public Plugin getPlugin(final String className) {
+ return (Plugin)plugins.get(className);
+ }
+}