I do not really feel comfortable with putting my “domain information” into a “String-to-whatever” map within the Spatials. There are several reasons for this. Firstly, by using a generic map, one looses most of the benefits of “static typing”; it is likely that the wrong data-type could be used in some places. Also, NullPointerException are a lot easier to produce, then when using primitive fields. And, all those primitive wrappers uses more memory and cause more work for the GC, then primitive fields. I suppose this all makes me “old school”.
But most importantly, I want to keep my domain model separate from the JME API, so I can reuse it on the server, without needing to deploy the engine there too (I am aware this means I need to write my own networking code), in exactly the same way I would not want to deploy a Swing GUI jar on my server either.
I figured at least I could define my own domain interface similar to Control, and have a standard wrapper for all “entities” implementing Control and delegating to my domain model, to keep both sides linked at runtime. OTOH, it would probably be possible to inverse the relationship as well. Idk atm what makes most sense for me.
So my question is this: if you have a completely separate domain model, and the domain model is the “authoritative” source of all information (I mean in particular, the position, scale, and orientation of all Spatials), how does one go about re-creating the scene on “re-load”? Is there some kind of particularly appropriate pattern? Alternatively, I could serialize both (with different serialization APIs) the scene and the domain, but I would need to somehow re-connect them on re-load.