more work on webstart

This commit is contained in:
7u83 2017-03-24 07:27:25 +01:00
parent 924a9c059c
commit f6cc6bbb7d
6 changed files with 104 additions and 68 deletions

View File

@ -109,7 +109,7 @@
--> -->
<target name="package-for-store" depends="jar"> <target name="single-jar" depends="jar">
<property name="store.jar.name" value="SeSim"/> <property name="store.jar.name" value="SeSim"/>
<property name="store.dir" value="store"/> <property name="store.dir" value="store"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/> <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>

View File

@ -0,0 +1 @@
config=sesimws

View File

@ -1,4 +1,4 @@
#Tue, 21 Mar 2017 02:08:14 +0100 #Thu, 23 Mar 2017 20:54:23 +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=
@ -58,12 +58,14 @@ javadoc.version=false
javadoc.windowtitle= javadoc.windowtitle=
jnlp.applet.height=300 jnlp.applet.height=300
jnlp.applet.width=300 jnlp.applet.width=300
jnlp.codebase.type=no.codebase jnlp.codebase.type=user
jnlp.codebase.url=$$$$codebase
jnlp.codebase.user=https\://blog.cauwersin.com/sesim https\://blog.cauwersin.com/sesim/lib
jnlp.descriptor=application jnlp.descriptor=application
jnlp.enabled=true jnlp.enabled=true
jnlp.icon= jnlp.icon=
jnlp.mixed.code=default jnlp.mixed.code=default
jnlp.offline-allowed=false jnlp.offline-allowed=true
jnlp.signed=true jnlp.signed=true
jnlp.signing=key jnlp.signing=key
jnlp.signing.alias=SeSim jnlp.signing.alias=SeSim

View File

