Initialize the plugin manager. @throws Exception See other throws. @throws PluginLoadException When loading specific plugin crashes when loaded. @throws IOException When the plugin directory cannot be read from or created. @throws IllegalStateException When the plugin does not properly defi
()
| 51 | * When the plugin does not properly define a name. |
| 52 | */ |
| 53 | public void load() throws Exception { |
| 54 | PluginFolderSource source = new PluginFolderSource(); |
| 55 | // Collect plugin instances |
| 56 | Collection<Object> instances = loadPlugins(source); |
| 57 | for (Object instance : instances) { |
| 58 | if (instance instanceof BasePlugin) { |
| 59 | BasePlugin plugin = (BasePlugin) instance; |
| 60 | String name = plugin.getName(); |
| 61 | String version = plugin.getVersion(); |
| 62 | String className = instance.getClass().getName(); |
| 63 | BufferedImage icon = |
| 64 | source.getPluginIcons().get(source.getClassToPlugin().get(className)); |
| 65 | Log.info("Discovered plugin '{}-{}'", name, version); |
| 66 | // PlugFace already has its own internal storage of the plugin instances, |
| 67 | // but we want to control them a bit easier. So we'll keep a local reference. |
| 68 | addPlugin(name, plugin, icon); |
| 69 | } else { |
| 70 | Log.error("Class '{}' does not extend plugin!", instance.getClass().getName()); |
| 71 | } |
| 72 | } |
| 73 | // Done |
| 74 | if (!plugins.isEmpty()) |
| 75 | Log.info("Loaded {} plugins", plugins.size()); |
| 76 | } |
| 77 | |
| 78 | |
| 79 | /** |
no test coverage detected