mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
classpath util method
This commit is contained in:
Binary file not shown.
Binary file not shown.
+27
-22
@@ -26,7 +26,6 @@ import javax.swing.JOptionPane;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
import org.diylc.appframework.miscutils.JarScanner;
|
|
||||||
import org.diylc.appframework.miscutils.Utils;
|
import org.diylc.appframework.miscutils.Utils;
|
||||||
import org.diylc.appframework.simplemq.MessageDispatcher;
|
import org.diylc.appframework.simplemq.MessageDispatcher;
|
||||||
import org.diylc.appframework.update.VersionNumber;
|
import org.diylc.appframework.update.VersionNumber;
|
||||||
@@ -299,29 +298,35 @@ public class Presenter implements IPlugInPort {
|
|||||||
if (componentTypes == null) {
|
if (componentTypes == null) {
|
||||||
LOG.info("Loading component types.");
|
LOG.info("Loading component types.");
|
||||||
componentTypes = new HashMap<String, List<ComponentType>>();
|
componentTypes = new HashMap<String, List<ComponentType>>();
|
||||||
String[] classPath = Utils.getClasspath(Presenter.class);
|
Set<Class<?>> componentTypeClasses = null;
|
||||||
Set<Class<?>> componentTypeClasses = new HashSet<Class<?>>();
|
try {
|
||||||
for (String path : classPath) {
|
componentTypeClasses = Utils.getClasses("org.diylc.components");
|
||||||
path = path.replace('\\', '/');
|
} catch (Exception e) {
|
||||||
File f = new File(path);
|
// TODO Auto-generated catch block
|
||||||
try {
|
e.printStackTrace();
|
||||||
if (f.isDirectory()) {
|
|
||||||
LOG.info("Scanning folder for components: "
|
|
||||||
+ f.getAbsolutePath());
|
|
||||||
componentTypeClasses.addAll(JarScanner.getInstance()
|
|
||||||
.scanFolder(path, IDIYComponent.class));
|
|
||||||
} else {
|
|
||||||
LOG.info("Scanning JAR for components: "
|
|
||||||
+ f.getAbsolutePath());
|
|
||||||
componentTypeClasses.addAll(JarScanner.getInstance()
|
|
||||||
.scanJar(f, IDIYComponent.class));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.warn("Could not scan path " + path, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// for (String path : classPath) {
|
||||||
|
// path = path.replace('\\', '/');
|
||||||
|
// File f = new File(path);
|
||||||
|
// try {
|
||||||
|
// if (f.isDirectory()) {
|
||||||
|
// LOG.info("Scanning folder for components: "
|
||||||
|
// + f.getAbsolutePath());
|
||||||
|
// componentTypeClasses.addAll(JarScanner.getInstance()
|
||||||
|
// .scanFolder(path, IDIYComponent.class));
|
||||||
|
// } else {
|
||||||
|
// LOG.info("Scanning JAR for components: "
|
||||||
|
// + f.getAbsolutePath());
|
||||||
|
// componentTypeClasses.addAll(JarScanner.getInstance()
|
||||||
|
// .scanJar(f, IDIYComponent.class));
|
||||||
|
// }
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// LOG.warn("Could not scan path " + path, e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
for (Class<?> clazz : componentTypeClasses) {
|
for (Class<?> clazz : componentTypeClasses) {
|
||||||
if (!Modifier.isAbstract(clazz.getModifiers())) {
|
if (!Modifier.isAbstract(clazz.getModifiers())
|
||||||
|
&& IDIYComponent.class.isAssignableFrom(clazz)) {
|
||||||
ComponentType componentType = ComponentProcessor
|
ComponentType componentType = ComponentProcessor
|
||||||
.getInstance().extractComponentTypeFrom(
|
.getInstance().extractComponentTypeFrom(
|
||||||
(Class<? extends IDIYComponent<?>>) clazz);
|
(Class<? extends IDIYComponent<?>>) clazz);
|
||||||
|
|||||||
Reference in New Issue
Block a user