Engine

Engine is responsible for injection of component attributes. The injection requires component constructor provide the corresponding getter and setter method.

  1. Add the corresponding attribute node in the component structure XML (Suppose that you have registered Page and Row component.) See the following block of code as an example:
    <?xml version="1.0" encoding="UTF-8"?>
    <PageFormatter>
      <Page id="page1">
        <Row draggable="1" id="row_b1223959791733" title="html_service"/>
      </Page>
    </PageFormatter>
  2. Define the constructor of BTTRow and add corresponding getter and setter methods of attributes that need to be injected by IOC container.
    function BTTRow(){}
    BTTRow.prototype= {
    	title: null,
    	draggable: null,
    	getTitle: function(){
    		return this.title;
    	},
    	setTitle: function(title){
    		this.title = title;
    	},
    	getDraggable:function(){
    		return this.draggable;
    	},
    	setDraggable:function(draggable){
    		this.draggable=draggable
    	}
    };
    BTTRow.extend (BTTComponentBase); //let BTTRow inherit BTTComponentBase

In fact, besides injection of attribute which is provided with getter and setter methods, the engine also do some other injections. For example, if you don't specify the id of one component, the engine will generate a unique number and assign it to id attribute of this component instance.

The infrastructure of IOC engine is shown as follows.

the infrastructure of IOC engine