// this also checks to see if the plugin configuration has changed since it was last loaded
MasterServerPluginContainer master = LookupUtil.getServerPluginService().getMasterPluginContainer();
if (master != null) {
for (ServerPlugin installedPlugin : installedPlugins) {
PluginKey key = PluginKey.createServerPluginKey(installedPlugin.getType(), installedPlugin.getName());
AbstractTypeServerPluginContainer pc = master.getPluginContainerByPlugin(key);
if (pc != null && pc.isPluginLoaded(key)) {
boolean needToReloadPlugin = false;
boolean currentlyEnabled = pc.isPluginEnabled(key);
if (installedPlugin.isEnabled() != currentlyEnabled) {
log.info("Detected a state change to plugin [" + key + "]. It will now be "
+ ((installedPlugin.isEnabled()) ? "[enabled]" : "[disabled]"));
needToReloadPlugin = true;
} else {
Long pluginLoadTime = pc.getPluginLoadTime(key);
if (pluginLoadTime != null) {
long configChangeTimestamp = serverPluginsManager
.getLastConfigurationChangeTimestamp(installedPlugin.getId());
if (configChangeTimestamp > pluginLoadTime) {
// since the last time the plugin was loaded, its configuration has changed, reload it to pick up the new config
log.info("Detected a config change to plugin [" + key + "]. It will be reloaded and "
+ ((installedPlugin.isEnabled()) ? "[enabled]" : "[disabled]"));
needToReloadPlugin = true;
}
}
}
if (needToReloadPlugin) {
pc.reloadPlugin(key, installedPlugin.isEnabled());
}
}
}
}