use of org.pf4j.PluginWrapper in project pf4j-spring by pf4j.
the class SpringExtensionFactory method create.
@Override
public Object create(Class<?> extensionClass) {
Object extension = createWithoutSpring(extensionClass);
if (autowire && extension != null) {
// test for SpringBean
PluginWrapper pluginWrapper = pluginManager.whichPlugin(extensionClass);
if (pluginWrapper != null) {
Plugin plugin = pluginWrapper.getPlugin();
if (plugin instanceof SpringPlugin) {
// autowire
ApplicationContext pluginContext = ((SpringPlugin) plugin).getApplicationContext();
pluginContext.getAutowireCapableBeanFactory().autowireBean(extension);
}
}
}
return extension;
}
use of org.pf4j.PluginWrapper in project pf4j-update by pf4j.
the class UpdateManager method getUpdates.
/**
* Return a list of plugins that are newer versions of already installed plugins.
*
* @return list of plugins that have updates
*/
public List<PluginInfo> getUpdates() {
List<PluginInfo> updates = new ArrayList<>();
Map<String, PluginInfo> pluginMap = getPluginsMap();
for (PluginWrapper installed : pluginManager.getPlugins()) {
PluginInfo pluginFromRepo = pluginMap.get(installed.getPluginId());
if (pluginFromRepo != null) {
String installedVersion = installed.getDescriptor().getVersion();
if (pluginFromRepo.hasUpdate(systemVersion, installedVersion, versionManager)) {
updates.add(pluginFromRepo);
}
}
}
return updates;
}
use of org.pf4j.PluginWrapper in project pf4j-wicket by pf4j.
the class PluginManagerInitializer method init.
@Override
public void init(Application application) {
pluginManager = createPluginManager(application);
if (pluginManager == null) {
throw new WicketRuntimeException("Plugin manager cannot be null");
}
log.debug("Created plugin manager {}", pluginManager);
// load plugins
pluginManager.loadPlugins();
// init plugins
List<PluginWrapper> resolvedPlugins = pluginManager.getResolvedPlugins();
for (PluginWrapper plugin : resolvedPlugins) {
if (plugin.getPlugin() instanceof WicketPlugin) {
((WicketPlugin) plugin.getPlugin()).init(application);
}
}
// start plugins
pluginManager.startPlugins();
// set class resolver
CompoundClassResolver classResolver = new CompoundClassResolver();
classResolver.add(new DefaultClassResolver());
List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
for (PluginWrapper plugin : startedPlugins) {
classResolver.add(new PluginClassResolver(plugin));
}
application.getApplicationSettings().setClassResolver(classResolver);
// store plugin manager in application
application.setMetaData(PLUGIN_MANAGER_KEY, pluginManager);
// add PluginComponentInjector
application.getComponentInstantiationListeners().add(new PluginComponentInjector(application));
}
use of org.pf4j.PluginWrapper in project pf4j-wicket by pf4j.
the class PluginManagerInitializer method destroy.
@Override
public void destroy(Application application) {
List<PluginWrapper> startedPlugins = pluginManager.getStartedPlugins();
Collections.reverse(startedPlugins);
// stop plugins
pluginManager.stopPlugins();
// destroy started plugins in reverse order
for (PluginWrapper plugin : startedPlugins) {
if (plugin.getPlugin() instanceof WicketPlugin) {
((WicketPlugin) plugin.getPlugin()).destroy(application);
}
}
}
use of org.pf4j.PluginWrapper in project legendarybot by greatman.
the class ReloadPluginsCommand method execute.
@Override
public void execute(MessageReceivedEvent event, String[] args) {
if (args.length == 1) {
bot.getPluginManager().unloadPlugin(args[0]);
} else {
for (PluginWrapper wrapper : bot.getPluginManager().getPlugins()) {
bot.getPluginManager().unloadPlugin(wrapper.getPluginId());
}
}
bot.getPluginManager().loadPlugins();
bot.getPluginManager().startPlugins();
event.getChannel().sendMessage("Plugins reloaded!").queue();
}
Aggregations