Compare commits
5 Commits
d63ee05b5d
...
master
Author | SHA1 | Date | |
---|---|---|---|
bc5ccd6356 | |||
8279033d74 | |||
2e1a53789f | |||
b084e0a156 | |||
2241822b26 |
@ -130,7 +130,7 @@
|
||||
<delete file="${store.dir}/temp_final.jar"/>
|
||||
</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}">
|
||||
<isset property="env.IVY_HOME" />
|
||||
</condition>
|
||||
@ -142,7 +142,7 @@
|
||||
|
||||
<mkdir dir="${ivy.jar.dir}"/>
|
||||
<!-- 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"/>
|
||||
</target>
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class Main {
|
||||
);
|
||||
|
||||
// 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);
|
||||
|
||||
System.out.println("finished");
|
||||
|
@ -2,9 +2,9 @@
|
||||
"version": 0.2,
|
||||
"assets": [
|
||||
{
|
||||
"type": "opensesim.sesim.Assets.FurtureAsset",
|
||||
"type": "opensesim.sesim.assets.StockAsset",
|
||||
"symbol": "MSFT",
|
||||
"name": "Hello"
|
||||
"name": "Microsoft"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ import org.json.JSONObject;
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
@ -109,7 +109,14 @@ public class GodWorld implements GetJson, World {
|
||||
}
|
||||
init(cfg,false);
|
||||
}
|
||||
|
||||
private void init(JSONObject cfg, boolean mt) {
|
||||
// this.scheduler = new Scheduler();
|
||||
// this.scheduler.start();
|
||||
putJson(cfg);
|
||||
}
|
||||
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
@ -122,11 +129,6 @@ public class GodWorld implements GetJson, World {
|
||||
this(new JSONObject("{}"));
|
||||
}
|
||||
|
||||
private void init(JSONObject cfg, boolean mt) {
|
||||
this.scheduler = new Scheduler();
|
||||
this.scheduler.start();
|
||||
putJson(cfg);
|
||||
}
|
||||
|
||||
private void putJson(JSONObject cfg) {
|
||||
// Read assets
|
||||
@ -186,11 +188,19 @@ public class GodWorld implements GetJson, World {
|
||||
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 {
|
||||
AbstractAsset a;
|
||||
String class_name;
|
||||
Class<AbstractAsset> cls;
|
||||
|
||||
// get asset name
|
||||
try {
|
||||
class_name = cfg.getString(JKEYS.ASSET_TYPE);
|
||||
} catch (JSONException jex) {
|
||||
@ -198,10 +208,13 @@ public class GodWorld implements GetJson, World {
|
||||
return null;
|
||||
}
|
||||
|
||||
// create class from name
|
||||
try {
|
||||
cls = (Class<AbstractAsset>) Class.forName(class_name);
|
||||
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);
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user