private <T extends PluginConfig> List<T> getLatestPluginForLanguage(final PluginLanguage pluginLanguage) throws PluginConfigException { loadPluginsIfRequired(); final List<T> result = new LinkedList<T>(); for (final String pluginName : allPlugins.keySet()) { final T plugin = (T) allPlugins.get(pluginName).get(0); if (pluginLanguage != plugin.getPluginLanguage()) { continue; } result.add(plugin); } return result; }
@Override public int compare(final PluginConfig o1, final PluginConfig o2) { return -(o1.getVersion().compareTo(o2.getVersion())); } });
if (shouldStopPlugin) { try { logSafely(LogService.LOG_INFO, String.format("Stopping plugin='%s' ", pluginConfig.getPluginName())); stopAllButRestartMechanism(context); } catch (final IllegalStateException e) { logSafely(LogService.LOG_DEBUG, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); } catch (final Exception e) { logSafely(LogService.LOG_WARNING, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); logSafely(LogService.LOG_INFO, String.format("Restarting plugin='%s'", pluginConfig.getPluginName())); } catch (final IllegalStateException e) { logSafely(LogService.LOG_DEBUG, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); } catch (final Exception e) { logSafely(LogService.LOG_WARNING, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); start(context); } catch (final Exception e) { logSafely(LogService.LOG_WARNING, String.format("Error starting plugin='%s'", pluginConfig.getPluginName()), e);
List<T> curPluginVersionlist = (List<T>) allPlugins.get(plugin.getPluginName()); if (curPluginVersionlist == null) { curPluginVersionlist = new LinkedList<T>(); allPlugins.put(plugin.getPluginName(), curPluginVersionlist); logger.info("Adding plugin {} ", plugin.getPluginVersionnedName());
private File setupTmpDir(final PluginConfig pluginConfig) { final File tmpDirPath = new File(pluginConfig.getPluginVersionRoot().getAbsolutePath() + "/" + TMP_DIR_NAME); if (!tmpDirPath.exists()) { if (!tmpDirPath.mkdir()) { logService.log(LogService.LOG_WARNING, "Unable to create directory " + tmpDirPath + ", the restart mechanism is disabled"); return null; } } if (!tmpDirPath.isDirectory()) { logService.log(LogService.LOG_WARNING, tmpDirPath + " is not a directory, the restart mechanism is disabled"); return null; } return tmpDirPath; } }
if (shouldStopPlugin) { try { logSafely(LogService.LOG_INFO, String.format("Stopping plugin='%s' ", pluginConfig.getPluginName())); stopAllButRestartMechanism(context); } catch (final IllegalStateException e) { logSafely(LogService.LOG_DEBUG, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); } catch (final Exception e) { logSafely(LogService.LOG_WARNING, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); logSafely(LogService.LOG_INFO, String.format("Restarting plugin='%s'", pluginConfig.getPluginName())); } catch (final IllegalStateException e) { logSafely(LogService.LOG_DEBUG, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); } catch (final Exception e) { logSafely(LogService.LOG_WARNING, String.format("Error stopping plugin='%s'", pluginConfig.getPluginName()), e); start(context); } catch (final Exception e) { logSafely(LogService.LOG_WARNING, String.format("Error starting plugin='%s'", pluginConfig.getPluginName()), e);
private File setupTmpDir(final PluginConfig pluginConfig) { final File tmpDirPath = new File(pluginConfig.getPluginVersionRoot().getAbsolutePath() + "/" + TMP_DIR_NAME); if (!tmpDirPath.exists()) { if (!tmpDirPath.mkdir()) { logService.log(LogService.LOG_WARNING, "Unable to create directory " + tmpDirPath + ", the restart mechanism is disabled"); return null; } } if (!tmpDirPath.isDirectory()) { logService.log(LogService.LOG_WARNING, tmpDirPath + " is not a directory, the restart mechanism is disabled"); return null; } return tmpDirPath; } }
public void addPlugin(final PluginConfig newPlugin) { final Map<String, LinkedList<PluginConfig>> allPluginField = getAllPluginField(); allPluginField.clear(); if (allPluginField.get(newPlugin.getPluginName()) == null) { allPluginField.put(newPlugin.getPluginName(), new LinkedList<PluginConfig>()); } allPluginField.get(newPlugin.getPluginName()).add(newPlugin); }