The following about 3 minutes of GIF video demonstrates the basic method of dynamic model programming.The following video first creates a Person class, and then creates an instance Tom with the Person class, and finally executes Tom's related methods.
The above programming process is equivalent to the following code.
import org.xmeta.Thing; //Define class Person Thing Person = new Thing(); //code above equals java code: Object Person = new Object(); Person.set("descriptors", "xworker.lang.MetaDescriptor3"); //code above equals java code if setClass exists in java: //((Object) Person).setClass("xworker.lang.MetaDescriptor3")); //Define attributes Person.addChild(new Thing("name", "name", "xworker.lang.MetaDescriptor3/@attribute")); Person.addChild(new Thing("age", "age", "xworker.lang.MetaDescriptor3/@attribute")); //Define actions Thing actions = new Thing("xworker.lang.MetaDescriptor3/@actions"); Thing run = new Thing("run", "run", "xworker.lang.actions.Actions/@GroovyAction"); run.set("code", "println self.name;"); actions.addChild(run); Person.addChild(actions); //User class Person create object tom Thing tom = new Thing(Person.getMetadata().getPath()); tom.put("name", "Tom"); tom.put("age", "40"); //Execute tom's method tom.doAction("run", actionContext);
Copyright © 2007-2014 XWorker.org 版权所有