From 408c4f0379696a29e3e7265ae32270776ab0d80d Mon Sep 17 00:00:00 2001 From: rileyJones Date: Fri, 28 Jul 2017 11:17:54 -0700 Subject: [PATCH] Add external plugin support --- .idea/vcs.xml | 6 +++ src/org/nwapw/abacus/Abacus.java | 31 ++++++++++- .../nwapw/abacus/plugin/ClassFinderV2.java | 51 ++++++++++++++++++ src/org/nwapw/abacus/plugin/Standard.jar | Bin 0 -> 11127 bytes 4 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 src/org/nwapw/abacus/plugin/ClassFinderV2.java create mode 100644 src/org/nwapw/abacus/plugin/Standard.jar diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/org/nwapw/abacus/Abacus.java b/src/org/nwapw/abacus/Abacus.java index 08f4ba5..0522874 100644 --- a/src/org/nwapw/abacus/Abacus.java +++ b/src/org/nwapw/abacus/Abacus.java @@ -1,10 +1,14 @@ 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.ClassFinderV2; import javax.swing.*; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; public class Abacus { @@ -22,10 +26,33 @@ public class Abacus { e.printStackTrace(); } manager = new PluginManager(); - manager.addInstantiated(new StandardPlugin(manager)); + ArrayList names = new ArrayList(); + try { + + ClassFinderV2 classFinder = new ClassFinderV2(); + File pluginFile = new File("C:\\Users\\galbraithja\\Desktop\\.git\\abacus\\src\\org\\nwapw\\abacus\\plugin"); + for(File classes:pluginFile.listFiles()){ + if(classes.getName().endsWith(".jar")){ + names.addAll(classFinder.addJar("C:\\Users\\galbraithja\\Desktop\\.git\\abacus\\src\\org\\nwapw\\abacus\\plugin\\Standard.jar")); + } + } + for(String name:names){ + System.out.println(name); + } + ArrayList classes = classFinder.getClasses(); + for(Class classGet:classes){ + manager.addClass(classGet); + } + + } catch (IOException e) { + e.printStackTrace(); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } mainUi = new Window(manager); mainUi.setVisible(true); manager.load(); + } public static void main(String[] args){ diff --git a/src/org/nwapw/abacus/plugin/ClassFinderV2.java b/src/org/nwapw/abacus/plugin/ClassFinderV2.java new file mode 100644 index 0000000..3cdba13 --- /dev/null +++ b/src/org/nwapw/abacus/plugin/ClassFinderV2.java @@ -0,0 +1,51 @@ +package org.nwapw.abacus.plugin; + +import java.io.File; +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +public class ClassFinderV2 { + ArrayList classes; + URL[] urls; + public ClassFinderV2(){ + classes = new ArrayList(); + } + public ArrayList addJar(String path) throws IOException, ClassNotFoundException { + //urls = new URL[]{new URL("jar:file:" + path + "!/")}; + return addJar(new File(path)); + } + public ArrayList addJar(File jarLocation) throws IOException, ClassNotFoundException { + String path = jarLocation.getPath(); + urls = new URL[]{new URL("jar:file:" + path + "!/")}; + URLClassLoader classLoader = URLClassLoader.newInstance(urls); + JarFile jarFolder = new JarFile(jarLocation); + Enumeration jarList = jarFolder.entries(); + ArrayList classNames = new ArrayList(); + while(jarList.hasMoreElements()){ + JarEntry tempJar = (JarEntry)jarList.nextElement(); + if(tempJar.getName().endsWith(".class")){ + //System.out.println(tempJar.getName()); + classNames.add(tempJar.getName()); + classes.add(classLoader.loadClass(tempJar.getName().replace('/','.').substring(0,tempJar.getName().length()-6))); + } + } + return classNames; + } + public ArrayList getClasses(){ + return classes; + } + public Class getClass(int number){ + return classes.get(number); + } + public void delClasses(){ + classes=new ArrayList(); + } + public int classCount(){ + return classes.size(); + } +} diff --git a/src/org/nwapw/abacus/plugin/Standard.jar b/src/org/nwapw/abacus/plugin/Standard.jar new file mode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