Moving SesSimClassLoader to a pure templated class
This commit is contained in:
parent
fe6eae9457
commit
480167b53f
@ -1,4 +1,4 @@
|
|||||||
#Sun, 19 Nov 2017 18:42:19 +0100
|
#Mon, 20 Nov 2017 09:48:54 +0100
|
||||||
annotation.processing.enabled=true
|
annotation.processing.enabled=true
|
||||||
annotation.processing.enabled.in.editor=false
|
annotation.processing.enabled.in.editor=false
|
||||||
annotation.processing.processors.list=
|
annotation.processing.processors.list=
|
||||||
|
@ -150,7 +150,7 @@ public class Globals {
|
|||||||
tloader = new AutoTraderLoader(default_pathlist);
|
tloader = new AutoTraderLoader(default_pathlist);
|
||||||
|
|
||||||
|
|
||||||
IndicatorLoader<Indicator> il = new IndicatorLoader<Indicator>();
|
IndicatorLoader<Indicator> il = new IndicatorLoader<>(Indicator.class);
|
||||||
il.setDefaultPathList(default_pathlist);
|
il.setDefaultPathList(default_pathlist);
|
||||||
il.getInstalled();
|
il.getInstalled();
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ import sesim.Indicator;
|
|||||||
*
|
*
|
||||||
* @author tube
|
* @author tube
|
||||||
*/
|
*/
|
||||||
public class BaseIndicator implements Indicator{
|
public abstract class BaseIndicator implements Indicator{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -34,7 +34,7 @@ import java.util.logging.Logger;
|
|||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
*/
|
*/
|
||||||
public class AutoTraderLoader extends SeSimClassLoader {
|
public class AutoTraderLoader extends SeSimClassLoader<AutoTraderInterface> {
|
||||||
|
|
||||||
private ArrayList<Class<AutoTraderInterface>> traders_cache = null;
|
private ArrayList<Class<AutoTraderInterface>> traders_cache = null;
|
||||||
|
|
||||||
@ -44,6 +44,7 @@ public class AutoTraderLoader extends SeSimClassLoader {
|
|||||||
|
|
||||||
private ClassLoader cl;
|
private ClassLoader cl;
|
||||||
|
|
||||||
|
@Override
|
||||||
public AutoTraderInterface newInstance(Class<?> cls) {
|
public AutoTraderInterface newInstance(Class<?> cls) {
|
||||||
// ClassLoader cur = Thread.currentThread().getContextClassLoader();
|
// ClassLoader cur = Thread.currentThread().getContextClassLoader();
|
||||||
// Thread.currentThread().setContextClassLoader(cl);
|
// Thread.currentThread().setContextClassLoader(cl);
|
||||||
|
@ -34,6 +34,12 @@ import java.util.ArrayList;
|
|||||||
public class IndicatorLoader<T> extends SeSimClassLoader {
|
public class IndicatorLoader<T> extends SeSimClassLoader {
|
||||||
|
|
||||||
ArrayList<Class<T>> cache;
|
ArrayList<Class<T>> cache;
|
||||||
|
final Class<T> class_type;
|
||||||
|
|
||||||
|
|
||||||
|
public IndicatorLoader(Class<T> class_type){
|
||||||
|
this.class_type=class_type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all traders found in class path
|
* Get a list of all traders found in class path
|
||||||
@ -46,11 +52,11 @@ public class IndicatorLoader<T> extends SeSimClassLoader {
|
|||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?> tube = null;
|
Class<?> tube ;
|
||||||
|
|
||||||
ArrayList<Class<?>> trl;
|
ArrayList<Class<?>> trl;
|
||||||
ArrayList<Class<T>> result = new ArrayList<>();
|
ArrayList<Class<T>> result = new ArrayList<>();
|
||||||
trl = getInstalledClasses(new ArrayList(), tube);
|
trl = getInstalledClasses(new ArrayList(), class_type);
|
||||||
for (Class<?> c : trl) {
|
for (Class<?> c : trl) {
|
||||||
result.add((Class<T>) c);
|
result.add((Class<T>) c);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ import java.util.logging.Level;
|
|||||||
*
|
*
|
||||||
* @author 7u83 <7u83@mail.ru>
|
* @author 7u83 <7u83@mail.ru>
|
||||||
*/
|
*/
|
||||||
public class SeSimClassLoader {
|
public class SeSimClassLoader <T>{
|
||||||
|
|
||||||
protected ArrayList<String> default_pathlist;
|
protected ArrayList<String> default_pathlist;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user