Basic concepts

1.What is action?

    In the dynamic model, the model can run because the model can be transformed into action, which are equivalent to functions and methods, and can be executed.

    The class corresponding to the action is org.xmeta.Action

2.ActionContext (also known as variable context)

    ActionContext is the environment in which actions are executed. Variables and thread states are stored in ActionContext. Global variables, local variables, parameter transfer, and the implementation of various control models (while, for, try/catch, if, etc.) are all need ActionContext.

    The Java class corresponding to the ActionContext is org.xmeta.ActionContext

3.The Behavior of Objects

    The behavior of model objects is implemented by actions, and any model can be transformed into actions in the dynamic model. Therefore, the model engine used by XWorker specifies that the model under the sub-nodes of the model named actions is the definition of model behavior.

4.Demonstration code for executing actions and behaviors

import org.xmeta.Thing;
import org.xmeta.Action;
import org.xmeta.ActionContext;

//Transfer model into action
Action action = thing.getAction();

//Execute an action
action.run(new ActionContext());

//Execute a behavior of model through doAction method
thing.doAction("run", new ActionContext());

5.Action principle

    Actually, the principle of action is also the execution principle of dynamic model.

  1. Objects are models. Classes and behaviors of objects are also represented by models.
  2. Executing a model is the run method of executing the objects represented by the model.
  3. The run method of the object is also the model, so running the run method goes back to step 2.
  4. The above is a recursive process. In order for recursion to terminate, there must be a model with an engine that directly interprets the execution, rather than a run method that executes it.

    XWorker's model engine is implemented in Java, and the model class named JavaAction is interpreted and executed directly by the engine.

   

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