1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-04 15:32:59 -08:00

Load default plugin without jars.

This commit is contained in:
Danila Fedorin 2017-07-28 15:18:23 -07:00
parent 8c5306051e
commit 5c301e4afa
2 changed files with 11 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package org.nwapw.abacus;
import org.nwapw.abacus.plugin.PluginManager;
//import org.nwapw.abacus.plugin.StandardPlugin;
import org.nwapw.abacus.plugin.StandardPlugin;
import org.nwapw.abacus.window.Window;
import org.nwapw.abacus.plugin.ClassFinder;
@ -25,6 +26,7 @@ public class Abacus {
e.printStackTrace();
}
manager = new PluginManager();
manager.addInstantiated(new StandardPlugin(manager));
try {
ClassFinder.loadJars("plugins")
.forEach(plugin -> manager.addClass(plugin));

View File

@ -12,10 +12,14 @@ import java.util.*;
*/
public class PluginManager {
/**
* List of classes loaded by this manager.
*/
private Set<Class<?>> loadedPluginClasses;
/**
* A list of loaded plugins.
*/
private List<Plugin> plugins;
private Set<Plugin> plugins;
/**
* List of functions that have been cached,
* that is, found in a plugin and returned.
@ -43,7 +47,8 @@ public class PluginManager {
* Creates a new plugin manager.
*/
public PluginManager(){
plugins = new ArrayList<>();
loadedPluginClasses = new HashSet<>();
plugins = new HashSet<>();
cachedFunctions = new HashMap<>();
cachedOperators = new HashMap<>();
allFunctions = new HashSet<>();
@ -104,7 +109,9 @@ public class PluginManager {
* @param plugin the plugin to add.
*/
public void addInstantiated(Plugin plugin){
if(loadedPluginClasses.contains(plugin.getClass())) return;
plugins.add(plugin);
loadedPluginClasses.add(plugin.getClass());
}
/**