@ -284,7 +284,7 @@ public final class EditStrategies extends javax.swing.JDialog {
} }
System.out.printf("Base %s\n", base); Globals.LOGGER.info(String.format("Base %s\n", base));
ac = Globals.tloader.getStrategyBase(base); ac = Globals.tloader.getStrategyBase(base);
if (ac == null) { if (ac == null) {

View File

@ -57,13 +57,11 @@ public class AutoTraderLoader {
setPathList(pathlist); setPathList(pathlist);
} }
public final void setPathList(ArrayList<String> pathlist) { public final void setPathList(ArrayList<String> pathlist) {
this.pathlist = pathlist; this.pathlist = pathlist;
this.traders_cache = null; this.traders_cache = null;
} }
/** /**
* Check if a given class can instaciated as AutoTrader. * Check if a given class can instaciated as AutoTrader.
* *
@ -95,12 +93,31 @@ public class AutoTraderLoader {
return false; return false;
} }
private ClassLoader cl;
public AutoTraderInterface MakeInstance(Class<?> cls){
ClassLoader cur = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(cl);
AutoTraderInterface ai;
Globals.LOGGER.info("Going to load");
try {
ai = (AutoTraderInterface)cls.newInstance();
} catch (InstantiationException | IllegalAccessException ex) {
Globals.LOGGER.info("Ist was passiert");
Logger.getLogger(AutoTraderLoader.class.getName()).log(Level.SEVERE, null, ex);
ai=null;
}
Thread.currentThread().setContextClassLoader(cur);
return ai;
}
Class<AutoTraderInterface> loadAutoTraderClass(String filename, String classname) { Class<AutoTraderInterface> loadAutoTraderClass(String filename, String classname) {
System.out.printf("Comming in width %s %s", filename, classname);
System.out.printf("Comming in width %s %s\n", filename, classname);
Globals.LOGGER.info(String.format("Comming in width %s %s\n", filename, classname)); Globals.LOGGER.info(String.format("Comming in width %s %s\n", filename, classname));
if (classname == null) { if (classname == null) {
@ -124,8 +141,15 @@ public class AutoTraderLoader {
URL[] urls = new URL[]{url}; URL[] urls = new URL[]{url};
// Create a new class loader with the directory // Create a new class loader with the directory
ClassLoader cl = new URLClassLoader(urls); cl = new URLClassLoader(urls);
//Thread.currentThread().setContextClassLoader(cl);
cl = Thread.currentThread().getContextClassLoader();
try { try {
Globals.LOGGER.info("try cl"); Globals.LOGGER.info("try cl");
@ -136,8 +160,8 @@ public class AutoTraderLoader {
} }
Globals.LOGGER.info("Ccast"); Globals.LOGGER.info("Ccast");
Class<AutoTraderInterface> cls = (Class<AutoTraderInterface>) c; // cl.loadClass(clnam); Class<AutoTraderInterface> cls = (Class<AutoTraderInterface>) c; // cl.loadClass(clnam);
return cls; // return cls;
/* if (cls == null){ if (cls == null) {
} }
@ -145,7 +169,7 @@ public class AutoTraderLoader {
Globals.LOGGER.info(String.format("Class prope %s", cls.getCanonicalName())); Globals.LOGGER.info(String.format("Class prope %s", cls.getCanonicalName()));
if (isAutoTrader(cls)) { if (isAutoTrader(cls)) {
Globals.LOGGER.info("We have found an autotrader interface");
Class<AutoTraderInterface> claa; Class<AutoTraderInterface> claa;
claa = (Class<AutoTraderInterface>) cls; claa = (Class<AutoTraderInterface>) cls;
@ -158,7 +182,7 @@ public class AutoTraderLoader {
//return (Class<AutoTraderInterface>) cls; //return (Class<AutoTraderInterface>) cls;
//return (Class<AutoTraderInterface>) cls; //return (Class<AutoTraderInterface>) cls;
} }
*/
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
// something wnet wrong, but we ignore it // something wnet wrong, but we ignore it
System.out.printf("Class not found\n"); System.out.printf("Class not found\n");
@ -168,17 +192,12 @@ public class AutoTraderLoader {
} }
/* public ArrayList<Class<AutoTraderInterface>> getTradersX() { /* public ArrayList<Class<AutoTraderInterface>> getTradersX() {
String[] a = System.getProperty("java.class.path").split(System.getProperty("path.separator")); String[] a = System.getProperty("java.class.path").split(System.getProperty("path.separator"));
this.pathlist=new ArrayList<>(Arrays.asList(a)); this.pathlist=new ArrayList<>(Arrays.asList(a));
return getTraders0(); return getTraders0();
} }
*/ */
public ArrayList<Class<AutoTraderInterface>> getTraders() { public ArrayList<Class<AutoTraderInterface>> getTraders() {
if (traders_cache != null) { if (traders_cache != null) {
@ -188,8 +207,6 @@ public class AutoTraderLoader {
ArrayList<Class<AutoTraderInterface>> traders; ArrayList<Class<AutoTraderInterface>> traders;
traders = new ArrayList<>(); traders = new ArrayList<>();
for (String classpathEntry : pathlist) { for (String classpathEntry : pathlist) {
Globals.LOGGER.info(String.format("Here we ar looking now %s", classpathEntry)); Globals.LOGGER.info(String.format("Here we ar looking now %s", classpathEntry));
@ -231,9 +248,10 @@ public class AutoTraderLoader {
String fn0 = entry.getName(); String fn0 = entry.getName();
Class<AutoTraderInterface> cls = loadAutoTraderClass(fn, "/" + entry.getName()); Class<AutoTraderInterface> cls = loadAutoTraderClass(fn, "/" + entry.getName());
if (cls != null) { if (cls != null) {
Globals.LOGGER.info("Class is not null!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
traders.add(cls); traders.add(cls);
} }
Globals.LOGGER.info("clas was null"); //Globals.LOGGER.info("clas was null");
} }
} }
@ -244,6 +262,7 @@ public class AutoTraderLoader {
try { try {
is.close(); is.close();
} catch (IOException ex) { } catch (IOException ex) {
Logger.getLogger(AutoTraderLoader.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(AutoTraderLoader.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
@ -260,6 +279,9 @@ public class AutoTraderLoader {
} }
traders_cache = traders; traders_cache = traders;
Globals.LOGGER.info(String.format("We hav found %d traders", traders.size()));
return traders; return traders;
} }
@ -274,7 +296,9 @@ public class AutoTraderLoader {
for (int i = 0; i < trclasses.size(); i++) { for (int i = 0; i < trclasses.size(); i++) {
try { try {
AutoTraderInterface ac = trclasses.get(i).newInstance(); //AutoTraderInterface ac = trclasses.get(i).newInstance();
AutoTraderInterface ac = this.MakeInstance(trclasses.get(i));
if (ac.getDevelStatus() && devel == false) { if (ac.getDevelStatus() && devel == false) {
continue; continue;
} }
@ -297,7 +321,14 @@ public class AutoTraderLoader {
ArrayList<Class<AutoTraderInterface>> traders = this.getTraders(); ArrayList<Class<AutoTraderInterface>> traders = this.getTraders();
for (int i = 0; i < traders.size(); i++) { for (int i = 0; i < traders.size(); i++) {
try { try {
AutoTraderInterface ac = traders.get(i).newInstance(); Globals.LOGGER.info(String.format("Making lll instance of %s", traders.get(i).getCanonicalName()));
if (traders.get(i)==null){
Globals.LOGGER.info("We have null");
}
// AutoTraderInterface ac = traders.get(i).newInstance();
AutoTraderInterface ac = this.MakeInstance(traders.get(i));
System.out.printf("Looking for in %s == %s\n", ac.getClass().getCanonicalName(), name); System.out.printf("Looking for in %s == %s\n", ac.getClass().getCanonicalName(), name);
@ -308,6 +339,7 @@ public class AutoTraderLoader {
// return ac;} // return ac;}
} }
} catch (Exception ex) { } catch (Exception ex) {
Globals.LOGGER.info(String.format("Instance failed %s", ex.getMessage()));
} }
} }

View File

@ -34,6 +34,7 @@ import sesim.AutoTraderBase;
import sesim.AutoTraderConfigBase; import sesim.AutoTraderConfigBase;
import sesim.AutoTraderConfig; import sesim.AutoTraderConfig;
import sesim.AutoTraderGui; import sesim.AutoTraderGui;
import sesim.AutoTraderInterface;
import sesim.Exchange; import sesim.Exchange;
import sesim.Exchange.AccountListener; import sesim.Exchange.AccountListener;
import sesim.Exchange.OrderStatus; import sesim.Exchange.OrderStatus;
@ -42,7 +43,7 @@ import sesim.Exchange.OrderStatus;
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
*/ */
public class ManTrader extends AutoTraderBase implements AccountListener { public class ManTrader extends AutoTraderBase implements AccountListener, AutoTraderInterface{
public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) { public ManTrader(Exchange se, long id, String name, double money, double shares, AutoTraderConfig config) {
// super(se, id, name, money, shares, null); // super(se, id, name, money, shares, null);