5 Commits

Author SHA1 Message Date
bc5ccd6356 Fixed a comment 2025-03-29 20:59:30 +01:00
8279033d74 Fixed name of StockAsset and inserted Sockasset to example 2020-10-23 10:02:30 +02:00
2e1a53789f Added some comments 2020-10-23 09:45:44 +02:00
b084e0a156 Asset folder is lower case 2020-10-23 09:15:42 +02:00
2241822b26 Loads Ivy 2020-10-23 09:15:14 +02:00
5 changed files with 26 additions and 13 deletions

View File

@ -130,7 +130,7 @@
<delete file="${store.dir}/temp_final.jar"/> <delete file="${store.dir}/temp_final.jar"/>
</target> </target>
<property name="ivy.install.version" value="2.1.0-rc2" /> <property name="ivy.install.version" value="2.5.0" />
<condition property="ivy.home" value="${env.IVY_HOME}"> <condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" /> <isset property="env.IVY_HOME" />
</condition> </condition>
@ -142,7 +142,7 @@
<mkdir dir="${ivy.jar.dir}"/> <mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation --> <!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" <get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/> dest="${ivy.jar.file}" usetimestamp="true"/>
</target> </target>

View File

@ -46,7 +46,7 @@ public class Main {
); );
// We have to bootstrap with a god world because // We have to bootstrap with a god world because
// there whould be no way to to initialize the world // there whould be no way to initialize the world
GodWorld godworld = new GodWorld(is); GodWorld godworld = new GodWorld(is);
System.out.println("finished"); System.out.println("finished");

View File

@ -2,9 +2,9 @@
"version": 0.2, "version": 0.2,
"assets": [ "assets": [
{ {
"type": "opensesim.sesim.Assets.FurtureAsset", "type": "opensesim.sesim.assets.StockAsset",
"symbol": "MSFT", "symbol": "MSFT",
"name": "Hello" "name": "Microsoft"
} }
] ]
} }

View File

@ -34,9 +34,9 @@ import org.json.JSONObject;
* *
* @author 7u83 <7u83@mail.ru> * @author 7u83 <7u83@mail.ru>
*/ */
public class StockAssett extends AbstractAsset{ public class StockAsset extends AbstractAsset{
public StockAssett(GodWorld world, JSONObject cfg) { public StockAsset(GodWorld world, JSONObject cfg) {
super(world, cfg); super(world, cfg);
} }

View File

@ -109,7 +109,14 @@ public class GodWorld implements GetJson, World {
} }
init(cfg,false); init(cfg,false);
} }
private void init(JSONObject cfg, boolean mt) {
// this.scheduler = new Scheduler();
// this.scheduler.start();
putJson(cfg);
}
public Scheduler getScheduler() { public Scheduler getScheduler() {
return scheduler; return scheduler;
} }
@ -122,11 +129,6 @@ public class GodWorld implements GetJson, World {
this(new JSONObject("{}")); this(new JSONObject("{}"));
} }
private void init(JSONObject cfg, boolean mt) {
this.scheduler = new Scheduler();
this.scheduler.start();
putJson(cfg);
}
private void putJson(JSONObject cfg) { private void putJson(JSONObject cfg) {
// Read assets // Read assets
@ -186,11 +188,19 @@ public class GodWorld implements GetJson, World {
return cfg; return cfg;
} }
/**
* Create an asset from a JSON object
*
* @param cfg the JSON object to create the asset from
* @return the created asset
* @throws SeSimException
*/
public AbstractAsset createAsset(JSONObject cfg) throws SeSimException { public AbstractAsset createAsset(JSONObject cfg) throws SeSimException {
AbstractAsset a; AbstractAsset a;
String class_name; String class_name;
Class<AbstractAsset> cls; Class<AbstractAsset> cls;
// get asset name
try { try {
class_name = cfg.getString(JKEYS.ASSET_TYPE); class_name = cfg.getString(JKEYS.ASSET_TYPE);
} catch (JSONException jex) { } catch (JSONException jex) {
@ -198,10 +208,13 @@ public class GodWorld implements GetJson, World {
return null; return null;
} }
// create class from name
try { try {
cls = (Class<AbstractAsset>) Class.forName(class_name); cls = (Class<AbstractAsset>) Class.forName(class_name);
a = cls.getConstructor(GodWorld.class, JSONObject.class).newInstance(this, cfg); a = cls.getConstructor(GodWorld.class, JSONObject.class).newInstance(this, cfg);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { } catch (ClassNotFoundException | NoSuchMethodException | SecurityException
| InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException ex) {
Logger.getLogger(GodWorld.class.getName()).log(Level.SEVERE, class_name, ex); Logger.getLogger(GodWorld.class.getName()).log(Level.SEVERE, class_name, ex);
return null; return null;
} }