Quick Start

KevScript

Registry

Execute script in component

Directly trigger adaptations

This component will send each received messages to the core ModelService as KevScript.
This will have the effect of modifying the abstraction layer and so the running system.

1
2
3
4
5
6
7
8
9
10
11
12

@ComponentType(version=1,description="Update the current system using input messages as KevScript")publicclassKevScriptServiceComp{@KevoreeInjectprivateModelServicemodelService;@Inputpublicvoidin(Stringscript){// this will update the abstraction layerthis.modelService.submitScript(script);}}

Local execution

This component will execute each received messages as KevScript using an empty model as context.
Once executed, it will serialize the new model and send it to its output port named json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

@ComponentType(version=1,description="Transform incoming KevScript messages to JSON model")publicclassKevScript2ModelComp{@KevoreeInjectprivateKevScriptServicekevs;@OutputprivatePortjson;privateKevoreeFactoryfactory=newDefaultKevoreeFactory();privateJSONSerializerserializer=factory.createJSONSerializer();@Inputpublicvoidkevs(Stringscript){// create an empty modelfinalContainerRootmodel=factory.createContainerRoot();factory.root(model);// execute the incoming script to update the empty modelthis.kevs.execute(script,model);// serialize the model to JSON and send it through the output portthis.json.send(this.serializer.serialize(model));}}

Directly trigger adaptations

This component will send each received messages to the core ModelService as KevScript.
This will have the effect of modifying the abstraction layer and so the running system.

1
2
3
4
5
6
7
8
9
10
11

constAbstractComponent=require('kevoree-entities/lib/AbstractComponent');module.exports=AbstractComponent.extend({toString:'KevScriptServiceComp',tdef_version:1,in_in(script){// this will update the abstraction layerthis.kCore.submitScript(script);}});

Local execution

This component will execute each received messages as KevScript using an empty model as context.
Once executed, it will serialize the new model and send it to its output port named json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

constAbstractComponent=require('kevoree-entities/lib/AbstractComponent');constkevoree=require('kevoree-library');module.exports=AbstractComponent.extend({toString:'KevScript2ModelComp',tdef_version:1,construct(){constfactory=newkevoree.factory.DefaultKevoreeFactory();this.serializer=factory.createJSONSerializer();},in_kevs(script){// execute the incoming script on an empty model (default behavior in js)this.kCore.kevs.parse(script,(err,model)=>{if(err){console.error('Something went wrong',err.message);}else{// serialize the model to JSON and send it through the output portthis.out_json(this.serializer.serialize(model));}});},out_json(){/* noop as this function will be modified by the runtime */}});