diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml
index 0fd33bc..6c5f7d8 100644
--- a/nbproject/build-impl.xml
+++ b/nbproject/build-impl.xml
@@ -120,43 +120,7 @@ is divided into following sections:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Must set platform.home
- Must set platform.bootcp
- Must set platform.java
- Must set platform.javac
-
- The J2SE Platform is not correctly set up.
- Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files.
- Either open the project in the IDE and setup the Platform with the same name or add it manually.
- For example like this:
- ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file)
- or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used)
-
+
@@ -291,6 +255,20 @@ is divided into following sections:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -378,7 +356,7 @@ is divided into following sections:
-
+
@@ -429,7 +407,7 @@ is divided into following sections:
-
+
@@ -471,7 +449,7 @@ is divided into following sections:
-
+
@@ -550,7 +528,7 @@ is divided into following sections:
-
+
@@ -578,7 +556,7 @@ is divided into following sections:
-
+
@@ -654,7 +632,7 @@ is divided into following sections:
-
+
@@ -885,9 +863,6 @@ is divided into following sections:
-
-
-
@@ -937,7 +912,7 @@ is divided into following sections:
-
+
@@ -971,7 +946,7 @@ is divided into following sections:
-
+
@@ -1003,7 +978,7 @@ is divided into following sections:
-
+
@@ -1223,7 +1198,7 @@ is divided into following sections:
To run this application from the command line without Ant, try:
- ${platform.java} -jar "${dist.jar.resolved}"
+ java -jar "${dist.jar.resolved}"
@@ -1325,8 +1300,8 @@ is divided into following sections:
-
-
+
+
@@ -1519,19 +1494,16 @@ is divided into following sections:
-
-
-
-
+
-
+
-
+
diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties
index 9533c2b..fe5af1e 100644
--- a/nbproject/genfiles.properties
+++ b/nbproject/genfiles.properties
@@ -3,6 +3,6 @@ build.xml.script.CRC32=72406d8f
build.xml.stylesheet.CRC32=8064a381@1.79.1.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=ce5e9408
-nbproject/build-impl.xml.script.CRC32=9fb4669e
+nbproject/build-impl.xml.data.CRC32=65c6cbee
+nbproject/build-impl.xml.script.CRC32=ae093a94
nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.89.1.48
diff --git a/nbproject/project.properties b/nbproject/project.properties
index 70b4609..e457d56 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -1,4 +1,4 @@
-#Sat, 01 Dec 2018 09:27:21 +0100
+#Wed, 05 Dec 2018 17:40:04 +0100
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
@@ -100,7 +100,7 @@ manifest.custom.permissions=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
-platform.active=JDK_1.11.0
+platform.active=default_platform
project.license=bsd
run.classpath=${javac.classpath}\:${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
diff --git a/nbproject/project.xml b/nbproject/project.xml
index d52871a..878572a 100644
--- a/nbproject/project.xml
+++ b/nbproject/project.xml
@@ -10,7 +10,6 @@
OpenSeSim
-
diff --git a/src/opensesim/world/World.java b/src/opensesim/world/World.java
index b6f7066..be30bd9 100644
--- a/src/opensesim/world/World.java
+++ b/src/opensesim/world/World.java
@@ -36,6 +36,7 @@ import java.util.logging.Logger;
import opensesim.sesim.AssetPair;
import opensesim.util.idgenerator.IDGenerator;
import opensesim.util.SeSimException;
+import org.json.JSONException;
import org.json.JSONObject;
/**
@@ -43,21 +44,36 @@ import org.json.JSONObject;
* @author 7u83 <7u83@mail.ru>
*/
public class World {
+
+
public static final class JKEYS {
public static final String ASSETS = "assets";
public static final String EXCHANGES = "exchanges";
+
+ public static final String ASSET_SYMBOL = "symbol";
+ public static final String ASSET_TYPE = "type";
+
+
}
HashSet assetsById = new HashSet<>();
HashMap assetsBySymbol = new HashMap<>();
+
+
+
IDGenerator assetIdGenerator = new IDGenerator();
IDGenerator orderIdGenerator = new IDGenerator();
HashSet assetPairs = new HashSet<>();
ArrayList exchanges = new ArrayList<>();
+
+
+
+
+
/**
* Create a World object.
@@ -69,18 +85,37 @@ public class World {
// Read assets
JSONObject jassets = cfg.getJSONObject(World.JKEYS.ASSETS);
for (String symbol : jassets.keySet()) {
- AbstractAsset a = createAsset(jassets.getJSONObject(symbol));
+ AbstractAsset a;
+ try {
+ a = createAsset_p(jassets.getJSONObject(symbol));
+ } catch (SeSimException ex) {
+ Logger.getLogger(World.class.getName()).log(Level.SEVERE, null, ex);
+ return;
+ }
assetsById.add(a);
assetsBySymbol.put(symbol, a);
}
}
+
+
+ private long masterkey;
+ public World(long masterkey){
+ this.masterkey=masterkey;
+ }
- private AbstractAsset createAsset(JSONObject cfg) {
+ private AbstractAsset createAsset_p(JSONObject cfg) throws SeSimException {
AbstractAsset a;
String class_name;
Class cls;
- class_name = cfg.getString("type");
+ try {
+ class_name = cfg.getString(JKEYS.ASSET_TYPE);
+ }catch (JSONException jex){
+ Logger.getLogger(World.class.getName()).log(Level.SEVERE, null, jex);
+ return null;
+ }
+
+
try {
cls = (Class) Class.forName(class_name);
a = cls.getConstructor(World.class,JSONObject.class).newInstance(this,cfg);
@@ -88,6 +123,13 @@ public class World {
Logger.getLogger(World.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
+
+ if (this.assetsBySymbol.get(a.getSymbol())!=null){
+ throw new SeSimException("Already defined");
+ }
+
+ this.assetsById.add(a);
+ this.assetsBySymbol.put(a.getSymbol(),a);
return a;
}
@@ -119,8 +161,19 @@ public class World {
return ex;
}
- static final String JSON_ASSET = "asset";
- static final String JSON_EXCHANGES = "exchanges";
+
+ public AbstractAsset createAsset(long key, JSONObject cfg) throws SeSimException{
+ if (key!=masterkey)
+ throw new SeSimException("Access denied.");
+ return this.createAsset_p(cfg);
+ }
+
+
+ // static final String JSON_ASSET = "asset";
+ // static final String JSON_EXCHANGES = "exchanges";
+
+
+
/*
public JSONObject getConfig() {