use of fi.otavanopisto.pyramus.plugin.PluginDescriptor in project pyramus by otavanopisto.
the class PyramusServletContextListener method loadPlugins.
@SuppressWarnings("unchecked")
private void loadPlugins() {
try {
PluginRepositoryDAO pluginRepositoryDAO = DAOFactory.getInstance().getPluginRepositoryDAO();
List<PluginRepository> pluginRepositories = pluginRepositoryDAO.listAll();
PluginManager pluginManager = PluginManager.initialize(getClass().getClassLoader(), pluginRepositories);
PluginDAO pluginDAO = DAOFactory.getInstance().getPluginDAO();
List<Plugin> enabledPlugins = pluginDAO.listByEnabled(Boolean.TRUE);
for (Plugin plugin : enabledPlugins) {
try {
pluginManager.loadPlugin(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion());
} catch (Exception e) {
Logging.logException("Failed to load plugin: " + plugin.getGroupId() + "." + plugin.getArtifactId() + ":" + plugin.getVersion(), e);
}
}
pluginManager.registerPlugins();
// Load additional request mappings from plugins
List<PluginDescriptor> plugins = pluginManager.getPlugins();
for (PluginDescriptor plugin : plugins) {
Map<String, Class<?>> pageRequestControllers = plugin.getPageRequestControllers();
if (pageRequestControllers != null) {
for (Map.Entry<String, Class<?>> entry : pageRequestControllers.entrySet()) {
String className = entry.getValue().getName();
Class<? extends RequestController> pageController = (Class<? extends RequestController>) Class.forName(className, false, pluginManager.getPluginsClassLoader());
RequestController oldController = RequestControllerMapper.getRequestController(entry.getKey() + ".page");
if (oldController != null) {
// Save masked controllers for extending existing functionality by calling
// the masked controller's .process()
RequestControllerMapper.mapController(entry.getKey(), ".page.masked", oldController);
}
RequestControllerMapper.mapController(entry.getKey(), ".page", pageController.newInstance());
}
}
Map<String, Class<?>> jsonRequestControllers = plugin.getJSONRequestControllers();
if (jsonRequestControllers != null) {
for (Map.Entry<String, Class<?>> entry : jsonRequestControllers.entrySet()) {
String className = entry.getValue().getName();
Class<? extends RequestController> pageController = (Class<? extends RequestController>) Class.forName(className, false, pluginManager.getPluginsClassLoader());
RequestController oldController = RequestControllerMapper.getRequestController(entry.getKey() + ".json");
if (oldController != null) {
// Save masked controllers for extending existing functionality by calling
// the masked controller's .process()
RequestControllerMapper.mapController(entry.getKey(), ".json.masked", oldController);
}
RequestControllerMapper.mapController(entry.getKey(), ".json", pageController.newInstance());
}
}
Map<String, Class<?>> binaryRequestControllers = plugin.getBinaryRequestControllers();
if (binaryRequestControllers != null) {
for (Map.Entry<String, Class<?>> entry : binaryRequestControllers.entrySet()) {
String className = entry.getValue().getName();
Class<? extends RequestController> pageController = (Class<? extends RequestController>) Class.forName(className, false, pluginManager.getPluginsClassLoader());
RequestController oldController = RequestControllerMapper.getRequestController(entry.getKey() + ".binary");
if (oldController != null) {
// Save masked controllers for extending existing functionality by calling
// the masked controller's .process()
RequestControllerMapper.mapController(entry.getKey(), ".binary.masked", oldController);
}
RequestControllerMapper.mapController(entry.getKey(), ".binary", pageController.newInstance());
}
}
}
} catch (Exception e) {
Logging.logException("Plugins loading failed", e);
}
for (Webhook webhook : webhookDAO.listAll()) {
webhooks.addWebhook(webhook.getUrl(), webhook.getSecret());
}
;
}
use of fi.otavanopisto.pyramus.plugin.PluginDescriptor in project pyramus by otavanopisto.
the class Messages method loadBundleNames.
private void loadBundleNames() {
List<PluginDescriptor> plugins = PluginManager.getInstance().getPlugins();
for (PluginDescriptor plugin : plugins) {
if (!StringUtils.isBlank(plugin.getMessagesBundlePath())) {
bundleNames.add(plugin.getMessagesBundlePath());
}
}
bundleNames.add("fi.otavanopisto.pyramus.I18N.pyramuslocale");
}
Aggregations