The dynamic model can be used under the Java project, take the Maven project as an example.
Please refer to the following pom.xml to introduce related class libraries in your own Java project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <dependencies> <dependency> <groupId>org.xworker</groupId> <artifactId>xworker_swt_thingeditor</artifactId> <version>2.0.2</version> </dependency> <dependency> <groupId>org.xworker</groupId> <artifactId>xworker_webserver</artifactId> <version>2.0.2</version> </dependency> <dependency> <groupId>org.xworker</groupId> <artifactId>xworker_patch</artifactId> <version>2.0.2-patch1</version> </dependency> </dependencies> </project>
If you just use XWorker as a model editor, the scope of the related package can be set to test.
The SNAPSHOT version can access the latest XWorker model library, and the sonatype warehouse is for using the SNAPSHOT version of the class library.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <dependencies> <dependency> <groupId>org.xworker</groupId> <artifactId>xworker_swt_thingeditor</artifactId> <version>2.0.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.xworker</groupId> <artifactId>xworker_webserver</artifactId> <version>2.0.3-SNAPSHOT</version> </dependency> </dependencies> <repositories> <repository> <id>sonatype</id> <name>sonatype Repository</name> <url>https://oss.sonatype.org/content/groups/public/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> <layout>default</layout> </repository> </repositories> </project>
If you just use XWorker as a model editor, the scope of the related package can be set to test.
The dependencies in the above pom are the necessary dependencies to run the model editor. You can choose other model libraries according to your needs. You can refer to Model Library Tool.
Write a Java program to run the model editor.
import org.xmeta.World; import xworker.lang.util.XWorkerUtils; import xworker.swt.SwtThingEditor; import xworker.webserver.XWorkerWebServer; import java.io.File; public class ThingEditor { public static void main(String args[]){ try { //Get an instance of the dynamic model engine World world = World. getInstance(); //Initialize the working directory of the engine, some temporary files may be generated, the directory should be writable world.init("./xworker/"); //Add the model manager, that is, the directory where the model is stored, and it is needed to edit the model. Test is the name of the model manager and cannot be repeated with other model managers. world.addFileThingManager("myproject", new File("./src/main/resources"), false, true); //The model can be placed in the Java source directory, and the model can be compiled and packaged with Java, but the model in the jar is generally read-only //Check if initialization is required, such as re-indexing when the dependent model library is updated XWorkerUtils. setup(false); //run the web server and model editor XWorkerWebServer.run(); SwtThingEditor. run(); }catch(Exception e){ e.printStackTrace(); } System. exit(0); } }
Note that the startup time will be longer after the first startup or after the class library is changed. At this time, resources will be decompressed and indexes will be built at startup. After successful operation, the model manager will open, as shown in the figure below.
Copyright © 2007-2019 XWorker.org 版权所有 沪ICP备08000575号