Hello World

1.Create Model

   The model can be put together with Java source files, and can be combined with compiled classes in Jar when packaged.

    The model can be edited with a text editor. The text editor opens the model and enters the following.

<?xml version="1.0" encoding="utf-8"?>
 
<Println name="HelloWorld" descriptors="xworker.lang.actions.Actions/@Println"
       message="Hello World!"></Println>

2.Execute Model

    The model can be called by Java, and the code for executing HelloWorld's HelloWorld.java is as follows.

package org.xworker.test;

import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;

public class HelloWorld {
	public static void main(String args[]) {
		try {
			//Init engine
			World world = World.getInstance();
			world.init(".");
			
			//Get the HelloWorld model
			Thing helloWorld = world.getThing("org.xworker.test.HelloWorld");
			//Executing the HelloWorld model
			helloWorld.doAction("run", new ActionContext());
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
}

    When HelloWorld. Java is executed, you can see the output HelloWorld in the console!

 

Copyright ©  2007-2019 XWorker.org  版权所有  沪ICP备08000575号