Get a model and use the model path to get it through the World object.
//Get an example of the model where World is singlet Thing thing = World.getInstance().getThing("HelloWorld");
If the model is saved in the file system, that is, managed by FileThingManager, it will be entered into the file modification monitoring after loading. When the date of the file is found to be modified by the external program, the latest model will be automatically loaded the next time it is acquired through World.
When loaded, the model is stored in a Map<String, SoftReference<Thing>> cache. When memory is tight, the JVM automatically reclaims the model in the cache.
So don't store persistent variables in the model, because the model may be garbage collected at any time.
When the model is modified, it can be saved by calling its save () or saveAs method, and the model can be removed by using the remove () method.
//Save thing.save(); //Save to other things managers and new paths thing.saveAs("_local", "xworker.test.TestHelloWorld"); //Remove model thing.remove(); //You can reset the encoding format before save thing.getMetadata().setCoderType(XmlThingCoder.TYPE);
Copyright © 2007-2019 XWorker.org 版权所有 沪ICP备08000575号